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

Popover / ToggleGroupControl: Use useReducedMotion() from @wordpress/compose #60168

Merged
merged 2 commits into from Mar 27, 2024

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Mar 25, 2024

What?

Use our internal useReducedMotion() utility instead of the framer-motion one.

Why?

Our version is more broadly utilized, and it does the same thing, so there's no good reason to use two different versions

How?

We're using the version from @wordpress/compose which is already a dependency.

Testing Instructions

  • Use your browser dev tools to emulate prefers-reduced-motion.
  • Verify Popover appear/disappear animation still works well and is properly disabled when prefers-reduced-motion is enabled/disabled.
    • You can test it by clicking the ellipsis in the block toolbar to reveal the block settings menu.
    • You can also test it in Storybook.
  • Verify ToggleGroupControl selected toggle backdrop animation still works well and is properly disabled when prefers-reduced-motion is enabled/disabled.
    • You can test it with the "Size" field in the block sidebar for a Paragraph block.
    • You can also test it in Storybook.
  • All tests should pass and all checks should be green.

Testing Instructions for Keyboard

None

Screenshots or screencast

None

@tyxla tyxla added [Type] Enhancement A suggestion for improvement. [Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components labels Mar 25, 2024
@tyxla tyxla requested review from fullofcaffeine, jsnajdr and a team March 25, 2024 13:10
@tyxla tyxla self-assigned this Mar 25, 2024
@tyxla tyxla requested a review from ajitbohra as a code owner March 25, 2024 13:10
Copy link

github-actions bot commented Mar 25, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@tyxla tyxla force-pushed the update/framer-motion-usage-components branch from cf5c22f to e9b6017 Compare March 26, 2024 17:03
Copy link
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

Looks good and works as expected 👍 I also checked the source code for the one in Framer, and there was nothing unexpected in there.

@tyxla tyxla merged commit 9598b80 into trunk Mar 27, 2024
58 checks passed
@tyxla tyxla deleted the update/framer-motion-usage-components branch March 27, 2024 10:23
@github-actions github-actions bot added this to the Gutenberg 18.1 milestone Mar 27, 2024
Copy link
Member

@jsnajdr jsnajdr left a comment

Choose a reason for hiding this comment

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

Nice. The framer-motion's useReducedMotion uses the same media query (prefers-reduced-motion) but it's interesting that they don't bother to listen to the dynamic updates. They just assume that the value is constant for the entire lifetime of the page and read it just once.

One thing that could be inspiring for us is that they use a shared global instance of the media query. Our useReducedMotion leads to creating 10+ identical media queries, one for each use of the hook. Similarly, useViewportMatch also leads to multiple identical max-width/min-width queries.

I'm not sure if it has any real performance impact, it probably doesn't. MediaQueryList should be a cheap object.

carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Mar 27, 2024
…ss/compose` (WordPress#60168)

* Use useReducedMotion() from @wordpress/compose

* CHANGELOG

Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
cbravobernal pushed a commit to garridinsi/gutenberg that referenced this pull request Apr 9, 2024
…ss/compose` (WordPress#60168)

* Use useReducedMotion() from @wordpress/compose

* CHANGELOG

Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants