WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.17k stars 4.05k forks source link

Base styles: Improve the reduce-motion mixin #55566

Open afercia opened 9 months ago

afercia commented 9 months ago

Description

Splitting this out from https://github.com/WordPress/gutenberg/pull/55547

Ideally, the reduce-motion scss mixin should be able to reset any CSS transition / animation. However, this is not the case. Thdre are a few occurrences in the codebase where specific, ad-hoc, media query prefers-reduced-motion are in place because the mixin doesn't cover all the cases to properly reset a transition or animation.

Ideally, these specific ad-hoc media query should be avoided because they are redundant code, hard to maintain, and pronoe to bugs. A unique, centralized, mixin that works for all cases is certainly better.

The specific case in https://github.com/WordPress/gutenberg/pull/55547 didn't allow to use the reduce-motion mixin because the animation for the 'saving' buttons state uses the CSS property animation-iteration-count with a value of infinite. This property is not reset by the reduce-motion mixin.

https://github.com/WordPress/gutenberg/blob/1ee154f51d6b0a743fc7c99ba5959371237bbb0e/packages/base-styles/_mixins.scss#L185-L205

Notice the mixin sets animation-duration to 1ms instead of 0. This is because of this reason, which dates to more than 3 years ago. I'm not sure whther that concern is still valid. Regardles, the effect of: animation-duration: 1ms; on the saving buttons animation would just make the animation very fast because animation-iteration-count is still infinite.

At the very least, the mixing:

Step-by-step reproduction instructions

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

afercia commented 9 months ago

The enqueue_disable_animations_stylesheet E2E 'pugin' should be updated as well.

https://github.com/WordPress/gutenberg/blob/1ee154f51d6b0a743fc7c99ba5959371237bbb0e/packages/e2e-tests/plugins/disable-animations.php

afercia commented 9 months ago

Additionally, check any @keyframes animation.