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
Show 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'
;
'use strict'
;
// @ngInject
const
{
createElement
}
=
require
(
'preact'
);
function
SpinnerController
(
$animate
,
$element
)
{
// ngAnimate conflicts with the spinners own CSS
$animate
.
enabled
(
false
,
$element
);
}
module
.
exports
=
{
/**
controller
:
SpinnerController
,
* Loading indicator.
controllerAs
:
'vm'
,
*/
template
:
`
function
Spinner
()
{
<div class="spinner__container">
// The `spinner__container` div only exists to center the spinner within
<span class="spinner">
// the `<spinner>` Angular component element. Once consumers of this component
<span><span>
// have been converted to Preact, we should be able to remove this.
</span></span>
return
(
<
div
className
=
"spinner__container"
>
{
/* See `.spinner` CSS definition for an explanation of the nested spans. */
}
<
span
className
=
"spinner"
>
<
span
>
<
span
/>
<
/span
>
<
/span
>
<
/span
>
<
/div
>
<
/div
>
`
,
);
};
}
Spinner
.
propTypes
=
{};
module
.
exports
=
Spinner
;
src/sidebar/components/test/spinner-test.js
View file @
6cd76608
'use strict'
;
'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
;
describe
(
'Spinner'
,
function
()
{
const
inject
=
angular
.
mock
.
inject
;
const
createSpinner
=
(
props
=
{})
=>
mount
(
<
Spinner
{...
props
}
/>
)
;
describe
(
'spinner'
,
function
()
{
// A spinner is a trivial component with no props. Just make sure it renders.
let
$animate
=
null
;
it
(
'renders'
,
()
=>
{
let
$element
=
null
;
const
wrapper
=
createSpinner
();
let
sandbox
=
null
;
assert
.
isTrue
(
wrapper
.
exists
(
'.spinner'
));
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
]);
});
});
});
});
src/sidebar/index.js
View file @
6cd76608
...
@@ -191,7 +191,7 @@ function startAngularApp(config) {
...
@@ -191,7 +191,7 @@ function startAngularApp(config) {
'sortMenu'
,
'sortMenu'
,
wrapReactComponent
(
require
(
'./components/sort-menu'
))
wrapReactComponent
(
require
(
'./components/sort-menu'
))
)
)
.
component
(
'spinner'
,
require
(
'./components/spinner'
))
.
component
(
'spinner'
,
wrapReactComponent
(
require
(
'./components/spinner'
)
))
.
component
(
'streamContent'
,
require
(
'./components/stream-content'
))
.
component
(
'streamContent'
,
require
(
'./components/stream-content'
))
.
component
(
'svgIcon'
,
wrapReactComponent
(
require
(
'./components/svg-icon'
)))
.
component
(
'svgIcon'
,
wrapReactComponent
(
require
(
'./components/svg-icon'
)))
.
component
(
'tagEditor'
,
require
(
'./components/tag-editor'
))
.
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