Skip to content

Conversation

@austingreendev
Copy link
Contributor

🚧 WIP, still trying to get animation working correctly and some API tweaks 🚧

Description

This PR adds a new CollapsibleSubNavItem component.

Detail

screen shot 2018-10-15 at 3 03 29 pm

Checklist

  • 👌 design updates are Garden Designer approved (add the
    designer as a reviewer)
  • 💅 view component styling is based on a Garden CSS
    component
  • 🌐 Styleguidist demo is up-to-date (yarn start)
  • ⬅️ renders as expected with reversed (RTL) direction
  • 💂‍♂️ includes new unit and snapshot tests
  • 📒 any new files are included in the packages src/index.js export
  • 📝 tested in Chrome, Firefox, Safari, Edge, and IE11

Copy link
Contributor

@jordanalviso jordanalviso left a 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;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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]".

Copy link
Contributor Author

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.

@coveralls
Copy link

coveralls commented Oct 17, 2018

Coverage Status

Coverage decreased (-0.3%) to 94.781% when pulling 3369d15 on agreen/chrome-subnav-collapse into bb1e66c on master.

Copy link

@rauschermate rauschermate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Member

@jzempel jzempel left a 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`;
Copy link
Member

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.

Copy link
Member

@jzempel jzempel left a 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,
Copy link
Member

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)?

Copy link
Contributor Author

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.

@austingreendev
Copy link
Contributor Author

Yessss! This is looking good. Please just remove the @zendeskgarden/svg-icons duplicate from "dependencies" and we should be good to go!

Looks like I erroneously added it as a dependency when we first created the package. Now removed.

Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@austingreendev austingreendev merged commit 6b39fb5 into master Oct 18, 2018
@austingreendev austingreendev deleted the agreen/chrome-subnav-collapse branch October 18, 2018 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

7 participants