-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚀 New Component: SidePanel (Labs) #866
Conversation
Better to call cb for internal state and collapsed state separately?
This component assumes no "force re-rendering" happens.
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, @lychyi! Thanks for working on this. 👍 I left some comments and questions and only one change requested. Let me know if anything is unclear. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🦩
Summary
While, Canvas Kit already has a Side Panel, we are unifying it as an internal initiative, starting with the container itself. This means that the existing side panel would have had to change significantly. Because of that we've decided to use the Labs namespace to build this new one and eventually deprecate the original one.
Basics
The side panel is made up of 3 parts:
It also includes a hook that wires the three together
useSidePanel()
. It returns anexpanded
state getter and setter (like any otheruseState
hook) and 3 sets of prop objects meant to be spread to their associated parts:panelProps
,labelProps
, andcontrolProps
.The hook itself takes a config object that allows you to set:
initialExpanded
(initial state of the panel),panelId
, andlabelId
(if either is defined it will be a string id, otherwise, it is uniquely generated). It can also take no arguments and return a default set of props and expanded state.The component also ships 1 default sub-component for the control:
SidePanel.ToggleButton
. This is anIconButton
with a default icon and is aware of whether it's a left-handed or right-handed side panel and positions the button accordingly.In our docs and examples, we recommend that a hidden label be used as an
aria-labelledby
target to make sure all parts of this side panel are accessible and read well on a screen reader.Usage
Notable differences to the current Side Panel
origin
prop)expanded
prop changes (onExpandedChange
) while the other is called when the panel transitions between'collapsed' | 'collapsing' | 'expanded' | 'expanding'
(onStateTransition
). The latter is useful if the side panel contents need to know when things are'collapsing'
or'expanding'
.Open Questions
Checklist
yarn test
passespackage.json
canvas-kit-react
and/orcanvas-kit-css
universal modules, ifapplicable
Additional References
Internal-only Figma Specs
Original side panel codebase
Closes #778
Blocked by #896