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
1a1fa267
Unverified
Commit
1a1fa267
authored
Nov 05, 2018
by
Hannah Stepanek
Committed by
GitHub
Nov 05, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #800 from hypothesis/spinner-component
Adjust spinner positioning and convert to component
parents
fd52ab43
42823a49
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
23 deletions
+42
-23
spinner.js
src/sidebar/components/spinner.js
+20
-0
search-input-test.js
src/sidebar/components/test/search-input-test.js
+2
-2
spinner-test.js
src/sidebar/components/test/spinner-test.js
+10
-5
spinner.js
src/sidebar/directive/spinner.js
+0
-12
index.js
src/sidebar/index.js
+1
-1
search-input.html
src/sidebar/templates/search-input.html
+1
-3
spinner.scss
src/styles/sidebar/components/spinner.scss
+8
-0
No files found.
src/sidebar/components/spinner.js
0 → 100644
View file @
1a1fa267
'use strict'
;
// @ngInject
function
SpinnerController
(
$animate
,
$element
)
{
// ngAnimate conflicts with the spinners own CSS
$animate
.
enabled
(
false
,
$element
);
}
module
.
exports
=
{
controller
:
SpinnerController
,
controllerAs
:
'vm'
,
template
:
`
<div class="spinner__container">
<span class="spinner">
<span><span>
</span></span>
</span>
</div>
`
,
};
src/sidebar/components/test/search-input-test.js
View file @
1a1fa267
...
...
@@ -46,13 +46,13 @@ describe('searchInput', function () {
describe
(
'loading indicator'
,
function
()
{
it
(
'is hidden when there are no network requests in flight'
,
function
()
{
const
el
=
util
.
createDirective
(
document
,
'search-input'
,
{});
const
spinner
=
el
[
0
].
querySelector
(
'
.
spinner'
);
const
spinner
=
el
[
0
].
querySelector
(
'spinner'
);
assert
.
equal
(
util
.
isHidden
(
spinner
),
true
);
});
it
(
'is visible when there are network requests in flight'
,
function
()
{
const
el
=
util
.
createDirective
(
document
,
'search-input'
,
{});
const
spinner
=
el
[
0
].
querySelector
(
'
.
spinner'
);
const
spinner
=
el
[
0
].
querySelector
(
'spinner'
);
fakeHttp
.
pendingRequests
.
push
([{}]);
el
.
scope
.
$digest
();
assert
.
equal
(
util
.
isHidden
(
spinner
),
false
);
...
...
src/sidebar/
directive
/test/spinner-test.js
→
src/sidebar/
components
/test/spinner-test.js
View file @
1a1fa267
...
...
@@ -2,6 +2,8 @@
const
angular
=
require
(
'angular'
);
const
util
=
require
(
'../../directive/test/util'
);
const
module
=
angular
.
mock
.
module
;
const
inject
=
angular
.
mock
.
inject
;
...
...
@@ -11,19 +13,18 @@ describe('spinner', function () {
let
sandbox
=
null
;
before
(
function
()
{
angular
.
module
(
'h'
,
[]).
directive
(
'spinner'
,
require
(
'../spinner'
));
angular
.
module
(
'h'
,
[]).
component
(
'spinner'
,
require
(
'../spinner'
));
});
beforeEach
(
module
(
'h'
));
beforeEach
(
inject
(
function
(
_$animate_
,
$compile
,
$rootScope
)
{
beforeEach
(
inject
(
function
(
_$animate_
)
{
sandbox
=
sinon
.
sandbox
.
create
();
$animate
=
_$animate_
;
sandbox
.
spy
(
$animate
,
'enabled'
);
$element
=
angular
.
element
(
'<span class="spinner"></span>'
);
$compile
(
$element
)(
$rootScope
.
$new
());
$element
=
util
.
createDirective
(
document
,
'spinner'
);
}));
afterEach
(
function
()
{
...
...
@@ -31,6 +32,10 @@ describe('spinner', function () {
});
it
(
'disables ngAnimate animations for itself'
,
function
()
{
assert
.
calledWith
(
$animate
.
enabled
,
false
,
sinon
.
match
(
$element
));
assert
.
calledOnce
(
$animate
.
enabled
);
const
[
enabled
,
jqElement
]
=
$animate
.
enabled
.
getCall
(
0
).
args
;
assert
.
equal
(
enabled
,
false
);
assert
.
equal
(
jqElement
[
0
],
$element
[
0
]);
});
});
src/sidebar/directive/spinner.js
deleted
100644 → 0
View file @
fd52ab43
'use strict'
;
module
.
exports
=
[
'$animate'
,
function
(
$animate
)
{
return
{
link
:
function
(
scope
,
elem
)
{
// ngAnimate conflicts with the spinners own CSS
$animate
.
enabled
(
false
,
elem
);
},
restrict
:
'C'
,
template
:
'<span><span></span></span>'
,
};
}];
src/sidebar/index.js
View file @
1a1fa267
...
...
@@ -160,6 +160,7 @@ function startAngularApp(config) {
.
component
(
'sidebarTutorial'
,
require
(
'./components/sidebar-tutorial'
))
.
component
(
'shareDialog'
,
require
(
'./components/share-dialog'
))
.
component
(
'sortDropdown'
,
require
(
'./components/sort-dropdown'
))
.
component
(
'spinner'
,
require
(
'./components/spinner'
))
.
component
(
'streamContent'
,
require
(
'./components/stream-content'
))
.
component
(
'svgIcon'
,
require
(
'./components/svg-icon'
))
.
component
(
'tagEditor'
,
require
(
'./components/tag-editor'
))
...
...
@@ -171,7 +172,6 @@ function startAngularApp(config) {
.
directive
(
'hBranding'
,
require
(
'./directive/h-branding'
))
.
directive
(
'hOnTouch'
,
require
(
'./directive/h-on-touch'
))
.
directive
(
'hTooltip'
,
require
(
'./directive/h-tooltip'
))
.
directive
(
'spinner'
,
require
(
'./directive/spinner'
))
.
directive
(
'windowScroll'
,
require
(
'./directive/window-scroll'
))
.
service
(
'analytics'
,
require
(
'./services/analytics'
))
...
...
src/sidebar/templates/search-input.html
View file @
1a1fa267
...
...
@@ -10,7 +10,5 @@
<button
type=
"button"
class=
"simple-search-icon top-bar__btn"
ng-hide=
"vm.loading"
>
<i
class=
"h-icon-search"
></i>
</button>
<button
type=
"button"
class=
"simple-search-icon btn btn-clean"
ng-show=
"vm.loading"
disabled
>
<span
class=
"btn-icon"
><span
class=
"spinner"
></span></span>
</button>
<spinner
class=
"top-bar__btn"
ng-show=
"vm.loading"
title=
"Loading…"
></spinner>
</form>
src/styles/sidebar/components/spinner.scss
View file @
1a1fa267
...
...
@@ -15,6 +15,14 @@ $part-height: 3 * $part-width;
to
{
transform
:
rotate
(
1turn
);
}
}
// Container which centers the spinner vertically.
.spinner__container
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
}
// The actual spinner itself.
.spinner
{
position
:
relative
;
display
:
inline-block
;
...
...
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