Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
6cd76608
Unverified
Commit
6cd76608
authored
Jun 14, 2019
by
Robert Knight
Committed by
GitHub
Jun 14, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1173 from hypothesis/react-spinner
Convert loading spinner to Preact
parents
a716d2dc
9711f1bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
50 deletions
+31
-50
spinner.js
src/sidebar/components/spinner.js
+21
-15
spinner-test.js
src/sidebar/components/test/spinner-test.js
+9
-34
index.js
src/sidebar/index.js
+1
-1
No files found.
src/sidebar/components/spinner.js
View file @
6cd76608
'use strict'
;
// @ngInject
function
SpinnerController
(
$animate
,
$element
)
{
// ngAnimate conflicts with the spinners own CSS
$animate
.
enabled
(
false
,
$element
);
}
const
{
createElement
}
=
require
(
'preact'
);
module
.
exports
=
{
controller
:
SpinnerController
,
controllerAs
:
'vm'
,
template
:
`
<div class="spinner__container">
<span class="spinner">
<span><span>
</span></span>
/**
* Loading indicator.
*/
function
Spinner
()
{
// The `spinner__container` div only exists to center the spinner within
// the `<spinner>` Angular component element. Once consumers of this component
// have been converted to Preact, we should be able to remove this.
return
(
<
div
className
=
"spinner__container"
>
{
/* See `.spinner` CSS definition for an explanation of the nested spans. */
}
<
span
className
=
"spinner"
>
<
span
>
<
span
/>
<
/span
>
<
/span
>
<
/div
>
`
,
};
);
}
Spinner
.
propTypes
=
{};
module
.
exports
=
Spinner
;
src/sidebar/components/test/spinner-test.js
View file @
6cd76608
'use strict'
;
const
angular
=
require
(
'angular'
);
const
{
createElement
}
=
require
(
'preact'
);
const
{
mount
}
=
require
(
'enzyme'
);
const
util
=
require
(
'../../directive/test/util
'
);
const
Spinner
=
require
(
'../spinner
'
);
const
module
=
angular
.
mock
.
module
;
const
inject
=
angular
.
mock
.
inject
;
describe
(
'Spinner'
,
function
()
{
const
createSpinner
=
(
props
=
{})
=>
mount
(
<
Spinner
{...
props
}
/>
)
;
describe
(
'spinner'
,
function
()
{
let
$animate
=
null
;
let
$element
=
null
;
let
sandbox
=
null
;
before
(
function
()
{
angular
.
module
(
'h'
,
[]).
component
(
'spinner'
,
require
(
'../spinner'
));
});
beforeEach
(
module
(
'h'
));
beforeEach
(
inject
(
function
(
_$animate_
)
{
sandbox
=
sinon
.
sandbox
.
create
();
$animate
=
_$animate_
;
sandbox
.
spy
(
$animate
,
'enabled'
);
$element
=
util
.
createDirective
(
document
,
'spinner'
);
}));
afterEach
(
function
()
{
sandbox
.
restore
();
});
it
(
'disables ngAnimate animations for itself'
,
function
()
{
assert
.
calledOnce
(
$animate
.
enabled
);
const
[
enabled
,
jqElement
]
=
$animate
.
enabled
.
getCall
(
0
).
args
;
assert
.
equal
(
enabled
,
false
);
assert
.
equal
(
jqElement
[
0
],
$element
[
0
]);
// A spinner is a trivial component with no props. Just make sure it renders.
it
(
'renders'
,
()
=>
{
const
wrapper
=
createSpinner
();
assert
.
isTrue
(
wrapper
.
exists
(
'.spinner'
));
});
});
src/sidebar/index.js
View file @
6cd76608
...
...
@@ -191,7 +191,7 @@ function startAngularApp(config) {
'sortMenu'
,
wrapReactComponent
(
require
(
'./components/sort-menu'
))
)
.
component
(
'spinner'
,
require
(
'./components/spinner'
))
.
component
(
'spinner'
,
wrapReactComponent
(
require
(
'./components/spinner'
)
))
.
component
(
'streamContent'
,
require
(
'./components/stream-content'
))
.
component
(
'svgIcon'
,
wrapReactComponent
(
require
(
'./components/svg-icon'
)))
.
component
(
'tagEditor'
,
require
(
'./components/tag-editor'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment