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
f684e341
Commit
f684e341
authored
Oct 13, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Jan 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update shared components in `Toolbar`
parent
93f699c7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
26 deletions
+37
-26
Toolbar.js
src/annotator/components/Toolbar.js
+37
-26
No files found.
src/annotator/components/Toolbar.js
View file @
f684e341
import
{
IconButton
}
from
'@hypothesis/frontend-shared'
;
import
{
ButtonBase
,
AnnotateIcon
,
CancelIcon
,
CaretRightIcon
,
CaretLeftIcon
,
HideIcon
,
NoteIcon
,
ShowIcon
,
}
from
'@hypothesis/frontend-shared/lib/next'
;
import
classnames
from
'classnames'
;
/**
* @typedef {import("@hypothesis/frontend-shared/lib/components/buttons").IconButtonProps} IconButtonProps
*
* @typedef {Omit<IconButtonProps, "className">} ToolbarButtonProps
* @typedef {import('@hypothesis/frontend-shared/lib/types').PresentationalProps} PresentationalProps
* @typedef {import('@hypothesis/frontend-shared/lib/components/input/ButtonBase').ButtonCommonProps} ButtonCommonProps
* @typedef {Omit<import('preact').JSX.HTMLAttributes<HTMLButtonElement>, 'icon'|'size'>} HTMLButtonAttributes
* @typedef {import('@hypothesis/frontend-shared/lib/types').IconComponent} IconComponent
*/
/**
* Style an IconButton for use on the Toolbar
*
* @param {
ToolbarButtonProps
} props
* @param {
PresentationalProps & ButtonCommonProps & HTMLButtonAttributes & {icon: IconComponent}
} props
*/
function
ToolbarButton
({
...
buttonProps
})
{
const
{
icon
,
title
,
...
restProps
}
=
buttonProps
;
function
ToolbarButton
({
icon
:
Icon
,
...
buttonProps
})
{
return
(
<
IconButton
class
Name
=
{
classnames
(
<
ButtonBase
class
es
=
{
classnames
(
'w-[30px] h-[30px]'
,
// These buttons have precise dimensions
'rounded-px'
,
// size of border radius in absolute units
'flex items-center justify-center'
,
'border bg-white text-grey-6 hover:text-grey-9'
,
'shadow transition-colors'
)}
icon
=
{
icon
}
title
=
{
title
}
{...
restProps
}
/
>
{...
buttonProps
}
>
<
Icon
/>
<
/ButtonBase
>
);
}
...
...
@@ -71,7 +80,7 @@ function StatusNotifier({ highlightsVisible }) {
* Callback to toggle visibility of highlights in the document.
* @prop {() => void} toggleSidebar -
* Callback to toggle the visibility of the sidebar.
* @prop {import("preact").Ref
<HTMLButton
Element>} [toggleSidebarRef] -
* @prop {import("preact").Ref
Object<HTML
Element>} [toggleSidebarRef] -
* Ref that gets set to the toolbar button for toggling the sidebar.
* This is exposed to enable the drag-to-resize functionality of this
* button.
...
...
@@ -114,8 +123,8 @@ export default function Toolbar({
absolutely positioned some way down the edge of the sidebar.
*/
}
{
useMinimalControls
&&
isSidebarOpen
&&
(
<
IconButton
class
Name
=
{
classnames
(
<
ButtonBase
class
es
=
{
classnames
(
'w-[27px] h-[27px] mt-[140px] ml-px-1.5'
,
'flex items-center justify-center bg-white border'
,
'text-grey-6 hover:text-grey-9 transition-colors'
,
...
...
@@ -126,32 +135,34 @@ export default function Toolbar({
'shadow-sidebar'
)}
title
=
"Close annotation sidebar"
icon
=
"cancel"
onClick
=
{
closeSidebar
}
/
>
>
<
CancelIcon
/>
<
/ButtonBase
>
)}
{
!
useMinimalControls
&&
(
<>
<
IconButton
class
Name
=
{
classnames
(
<
ButtonBase
class
es
=
{
classnames
(
// Height and width to align with the sidebar's top bar
'h-[40px] w-[33px] pl-
px-1.5
'
,
'h-[40px] w-[33px] pl-
[6px]
'
,
'bg-white text-grey-5 hover:text-grey-9'
,
// Turn on left and bottom borders to continue the
// border of the sidebar's top bar
'border-l border-b'
)}
button
Ref
=
{
toggleSidebarRef
}
element
Ref
=
{
toggleSidebarRef
}
title
=
"Annotation sidebar"
icon
=
{
isSidebarOpen
?
'caret-right'
:
'caret-left'
}
expanded
=
{
isSidebarOpen
}
pressed
=
{
isSidebarOpen
}
onClick
=
{
toggleSidebar
}
/
>
>
{
isSidebarOpen
?
<
CaretRightIcon
/>
:
<
CaretLeftIcon
/>
}
<
/ButtonBase
>
<
div
className
=
"space-y-px-1.5 mt-px-2"
>
<
ToolbarButton
title
=
"Show highlights"
icon
=
{
showHighlights
?
'show'
:
'hide'
}
icon
=
{
showHighlights
?
ShowIcon
:
HideIcon
}
selected
=
{
showHighlights
}
onClick
=
{
toggleHighlights
}
/
>
...
...
@@ -161,7 +172,7 @@ export default function Toolbar({
?
'New page note'
:
'New annotation'
}
icon
=
{
newAnnotationType
===
'note'
?
'note'
:
'annotate'
}
icon
=
{
newAnnotationType
===
'note'
?
NoteIcon
:
AnnotateIcon
}
onClick
=
{
createAnnotation
}
/
>
<
/div
>
...
...
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