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
0edbc1ba
Commit
0edbc1ba
authored
Apr 06, 2021
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Apr 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Notebook components to use shared button components
parent
d1cc0a07
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
52 deletions
+47
-52
NotebookModal.js
src/annotator/components/NotebookModal.js
+11
-9
NotebookModal-test.js
src/annotator/components/test/NotebookModal-test.js
+2
-2
PaginationNavigation.js
src/sidebar/components/PaginationNavigation.js
+20
-14
annotator.scss
src/styles/annotator/annotator.scss
+3
-0
notebook.scss
src/styles/annotator/notebook.scss
+1
-2
buttons.scss
src/styles/sidebar/buttons.scss
+9
-0
PaginationNavigation.scss
src/styles/sidebar/components/PaginationNavigation.scss
+1
-25
No files found.
src/annotator/components/NotebookModal.js
View file @
0edbc1ba
...
@@ -3,8 +3,7 @@ import classnames from 'classnames';
...
@@ -3,8 +3,7 @@ import classnames from 'classnames';
import
{
createSidebarConfig
}
from
'../config/sidebar'
;
import
{
createSidebarConfig
}
from
'../config/sidebar'
;
// FIXME: use the button from the frontend shared package once this is stable.
import
{
LabeledButton
}
from
'../../shared/components/buttons'
;
import
Button
from
'../../sidebar/components/Button'
;
/**
/**
* @typedef NotebookIframeProps
* @typedef NotebookIframeProps
...
@@ -102,13 +101,16 @@ export default function NotebookModal({ eventBus, config }) {
...
@@ -102,13 +101,16 @@ export default function NotebookModal({ eventBus, config }) {
return
(
return
(
<
div
className
=
{
classnames
(
'Notebook__outer'
,
{
'is-hidden'
:
isHidden
})}
>
<
div
className
=
{
classnames
(
'Notebook__outer'
,
{
'is-hidden'
:
isHidden
})}
>
<
div
className
=
"Notebook__inner"
>
<
div
className
=
"Notebook__inner"
>
<
Button
<
div
className
=
"Notebook__close-button-container"
>
icon
=
"cancel"
<
LabeledButton
className
=
"Notebook__close-button"
icon
=
"cancel"
buttonText
=
"Close"
title
=
"Close the Notebook"
title
=
"Close the Notebook"
onClick
=
{
onClose
}
onClick
=
{
onClose
}
variant
=
"dark"
/
>
>
Close
<
/LabeledButton
>
<
/div
>
{
groupId
!==
null
&&
(
{
groupId
!==
null
&&
(
<
NotebookIframe
key
=
{
iframeKey
}
config
=
{
config
}
groupId
=
{
groupId
}
/
>
<
NotebookIframe
key
=
{
iframeKey
}
config
=
{
config
}
groupId
=
{
groupId
}
/
>
)}
)}
...
...
src/annotator/components/test/NotebookModal-test.js
View file @
0edbc1ba
...
@@ -109,7 +109,7 @@ describe('NotebookModal', () => {
...
@@ -109,7 +109,7 @@ describe('NotebookModal', () => {
assert
.
isFalse
(
outer
.
hasClass
(
'is-hidden'
));
assert
.
isFalse
(
outer
.
hasClass
(
'is-hidden'
));
act
(()
=>
{
act
(()
=>
{
wrapper
.
find
(
'Button'
).
prop
(
'onClick'
)();
wrapper
.
find
(
'
Labeled
Button'
).
prop
(
'onClick'
)();
});
});
wrapper
.
update
();
wrapper
.
update
();
...
@@ -125,7 +125,7 @@ describe('NotebookModal', () => {
...
@@ -125,7 +125,7 @@ describe('NotebookModal', () => {
});
});
assert
.
equal
(
document
.
body
.
style
.
overflow
,
'hidden'
);
assert
.
equal
(
document
.
body
.
style
.
overflow
,
'hidden'
);
act
(()
=>
{
act
(()
=>
{
wrapper
.
find
(
'Button'
).
prop
(
'onClick'
)();
wrapper
.
find
(
'
Labeled
Button'
).
prop
(
'onClick'
)();
});
});
assert
.
notEqual
(
document
.
body
.
style
.
overflow
,
'hidden'
);
assert
.
notEqual
(
document
.
body
.
style
.
overflow
,
'hidden'
);
});
});
...
...
src/sidebar/components/PaginationNavigation.js
View file @
0edbc1ba
import
{
pageNumberOptions
}
from
'../util/pagination'
;
import
{
pageNumberOptions
}
from
'../util/pagination'
;
import
Button
from
'./Button
'
;
import
{
LabeledButton
}
from
'../../shared/components/buttons
'
;
/**
/**
* @typedef PaginationNavigationProps
* @typedef PaginationNavigationProps
...
@@ -35,13 +35,15 @@ function PaginationNavigation({ currentPage, onChangePage, totalPages }) {
...
@@ -35,13 +35,15 @@ function PaginationNavigation({ currentPage, onChangePage, totalPages }) {
<
div
className
=
"PaginationNavigation"
>
<
div
className
=
"PaginationNavigation"
>
<
div
className
=
"PaginationNavigation__relative PaginationNavigation__prev"
>
<
div
className
=
"PaginationNavigation__relative PaginationNavigation__prev"
>
{
hasPreviousPage
&&
(
{
hasPreviousPage
&&
(
<
Button
<
Labeled
Button
className
=
"Pagination
Navigation__b
utton"
className
=
"Pagination
PageB
utton"
icon
=
"arrow-left"
icon
=
"arrow-left"
buttonText
=
"prev"
title
=
"Go to previous page"
title
=
"Go to previous page"
onClick
=
{
e
=>
changePageTo
(
currentPage
-
1
,
e
.
target
)}
onClick
=
{
e
=>
changePageTo
(
currentPage
-
1
,
e
.
target
)}
/
>
variant
=
"dark"
>
prev
<
/LabeledButton
>
)}
)}
<
/div
>
<
/div
>
<
ul
className
=
"PaginationNavigation__pages"
>
<
ul
className
=
"PaginationNavigation__pages"
>
...
@@ -50,28 +52,32 @@ function PaginationNavigation({ currentPage, onChangePage, totalPages }) {
...
@@ -50,28 +52,32 @@ function PaginationNavigation({ currentPage, onChangePage, totalPages }) {
{
page
===
null
?
(
{
page
===
null
?
(
<
div
className
=
"PaginationNavigation__gap"
>
...
<
/div
>
<
div
className
=
"PaginationNavigation__gap"
>
...
<
/div
>
)
:
(
)
:
(
<
Button
<
LabeledButton
className
=
"PaginationPageButton"
key
=
{
`page-
${
idx
}
`
}
key
=
{
`page-
${
idx
}
`
}
buttonText
=
{
page
.
toString
()}
title
=
{
`Go to page
${
page
}
`
}
title
=
{
`Go to page
${
page
}
`
}
className
=
"PaginationNavigation__page-button"
pressed
=
{
page
===
currentPage
}
isPressed
=
{
page
===
currentPage
}
onClick
=
{
e
=>
changePageTo
(
page
,
e
.
target
)}
onClick
=
{
e
=>
changePageTo
(
page
,
e
.
target
)}
/
>
variant
=
"dark"
>
{
page
.
toString
()}
<
/LabeledButton
>
)}
)}
<
/li
>
<
/li
>
))}
))}
<
/ul
>
<
/ul
>
<
div
className
=
"PaginationNavigation__relative PaginationNavigation__next"
>
<
div
className
=
"PaginationNavigation__relative PaginationNavigation__next"
>
{
hasNextPage
&&
(
{
hasNextPage
&&
(
<
Button
<
Labeled
Button
className
=
"Pagination
Navigation__button PaginationNavigation__button-right
"
className
=
"Pagination
PageButton
"
icon
=
"arrow-right"
icon
=
"arrow-right"
buttonText
=
"next"
iconPosition
=
"right"
iconPosition
=
"right"
title
=
"Go to next page"
title
=
"Go to next page"
onClick
=
{
e
=>
changePageTo
(
currentPage
+
1
,
e
.
target
)}
onClick
=
{
e
=>
changePageTo
(
currentPage
+
1
,
e
.
target
)}
/
>
variant
=
"dark"
>
next
<
/LabeledButton
>
)}
)}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
...
src/styles/annotator/annotator.scss
View file @
0edbc1ba
...
@@ -10,6 +10,9 @@
...
@@ -10,6 +10,9 @@
// -----------------
// -----------------
@use
'@hypothesis/frontend-shared/styles'
;
@use
'@hypothesis/frontend-shared/styles'
;
// Shared button styles (TEMPORARY)
@use
'../shared'
;
// Annotator-specific components.
// Annotator-specific components.
@use
'./components/AdderToolbar'
;
@use
'./components/AdderToolbar'
;
@use
'./components/Buckets'
;
@use
'./components/Buckets'
;
...
...
src/styles/annotator/notebook.scss
View file @
0edbc1ba
...
@@ -39,11 +39,10 @@
...
@@ -39,11 +39,10 @@
border
:
none
;
border
:
none
;
}
}
.Notebook__close-button
{
.Notebook__close-button
-container
{
position
:
absolute
;
position
:
absolute
;
right
:
0
;
right
:
0
;
font-size
:
var
.
$font-size--large
;
font-size
:
var
.
$font-size--large
;
@include
buttons
.
button--primary
;
margin
:
var
.
$layout-space--xsmall
;
margin
:
var
.
$layout-space--xsmall
;
cursor
:
pointer
;
cursor
:
pointer
;
}
}
src/styles/sidebar/buttons.scss
View file @
0edbc1ba
@use
'../variables'
as
var
;
// Button styling for the sidebar extending common button-component styles
// Button styling for the sidebar extending common button-component styles
@use
'../shared/components/buttons/mixins'
as
buttons
;
@use
'../shared/components/buttons/mixins'
as
buttons
;
...
@@ -25,3 +26,11 @@
...
@@ -25,3 +26,11 @@
}
}
}
}
}
}
// This button style has asymmetrical padding. Hold it here to see if
// this kind of padding is useful in other patterns.
.PaginationPageButton
{
@include
buttons
.
LabeledButton
{
padding
:
var
.
$layout-space--small
var
.
$layout-space
;
}
}
src/styles/sidebar/components/PaginationNavigation.scss
View file @
0edbc1ba
...
@@ -26,31 +26,6 @@
...
@@ -26,31 +26,6 @@
display
:
none
;
display
:
none
;
}
}
&
__button
,
&
__page-button
{
@include
buttons
.
button--labeled
(
$background-color
:
transparent
,
$active-background-color
:
var
.
$grey-3
);
}
&
__page-button
{
margin
:
var
.
$layout-space--xxsmall
;
padding
:
var
.
$layout-space--small
var
.
$layout-space
;
&
[
aria-pressed
=
'true'
]
{
background-color
:
var
.
$grey-3
;
}
}
&
__button-right
{
// FIXME Button SVG margins assume that the icon is on the left
svg
{
margin-left
:
var
.
$layout-space--xxsmall
;
}
padding-right
:
var
.
$layout-space--xxsmall
;
}
@include
responsive
.
wide-handheld-and-up
{
@include
responsive
.
wide-handheld-and-up
{
// Where there's enough horizontal space,
// Where there's enough horizontal space,
// lay out page navigation buttons horizontally as:
// lay out page navigation buttons horizontally as:
...
@@ -65,6 +40,7 @@
...
@@ -65,6 +40,7 @@
display
:
block
;
display
:
block
;
grid-area
:
numberedPages
;
grid-area
:
numberedPages
;
@include
layout
.
row
(
$justify
:
center
,
$align
:
center
);
@include
layout
.
row
(
$justify
:
center
,
$align
:
center
);
@include
layout
.
horizontal-rhythm
(
0
.5em
);
}
}
}
}
}
}
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