-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Base styles: Improve the reduce-motion mixin #55566
Comments
The |
Additionally, check any |
In this comment, it is suggested to use the standard pattern instead of the At the same time, efforts are being made to replace the Will this solve the issue? |
I'm not sure that pattern takes into account Regardless, the mixin still 'resets' gutenberg/packages/base-styles/_mixins.scss Line 246 in 9bde809
animation-iteration-count .
|
Taking the .components-button {
// ...
&.is-busy,
&.is-secondary.is-busy,
&.is-secondary.is-busy:disabled,
&.is-secondary.is-busy[aria-disabled="true"] {
@media not (prefers-reduced-motion) {
animation: components-button__busy-animation 2500ms infinite linear;
}
// ...
}
// ...
} Testing on Storybook: 2fb686667068ad8495cf1a7bfd6b9ea8.mp4I think the advantage of this approach is that there is no need to "reset" Another benefit is that the size of the compiled files is slightly reduced. Code compiled using the .components-button {
transition: all 0.2s;
}
@media (prefers-reduced-motion: reduce) {
.components-button {
transition-duration: 0s;
transition-delay: 0s;
}
} Code compiled using the .components-button {
@media not (prefers-reduced-motion) {
transition: all 0.2s;
}
} |
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: