Skip to content
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

feat(PPDSC-2115): accordion motion #264

Merged
merged 21 commits into from
Sep 7, 2022

Conversation

mstuartf
Copy link
Contributor

@mstuartf mstuartf commented Jul 6, 2022

PPDSC-2115

What

  1. Background:
  • Accordion v1 does not support transitions
  1. What did you do:
    For the header:
  • Added support for transitions and set backgroundColorChange as default.

For the panel:

  • Considered using slideTop (similar to Drawer component) but this does not work. The Drawer sits above existing content, but the Accordion panel needs to sit within the other elements on the page when expanded.
  • Considered using scaleY but this distorts the panel contents during the transition.
  • Considered using height but this is not possible when expanded height is unknown.
  • Settled on using maxHeight, which seems to be the consensus: https://www.w3schools.com/howto/howto_js_accordion.asp
  • Added a new maxHeightChange transition preset.
  • Added support for transitions and set maxHeightChange as default.
  • Conditionally set the panel max height based on expanded state. This needs to be set manually in the component as it is specific to each case (i.e. not a generic value like 100%).
  1. What does the reviewers should expect:
  • Default transition presets working for accordion + ability to override

I have done:

  • Written unit tests against changes
  • Written functional tests against the component and/or NewsKit site
  • Updated relevant documentation

I have tested manually:

  • The feature's functionality is working as expected on Chrome, Firefox, Safari and Edge
  • The screen reader reads and flows through the elements as expected.
  • There are no new errors in the browser console coming from this PR.
  • When visual test is not added, it renders correctly on different browsers and mobile viewports (Safari, Firefox, small mobile viewport, tablet)
  • The Playground feature is working as expected

mstuartf added 3 commits July 5, 2022 10:55
- Add motion support to accordion header
- Add backgroundColorChange default transition present
- Update test snapshots
- Add transitionPreset override support
- Update overrides test snapshot
- Add transitionPreset override to storybook scenario
- Add maxHeightChange transition preset
- Conditionally set max-height on accordion panel (to scroll height or 0)
- Set maxHeightChange as default transitionPreset for accordion
- Add support for accordion transitionPreset overrides on panel
- Update types, tests and stories
@mstuartf mstuartf added ready for review Please assist in getting this reviewed feature This change contains a new feature labels Jul 6, 2022
@mstuartf mstuartf changed the title feat(PPDSC-2115): accordion motion height feat(PPDSC-2115): accordion motion Jul 6, 2022
@mstuartf mstuartf added WIP Work in progress and removed ready for review Please assist in getting this reviewed labels Jul 6, 2022
@mstuartf mstuartf added ready for review Please assist in getting this reviewed and removed WIP Work in progress labels Jul 7, 2022
Comment on lines 21 to 43
const MaxHeightTransitionPanel = ({
expanded,
children,
overrides,
}: Pick<AccordionProps, 'expanded' | 'children' | 'overrides'>) => {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (expanded) {
ref.current!.style.maxHeight = `${ref.current!.scrollHeight}px`;
} else {
ref.current!.style.maxHeight = '0px';
}
}, [expanded]);
return (
<StyledPanelTransitionContainer
ref={ref}
expanded={expanded}
overrides={overrides}
>
{children}
</StyledPanelTransitionContainer>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems good solution but I don't think is very flexible and it will not allow people to use other transition presets
You might need to use CSSTransition to make it more flexible.

mutebg
mutebg previously approved these changes Jul 12, 2022
mutebg
mutebg previously approved these changes Jul 13, 2022
mstuartf added 5 commits July 22, 2022 08:56
- Accordion tests failing because responsiveness managed by JS: 'In Ultrafast Grid, the DOM is taken from the local rendering and rerendered on multiple devices. This works for pages that are CSS-responsive. If JS comes into picture, we need to take multiple DOMs locally, for each width on which page DOM changes.'
- Add layoutBreakpoints config to fix.
@Vanals
Copy link
Contributor

Vanals commented Aug 18, 2022

Is this "Ready for review" ? I cannot see any ticket related to 2115 in the board or review column. If not can we remove the tag?

@mstuartf
Copy link
Contributor Author

Is this "Ready for review" ? I cannot see any ticket related to 2115 in the board or review column. If not can we remove the tag?

It is flagged (in the To Do column). I'm still waiting to hear back from Applitools about the failing tests.

@Vanals
Copy link
Contributor

Vanals commented Aug 19, 2022

Is this "Ready for review" ? I cannot see any ticket related to 2115 in the board or review column. If not can we remove the tag?

It is flagged (in the To Do column). I'm still waiting to hear back from Applitools about the failing tests.

I see. I think is a bit confusing in this way?
A PR is either ready for review or is not. If it is should be in the ready to review Jira column(can flag it if blocked) and if not ready should not have the tag in github :D.

@mstuartf mstuartf removed the ready for review Please assist in getting this reviewed label Aug 22, 2022
- Unset max height for expanded accordions. It is calculated incorrectly in the Applitools test env, causing the tests to fail.
@mstuartf mstuartf merged commit 319fed2 into main Sep 7, 2022
@mstuartf mstuartf deleted the feat/PPDSC-2115-accordion-motion-height branch September 7, 2022 15:54
Xin00163 pushed a commit that referenced this pull request Oct 17, 2022
* feat(PPDSC-2155): accordion header motion

- Add motion support to accordion header
- Add backgroundColorChange default transition present
- Update test snapshots
- Add transitionPreset override support
- Update overrides test snapshot
- Add transitionPreset override to storybook scenario

* feat(PPDSC-2115): accordion panel transitions

- Add maxHeightChange transition preset
- Conditionally set max-height on accordion panel (to scroll height or 0)
- Set maxHeightChange as default transitionPreset for accordion
- Add support for accordion transitionPreset overrides on panel
- Update types, tests and stories

* feat(PPDSC-2115): update theme snapshots

* feat(PPDSC-2115): fix a117 storybook issue

* feat(PPDSC-2115): support other transition presets

* feat(PPDSC-2115): update snapshots

* feat(PPDSC-2115): update panel height on window resize

* feat(PPDSC-2115): test for setting max height

* feat(PPDSC-2115): add storybook config for failing tests

- Accordion tests failing because responsiveness managed by JS: 'In Ultrafast Grid, the DOM is taken from the local rendering and rerendered on multiple devices. This works for pages that are CSS-responsive. If JS comes into picture, we need to take multiple DOMs locally, for each width on which page DOM changes.'
- Add layoutBreakpoints config to fix.

* feat(PPDSC-2115): layout breakpoints global setting

* feat(PPDSC-2115): Revert "feat(PPDSC-2115): layout breakpoints global setting"

This reverts commit 297abb2.

* feat(PPDSC-2115): prevent animation on first render

* feat(PPDSC-2115): prevent test failures

- Unset max height for expanded accordions. It is calculated incorrectly in the Applitools test env, causing the tests to fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This change contains a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants