Repository navigation
Show flash alerts to users who prefer reduced motion - #374
Conversation
|
Suggestion: I think this can be a token-only fix. The reset only forces /* shared_tokens.css */
@media (prefers-reduced-motion: reduce) {
:root {
/* modern-css-reset forces animation-duration to 0.01ms, so the 5s goes in the delay */
--op-animation-flash: rm-slide-in-out-flash 0.01ms 5s forwards;
}
}During the delay, This lets us drop:
I tested it in Chromium with the reset rule applied: the alert is in place from 0s to 5s, then off screen, with no positions in between (no slide). Docs: I'd replace the added line in
|
3059dcd to
f2ab0ca
Compare
Task
[OP-XXX](link to ticket)No ticket. Upstream fix for the workaround in RoleModel/property-intel#4042.Why?
Users who turn on "reduce motion" never see a flash alert (
.alert--flash).rm-slide-in-out-flash) starts off screen, slides in, holds, then slides back off screen, andforwardskeeps that last off-screen frame.0.01ms !importantunderprefers-reduced-motion: reduce. So the flash animation ends right away and the alert sits off screen for good.With this change, those users get the alert in place with no sliding, and it goes away after the same 5 seconds. The default (motion) behavior is unchanged.
RoleModel/property-intel#4042 works around this in the app with the same approach. Once a release includes this fix, that override can be removed.
What Changed
--op-animation-flashunderprefers-reduced-motion: reduceasrm-slide-in-out-flash 0.01ms 5s forwards. The reset forces onlyanimation-duration, notanimation-delay, so the 5s goes in the delay. During the delayforwardsapplies no keyframe, so the alert sits at its owninset-inline-end; at 5s it jumps to the off-screen last keyframe. (Thanks to @Jeremy-Walton for this simpler approach.)@tokens-endcomment before that override, so the Storybook token addon doesn't list it under Input Focusdist/tokens/tokens.jsonreports the reduced-motion value for--op-animation-flash, becausebuild_token_json.jskeeps the last declaration. The dark shadow tokens already work this way.Quality Assurance
yarn lint:css,yarn test)[ ] Have you updated any usage of changed tokens?Only.alert--flashuses it.[ ] Did you add a component?[ ] Have you added it to the dependency graph?[ ] Have you added it to the docs?[ ] Did you update a component?Token change only;alert.cssis unchanged.[ ] Have you updated the dependency graph?[ ] Do you need to update the package version?Left for the release PR.[ ] Did you update the example pages in.storybook/assets?[ ] Were any changes made to the top level optics.css file?[ ] Were those changes reflected in the other top level files?Verification
Built
dist/css/optics.cssfrommainand from this branch, loaded a page with one.alert.alert--flashin Playwright (Chromium, 1000px wide), and sampled its position:mainmainUnder reduced motion the alert held the same position at every sample until it went off screen (no slide). The Storybook build shows
--op-animation-flashonly on the Animation token page, with its normal value.Screenshots
With
prefers-reduced-motion: reduce(Playwright, Chromium): the alert appears in place at 1s with no slide and goes away 5s later. Recorded with the first version of this fix; the delay version looks the same. The motion version looks the same as before.reduced-motion-flash.webm
🤖 Generated with Claude Code