Base styles: Improve the reduce-motion mixin #55566
Labels
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Package] Base styles
/packages/base-styles
[Type] Enhancement
A suggestion for improvement.
Description
Splitting this out from #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 queryprefers-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 #55547 didn't allow to use the
reduce-motion
mixin because the animation for the 'saving' buttons state uses the CSS propertyanimation-iteration-count
with a value ofinfinite
. This property is not reset by thereduce-motion
mixin.gutenberg/packages/base-styles/_mixins.scss
Lines 185 to 205 in 1ee154f
Notice the mixin sets
animation-duration
to1ms
instead of0
. 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 stillinfinite
.At the very least, the mixing:
animation-iteration-count
to0
(or maybe 1).animation-duration: 1ms;
is still needed. Ideally, this should be set to0
.prefers-reduced-motion
in the codebase should be replaced by the mixin.reduce-motion
mixin.Step-by-step reproduction instructions
@include reduce-motion("animation");
after this line:gutenberg/packages/components/src/button/style.scss
Line 244 in 1ee154f
Button
saving state accessibility. #55547 has already been merged, replace the ad-hoc media query with@include reduce-motion("animation");
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
The text was updated successfully, but these errors were encountered: