-
Notifications
You must be signed in to change notification settings - Fork 97
feat(chrome): add new CollapsibleSubNavItem component #187
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
Conversation
jordanalviso
left a comment
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.
👍
|
|
||
| const COMPONENT_ID = 'chrome.collapsable_sub_nav_item'; | ||
| const PANEL_COMPONENT_ID = 'chrome.collapsable_sub_nav_item_panel'; | ||
| const SUB_NAV_ITEM_HEIGHT_PX = 38; |
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.
Item height is variable – can wrap to multiple lines. I was hoping this measurement could be obtained and applied post-render.
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.
If we are animating the max-height over time, how would we calculate that total height without having a render flash? Lets discuss offline.
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.
On post-render, iterate over the children and get element.offsetHeight + top-margin + bottom-margin for each. Apply the value to the panel as style="max-height: [value]".
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.
I just pushed an update that adds a new AccordionContainer component. This abstracts all of the accessibility logic required for the W3C accordion pattern
I also calculated the panel maxHeight using a slightly different approach. Lets discuss offline.
rauschermate
left a comment
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.
LGTM 👍
jzempel
left a comment
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.
This is coming along nicely, @Austin94! Left a comment re: the max-height setting.
|
|
||
| componentDidUpdate() { | ||
| if (this.props.expanded && this.panelRef) { | ||
| this.panelRef.style.maxHeight = `${this.panelRef.offsetHeight}px`; |
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.
This doesn't appear to be animating at all. You can slow down the panel expansion by adding transition: max-height 2s ease-in-out !important; to the styled component to ensure you've got it working.
jzempel
left a comment
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.
Yessss! This is looking good. Please just remove the @zendeskgarden/svg-icons duplicate from "dependencies" and we should be good to go!
|
|
||
| getHeadingProps = ({ role = 'heading', ...other } = {}) => { | ||
| return { | ||
| role, |
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.
@Austin94 per https://www.w3.org/TR/wai-aria-practices/#accordion, the role="heading" also needs a value for aria-level. Can this be addressed so that the consumer can feed in that value (and in the demo so that it passes the axe audit)?
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.
Voiceover was smart enough to auto-detect the level, didn't realize that AXE was complaining.
This is now a required attribute and prop for the AccordionContainer and the CollapsibleSubNavItem.
Looks like I erroneously added it as a dependency when we first created the package. Now removed. |
jzempel
left a comment
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.
🎉
🚧 WIP, still trying to get animation working correctly and some API tweaks 🚧
Description
This PR adds a new
CollapsibleSubNavItemcomponent.Detail
Checklist
designer as a reviewer)
component
yarn start)src/index.jsexport