-
-
Notifications
You must be signed in to change notification settings - Fork 929
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
Add rule to enforce use of prefers-reduced-motion with animations and transitions #6202
Comments
cc: @thibaudcolas (is this what you meant by correct use of |
@mattxwang yup. See also stylelint-a11y’s rule. Another common way to implement @media (prefers-reduced-motion: reduce) {
*, ::before, ::after {
animation-delay: -1ms !important;
animation-duration: 1ms !important;
animation-iteration-count: 1 !important;
background-attachment: initial !important;
scroll-behavior: auto !important;
transition-duration: 0s !important;
transition-delay: 0s !important;
}
} I don’t think this undermines the usefulness of the rule as you suggested it, but it’s worth keeping in mind – at least the appropriateness of the rule to different approaches would need to be documented. We also need to be careful with our examples (as this is what people will refer to when trying to figure out what to make of an error):
|
Having a reset on all animations is considered to be an anti-pattern by many. As such I wouldn't consider the existence of animation reset code to be a strong consideration for not doing this work. Two of the main three browser companies indicate that That leads into the "too many false positives" concern. I do not consider it a concern because every animation should be evaluated and documenting that evaluation with an ignore line indicating an assessment was made seems like a minimal effort. AppleWebkit's take on it can be found here: https://webkit.org/blog/7551/responsive-design-for-motion/ That document has a lot of good examples of the visuals that should be reduced. A couple relevant statements from the document are:
Google has mixed messaging at https://web.dev/prefers-reduced-motion/:
Despite earlier in the document acknowledging the usability and accessibility uses of motion.
MozillaMDN article indicated that
|
Thanks for the exciting proposal. The idea of requiring the The "About rules" doc says that built-in rules "have a singular purpose", but what properties should the new rule be applied to?
Also, what name should be suitable for the new rule, according to the naming guideline? |
Ah, I think I should've done a bit more homework before making this issue. It does seem like it fulfills the requirements that I'm suggesting (or at least - mostly. I'm not sure if I like the autofix). This is maybe part of the broader discussion about bringing either that plugin and/or @thibaudcolas's work into the main repo/namespace. @thibaudcolas, did you want to write up that issue based on our conversation in the contributors team, or did you want me to?
I personally think all of
Thanks for pointing that out. Looking at "No rules", I think our rule just disallows something, and so probably needs |
If the rule is looking for the existence of If a11y is going to be a part of core then maybe I haven't looked at how difficult it is to limit the errors to "motion" based styles, but limiting it to vestibular based triggers I'm guessing is impossible. As such there will always be false positives. The stylelint-a11y autofix is definitely a "no animation" instead of "reduced motion" implementation. I don't think this rule should be autofixable. |
What is the problem you're trying to solve?
Branching off of our discussion around accessibility features in @stylelint/contributors and a discussion with the FE accessibility team at @chanzuckerberg, one pattern we want to enforce is the use of
prefers-reduced-motion
in blocks that also define animations and transitions.One positive use-case, taken from @chanzuckerberg's design system
In contrast, we would like to disallow
A similar rule could apply to
transition-*
keywords as well; CZI's design system has a use-case for that as well.Two caveats:
What solution would you like to see?
A rule to enforce the behaviour explained above. I'm no naming expert, so help there is certainly welcome!
With the caveat that I have little experience writing rule specs, I'm thinking something like:
animation-require-prefers-reduced-motion
(name pending)ignoreSelectors
feature here?Expected
prefers-reduced-motionto be used within declaration block
prefers-reduced-motion
when defining animations and transitions."prefers-reduced-motion
and accessibilityI'm happy to work on an implementation pending the discussion on this rule!
The text was updated successfully, but these errors were encountered: