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
26c4f7e1
Commit
26c4f7e1
authored
Jan 13, 2023
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Jan 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert `SidebarPanel` to TS
parent
106caf60
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
SidebarPanel.tsx
src/sidebar/components/SidebarPanel.tsx
+18
-19
No files found.
src/sidebar/components/SidebarPanel.
js
→
src/sidebar/components/SidebarPanel.
tsx
View file @
26c4f7e1
import
{
Panel
}
from
'@hypothesis/frontend-shared'
;
import
type
{
ComponentChildren
}
from
'preact'
;
import
{
useCallback
,
useEffect
,
useRef
}
from
'preact/hooks'
;
import
scrollIntoView
from
'scroll-into-view'
;
import
type
{
PanelName
}
from
'../../types/sidebar'
;
import
{
useSidebarStore
}
from
'../store'
;
import
Slider
from
'./Slider'
;
/**
* @typedef {import("../../types/sidebar").PanelName} PanelName
*/
/**
* @typedef SidebarPanelProps
* @prop {import("preact").ComponentChildren} children
* @prop {string} [icon] - An optional icon name for display next to the panel's title
* @prop {PanelName} panelName -
* A string identifying this panel. Only one `panelName` may be active at any time.
* Multiple panels with the same `panelName` would be "in sync", opening and closing together.
* @prop {string} title - The panel's title
* @prop {(active: boolean) => void} [onActiveChanged] -
* Optional callback to invoke when this panel's active status changes
*/
export
type
SidebarPanelProps
=
{
children
:
ComponentChildren
;
/** An optional icon name for display next to the panel's title */
icon
?:
string
;
/**
* A string identifying this panel. Only one `panelName` may be active at any
* time. Multiple panels with the same `panelName` would be "in sync", opening
* and closing together.
*/
panelName
:
PanelName
;
title
:
string
;
/** Optional callback to invoke when this panel's active status changes */
onActiveChanged
?:
(
active
:
boolean
)
=>
void
;
};
/**
* Base component for a sidebar panel. Only one sidebar panel
* (as defined by the panel's `panelName`) is active (visible) at one time.
*
* @param {SidebarPanelProps} props
*/
export
default
function
SidebarPanel
({
children
,
...
...
@@ -34,11 +33,11 @@ export default function SidebarPanel({
panelName
,
title
,
onActiveChanged
,
})
{
}
:
SidebarPanelProps
)
{
const
store
=
useSidebarStore
();
const
panelIsActive
=
store
.
isSidebarPanelOpen
(
panelName
);
const
panelElement
=
useRef
(
/** @type {HTMLDivElement|null}*/
(
null
)
);
const
panelElement
=
useRef
<
HTMLDivElement
|
null
>
(
null
);
const
panelWasActive
=
useRef
(
panelIsActive
);
// Scroll the panel into view if it has just been opened
...
...
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