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
c5e8702b
Commit
c5e8702b
authored
Jul 25, 2023
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Jul 26, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract `TabHeader` and `TabPanel`
Keep these unmocked in `ShareDialog` for the moment.
parent
b8551fbc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
64 deletions
+75
-64
ShareDialog.tsx
src/sidebar/components/ShareDialog/ShareDialog.tsx
+2
-62
TabHeader.tsx
src/sidebar/components/ShareDialog/TabHeader.tsx
+34
-0
TabPanel.tsx
src/sidebar/components/ShareDialog/TabPanel.tsx
+33
-0
ShareDialog-test.js
src/sidebar/components/ShareDialog/test/ShareDialog-test.js
+6
-2
No files found.
src/sidebar/components/ShareDialog/ShareDialog.tsx
View file @
c5e8702b
...
...
@@ -2,18 +2,13 @@ import {
Button
,
Card
,
CardActions
,
CardTitle
,
CloseButton
,
CopyIcon
,
IconButton
,
Input
,
InputGroup
,
LockIcon
,
TabList
,
Tab
,
}
from
'@hypothesis/frontend-shared'
;
import
classnames
from
'classnames'
;
import
type
{
ComponentChildren
,
JSX
}
from
'preact'
;
import
{
useCallback
,
useState
}
from
'preact/hooks'
;
import
{
pageSharingLink
}
from
'../../helpers/annotation-sharing'
;
...
...
@@ -24,63 +19,8 @@ import { copyText } from '../../util/copy-to-clipboard';
import
ShareLinks
from
'../ShareLinks'
;
import
SidebarPanel
from
'../SidebarPanel'
;
import
LoadingSpinner
from
'./LoadingSpinner'
;
/**
* Render a header to go above a Card, with contents in a TabList
*/
function
TabHeader
({
children
}:
{
children
:
ComponentChildren
})
{
return
(
<
div
data
-
testid=
"tab-header"
className=
"flex items-center"
>
<
CloseButton
classes=
{
classnames
(
// This element comes first in source order before tabs, but is
// positioned last. This puts this button earlier in the tab
// sequence than the tabs, allowing tabs to be immediately adjacent
// to their controlled tab panels/tab content in the tab sequence.
'order-last'
,
// Always render this button at 16px square regardless of parent
// font size
'text-[16px]'
,
'text-grey-6 hover:text-grey-7 hover:bg-grey-3/50'
)
}
title=
"Close"
variant=
"custom"
size=
"sm"
/>
<
TabList
classes=
"grow gap-x-1 -mb-[1px] z-2"
>
{
children
}
</
TabList
>
</
div
>
);
}
type
TabPanelProps
=
{
active
?:
boolean
;
title
?:
ComponentChildren
;
}
&
JSX
.
HTMLAttributes
<
HTMLDivElement
>
;
/**
* Render a `role="tabpanel"` element within a Card layout. It will be
* visually hidden unless `active`.
*/
function
TabPanel
({
children
,
active
,
title
,
...
htmlAttributes
}:
TabPanelProps
)
{
return
(
<
div
role=
"tabpanel"
{
...
htmlAttributes
}
className=
{
classnames
(
'p-3 focus-visible-ring ring-inset'
,
{
hidden
:
!
active
,
})
}
hidden=
{
!
active
}
>
{
title
&&
<
CardTitle
>
{
title
}
</
CardTitle
>
}
<
div
className=
"space-y-3 pt-2"
>
{
children
}
</
div
>
</
div
>
);
}
import
TabHeader
from
'./TabHeader'
;
import
TabPanel
from
'./TabPanel'
;
type
SharePanelContentProps
=
{
loading
:
boolean
;
...
...
src/sidebar/components/ShareDialog/TabHeader.tsx
0 → 100644
View file @
c5e8702b
import
{
CloseButton
,
TabList
}
from
'@hypothesis/frontend-shared'
;
import
classnames
from
'classnames'
;
import
type
{
ComponentChildren
}
from
'preact'
;
/**
* Render a header to go above a Card, with contents in a TabList
*/
export
default
function
TabHeader
({
children
,
}:
{
children
:
ComponentChildren
;
})
{
return
(
<
div
data
-
testid=
"tab-header"
className=
"flex items-center"
>
<
CloseButton
classes=
{
classnames
(
// This element comes first in source order before tabs, but is
// positioned last. This puts this button earlier in the tab
// sequence than the tabs, allowing tabs to be immediately adjacent
// to their controlled tab panels/tab content in the tab sequence.
'order-last'
,
// Always render this button at 16px square regardless of parent
// font size
'text-[16px]'
,
'text-grey-6 hover:text-grey-7 hover:bg-grey-3/50'
)
}
title=
"Close"
variant=
"custom"
size=
"sm"
/>
<
TabList
classes=
"grow gap-x-1 -mb-[1px] z-2"
>
{
children
}
</
TabList
>
</
div
>
);
}
src/sidebar/components/ShareDialog/TabPanel.tsx
0 → 100644
View file @
c5e8702b
import
{
CardTitle
}
from
'@hypothesis/frontend-shared'
;
import
classnames
from
'classnames'
;
import
type
{
ComponentChildren
,
JSX
}
from
'preact'
;
export
type
TabPanelProps
=
{
active
?:
boolean
;
title
?:
ComponentChildren
;
}
&
JSX
.
HTMLAttributes
<
HTMLDivElement
>
;
/**
* Render a `role="tabpanel"` element within a Card layout. It will be
* hidden unless `active`.
*/
export
default
function
TabPanel
({
children
,
active
,
title
,
...
htmlAttributes
}:
TabPanelProps
)
{
return
(
<
div
role=
"tabpanel"
{
...
htmlAttributes
}
className=
{
classnames
(
'p-3 focus-visible-ring ring-inset'
,
{
hidden
:
!
active
,
})
}
hidden=
{
!
active
}
>
{
title
&&
<
CardTitle
>
{
title
}
</
CardTitle
>
}
<
div
className=
"space-y-3 pt-2"
>
{
children
}
</
div
>
</
div
>
);
}
src/sidebar/components/ShareDialog/test/ShareDialog-test.js
View file @
c5e8702b
...
...
@@ -45,8 +45,12 @@ describe('ShareDialog', () => {
};
$imports
.
$mock
(
mockImportedComponents
());
// Don't mock this very simple component
$imports
.
$restore
({
'./LoadingSpinner'
:
true
});
// Don't mock these simple components for now
$imports
.
$restore
({
'./LoadingSpinner'
:
true
,
'./TabHeader'
:
true
,
'./TabPanel'
:
true
,
});
$imports
.
$mock
({
'../../store'
:
{
useSidebarStore
:
()
=>
fakeStore
},
'../../helpers/annotation-sharing'
:
{
...
...
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