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
ada86614
Commit
ada86614
authored
Apr 20, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Apr 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert SelectionTabs to Tailwind
parent
fb95af45
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
56 deletions
+29
-56
SelectionTabs.js
src/sidebar/components/SelectionTabs.js
+24
-17
SelectionTabs-test.js
src/sidebar/components/test/SelectionTabs-test.js
+5
-6
SelectionTabs.scss
src/styles/sidebar/components/SelectionTabs.scss
+0
-32
_index.scss
src/styles/sidebar/components/_index.scss
+0
-1
No files found.
src/sidebar/components/SelectionTabs.js
View file @
ada86614
import
{
Frame
,
Icon
,
LabeledButton
}
from
'@hypothesis/frontend-shared'
;
import
{
Frame
,
Icon
,
LabeledButton
,
LinkButton
,
}
from
'@hypothesis/frontend-shared'
;
import
classnames
from
'classnames'
;
import
classnames
from
'classnames'
;
import
{
applyTheme
}
from
'../helpers/theme'
;
import
{
applyTheme
}
from
'../helpers/theme'
;
...
@@ -44,10 +49,13 @@ function Tab({
...
@@ -44,10 +49,13 @@ function Tab({
const
title
=
count
>
0
?
`
${
label
}
(
${
count
}
available)`
:
label
;
const
title
=
count
>
0
?
`
${
label
}
(
${
count
}
available)`
:
label
;
return
(
return
(
<
LabeledButton
<
LinkButton
classes
=
{
classnames
(
'text-color-text'
,
'SelectionTab'
,
{
classes
=
{
classnames
(
'is-selected'
:
isSelected
,
'inline bg-transparent min-w-[5.25rem] text-color-text hover:!no-underline'
,
})}
{
'font-bold'
:
isSelected
,
}
)}
// Listen for `onMouseDown` so that the tab is selected when _pressed_
// Listen for `onMouseDown` so that the tab is selected when _pressed_
// as this makes the UI feel faster. Also listen for `onClick` as a fallback
// as this makes the UI feel faster. Also listen for `onClick` as a fallback
// to enable selecting the tab via other input methods.
// to enable selecting the tab via other input methods.
...
@@ -61,15 +69,12 @@ function Tab({
...
@@ -61,15 +69,12 @@ function Tab({
<>
<>
{
children
}
{
children
}
{
count
>
0
&&
!
isWaitingToAnchor
&&
(
{
count
>
0
&&
!
isWaitingToAnchor
&&
(
<
span
<
span
className
=
"relative bottom-[3px] left-[2px] text-tiny"
>
className
=
"text-tiny"
style
=
"position:relative;bottom:3px;left:2px"
>
{
count
}
{
count
}
<
/span
>
<
/span
>
)}
)}
<
/
>
<
/
>
<
/L
abeled
Button
>
<
/L
ink
Button
>
);
);
}
}
...
@@ -109,11 +114,13 @@ function SelectionTabs({ annotationsService, isLoading, settings }) {
...
@@ -109,11 +114,13 @@ function SelectionTabs({ annotationsService, isLoading, settings }) {
const
showNotesUnavailableMessage
=
selectedTab
===
'note'
&&
noteCount
===
0
;
const
showNotesUnavailableMessage
=
selectedTab
===
'note'
&&
noteCount
===
0
;
return
(
return
(
<
div
className
=
"hyp-u-vertical-spacing--4 SelectionTabs__container"
>
<
div
<
div
className
=
"hyp-u-layout-row hyp-u-horizontal-spacing--6 SelectionTabs"
className
=
{
classnames
(
role
=
"tablist"
// 9px balances out the space above the tabs
'space-y-3 pb-[9px]'
)}
>
>
<
div
className
=
"flex gap-x-6 theme-clean:ml-[15px]"
role
=
"tablist"
>
<
Tab
<
Tab
count
=
{
annotationCount
}
count
=
{
annotationCount
}
isWaitingToAnchor
=
{
isWaitingToAnchorAnnotations
}
isWaitingToAnchor
=
{
isWaitingToAnchorAnnotations
}
...
@@ -145,7 +152,7 @@ function SelectionTabs({ annotationsService, isLoading, settings }) {
...
@@ -145,7 +152,7 @@ function SelectionTabs({ annotationsService, isLoading, settings }) {
)}
)}
<
/div
>
<
/div
>
{
selectedTab
===
'note'
&&
settings
.
enableExperimentalNewNoteButton
&&
(
{
selectedTab
===
'note'
&&
settings
.
enableExperimentalNewNoteButton
&&
(
<
div
className
=
"
hyp-u-layout-row--justify-right
"
>
<
div
className
=
"
flex justify-end
"
>
<
LabeledButton
<
LabeledButton
data
-
testid
=
"new-note-button"
data
-
testid
=
"new-note-button"
icon
=
"add"
icon
=
"add"
...
@@ -171,7 +178,7 @@ function SelectionTabs({ annotationsService, isLoading, settings }) {
...
@@ -171,7 +178,7 @@ function SelectionTabs({ annotationsService, isLoading, settings }) {
<
br
/>
<
br
/>
Create
one
by
selecting
some
text
and
clicking
the
{
' '
}
Create
one
by
selecting
some
text
and
clicking
the
{
' '
}
<
Icon
<
Icon
classes
=
"
m-0.5 inline
-mt-0.5"
classes
=
"
inline m-0.5
-mt-0.5"
name
=
"annotate"
name
=
"annotate"
title
=
"Annotate"
title
=
"Annotate"
/>
{
' '
}
/>
{
' '
}
...
...
src/sidebar/components/test/SelectionTabs-test.js
View file @
ada86614
...
@@ -72,8 +72,8 @@ describe('SelectionTabs', () => {
...
@@ -72,8 +72,8 @@ describe('SelectionTabs', () => {
const
annotationTab
=
wrapper
.
find
(
'Tab[label="Annotations"]'
);
const
annotationTab
=
wrapper
.
find
(
'Tab[label="Annotations"]'
);
const
noteTab
=
wrapper
.
find
(
'Tab[label="Page notes"]'
);
const
noteTab
=
wrapper
.
find
(
'Tab[label="Page notes"]'
);
assert
.
isTrue
(
annotationTab
.
find
(
'L
abeled
Button'
).
props
().
pressed
);
assert
.
isTrue
(
annotationTab
.
find
(
'L
ink
Button'
).
props
().
pressed
);
assert
.
isFalse
(
noteTab
.
find
(
'L
abeled
Button'
).
props
().
pressed
);
assert
.
isFalse
(
noteTab
.
find
(
'L
ink
Button'
).
props
().
pressed
);
});
});
it
(
'should not display the add-page-note button when the annotations tab is active'
,
()
=>
{
it
(
'should not display the add-page-note button when the annotations tab is active'
,
()
=>
{
...
@@ -93,12 +93,11 @@ describe('SelectionTabs', () => {
...
@@ -93,12 +93,11 @@ describe('SelectionTabs', () => {
const
annotationTabButton
=
wrapper
const
annotationTabButton
=
wrapper
.
find
(
'Tab[label="Annotations"]'
)
.
find
(
'Tab[label="Annotations"]'
)
.
find
(
'L
abeled
Button'
);
.
find
(
'L
ink
Button'
);
const
noteTabButton
=
wrapper
const
noteTabButton
=
wrapper
.
find
(
'Tab[label="Page notes"]'
)
.
find
(
'Tab[label="Page notes"]'
)
.
find
(
'L
abeled
Button'
);
.
find
(
'L
ink
Button'
);
assert
.
isTrue
(
noteTabButton
.
find
(
'button'
).
hasClass
(
'is-selected'
));
assert
.
isTrue
(
noteTabButton
.
prop
(
'pressed'
));
assert
.
isTrue
(
noteTabButton
.
prop
(
'pressed'
));
assert
.
isFalse
(
annotationTabButton
.
prop
(
'pressed'
));
assert
.
isFalse
(
annotationTabButton
.
prop
(
'pressed'
));
});
});
...
@@ -175,7 +174,7 @@ describe('SelectionTabs', () => {
...
@@ -175,7 +174,7 @@ describe('SelectionTabs', () => {
const
wrapper
=
createComponent
();
const
wrapper
=
createComponent
();
const
orphanTab
=
wrapper
.
find
(
'Tab[label="Orphans"]'
);
const
orphanTab
=
wrapper
.
find
(
'Tab[label="Orphans"]'
);
assert
.
isTrue
(
orphanTab
.
find
(
'L
abeled
Button'
).
prop
(
'pressed'
));
assert
.
isTrue
(
orphanTab
.
find
(
'L
ink
Button'
).
prop
(
'pressed'
));
});
});
it
(
'should not display orphans tab if there are 0 orphans'
,
()
=>
{
it
(
'should not display orphans tab if there are 0 orphans'
,
()
=>
{
...
...
src/styles/sidebar/components/SelectionTabs.scss
deleted
100644 → 0
View file @
fb95af45
@use
'../../variables'
as
var
;
.SelectionTabs__container
{
// FIXME: This should be a margin, and it should be handled by the parent,
// but needs to be considered carefully because applying vertical rhythm to
// this component's parent messes with the calculations in the virtualized
// thread list. Needs another pass. Note also that it is `10px` (and looks
// unbalanced at the standard vertical rhythm size of `1rem`)
padding-bottom
:
10px
;
}
.SelectionTab
{
margin
:
0
;
padding
:
0
;
font-weight
:
normal
;
background-color
:
transparent
;
min-width
:
5
.25rem
;
&
:hover:not
([
disabled
])
{
color
:
var
.
$color-link-hover
;
}
&
.is-selected
{
font-weight
:
bold
;
}
}
/** Clean theme affordances */
#{
var
.
$sidebar--theme-clean
}
.SelectionTabs
{
margin-left
:
15px
;
}
src/styles/sidebar/components/_index.scss
View file @
ada86614
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
@use
'./NotebookView'
;
@use
'./NotebookView'
;
@use
'./NotebookResultCount'
;
@use
'./NotebookResultCount'
;
@use
'./PaginationNavigation'
;
@use
'./PaginationNavigation'
;
@use
'./SelectionTabs'
;
@use
'./SearchInput'
;
@use
'./SearchInput'
;
@use
'./StyledText'
;
@use
'./StyledText'
;
@use
'./ToastMessages'
;
@use
'./ToastMessages'
;
...
...
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