From e822e01cf2828101458009c1ae850c29d022ba97 Mon Sep 17 00:00:00 2001 From: Natalie-B-Wiese Date: Thu, 5 Nov 2026 11:26:25 -0500 Subject: [PATCH 1/2] Show flash alerts to users who prefer reduced motion --- src/components/alert.css | 8 ++++++++ src/core/tokens/shared_tokens.css | 11 +++++++++++ src/stories/Components/Alert/Alert.mdx | 2 ++ 3 files changed, 21 insertions(+) diff --git a/src/components/alert.css b/src/components/alert.css index 82a0a4a7..9aeccf27 100644 --- a/src/components/alert.css +++ b/src/components/alert.css @@ -39,6 +39,14 @@ animation: var(--op-animation-flash); inset-block-start: var(--op-space-large); inset-inline-end: var(--op-space-large); + + /* + The reset shortens every animation to 0.01ms under reduced motion, which would leave the flash + on the off-screen last frame of rm-slide-in-out-flash. !important is needed to override the reset. + */ + @media (prefers-reduced-motion: reduce) { + animation: var(--op-animation-reduced-motion-flash) !important; + } } &.alert--warning { diff --git a/src/core/tokens/shared_tokens.css b/src/core/tokens/shared_tokens.css index 4138c452..d6ca1cd1 100644 --- a/src/core/tokens/shared_tokens.css +++ b/src/core/tokens/shared_tokens.css @@ -152,6 +152,7 @@ * @presenter Animation */ --op-animation-flash: rm-slide-in-out-flash 5s normal forwards; + --op-animation-reduced-motion-flash: rm-hide-flash 5s normal forwards; /* Encoded Images */ @@ -270,3 +271,13 @@ inset-inline-end: -100%; } } + +/* + Used instead of rm-slide-in-out-flash when the user prefers reduced motion. + The flash stays in place, then hides once the same 5s have passed. +*/ +@keyframes rm-hide-flash { + to { + visibility: hidden; + } +} diff --git a/src/stories/Components/Alert/Alert.mdx b/src/stories/Components/Alert/Alert.mdx index 1a797a8b..4ad820e9 100644 --- a/src/stories/Components/Alert/Alert.mdx +++ b/src/stories/Components/Alert/Alert.mdx @@ -100,6 +100,8 @@ If your application needs to allow dismissing these alerts, you can add a second The alert component can also be used as an animated notification message by adding `.alert--flash` to the top level. This supports all the alert variations and styles. +For users who prefer reduced motion, the flash appears in place without sliding and hides after the same 5 seconds. The `--op-animation-reduced-motion-flash` token controls this animation. + Flash ## Alert Structure From f2ab0ca7231dd8839b3d5f53fb2b1ef0115959de Mon Sep 17 00:00:00 2001 From: Natalie-B-Wiese Date: Thu, 5 Nov 2026 12:09:14 -0500 Subject: [PATCH 2/2] Put the reduced-motion flash time in the animation delay --- src/components/alert.css | 8 -------- src/core/tokens/shared_tokens.css | 20 +++++++++----------- src/stories/Components/Alert/Alert.mdx | 2 +- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/components/alert.css b/src/components/alert.css index 9aeccf27..82a0a4a7 100644 --- a/src/components/alert.css +++ b/src/components/alert.css @@ -39,14 +39,6 @@ animation: var(--op-animation-flash); inset-block-start: var(--op-space-large); inset-inline-end: var(--op-space-large); - - /* - The reset shortens every animation to 0.01ms under reduced motion, which would leave the flash - on the off-screen last frame of rm-slide-in-out-flash. !important is needed to override the reset. - */ - @media (prefers-reduced-motion: reduce) { - animation: var(--op-animation-reduced-motion-flash) !important; - } } &.alert--warning { diff --git a/src/core/tokens/shared_tokens.css b/src/core/tokens/shared_tokens.css index d6ca1cd1..435ebba4 100644 --- a/src/core/tokens/shared_tokens.css +++ b/src/core/tokens/shared_tokens.css @@ -152,7 +152,6 @@ * @presenter Animation */ --op-animation-flash: rm-slide-in-out-flash 5s normal forwards; - --op-animation-reduced-motion-flash: rm-hide-flash 5s normal forwards; /* Encoded Images */ @@ -246,6 +245,15 @@ var(--op-input-outer-focus) var(--op-color-alerts-notice-plus-five); } +/* @tokens-end keeps the reduced-motion override below out of the Input Focus token docs */ + +@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; + } +} + /* Animations */ @keyframes rm-slide-in-out-flash { /* @@ -271,13 +279,3 @@ inset-inline-end: -100%; } } - -/* - Used instead of rm-slide-in-out-flash when the user prefers reduced motion. - The flash stays in place, then hides once the same 5s have passed. -*/ -@keyframes rm-hide-flash { - to { - visibility: hidden; - } -} diff --git a/src/stories/Components/Alert/Alert.mdx b/src/stories/Components/Alert/Alert.mdx index 4ad820e9..49989b92 100644 --- a/src/stories/Components/Alert/Alert.mdx +++ b/src/stories/Components/Alert/Alert.mdx @@ -100,7 +100,7 @@ If your application needs to allow dismissing these alerts, you can add a second The alert component can also be used as an animated notification message by adding `.alert--flash` to the top level. This supports all the alert variations and styles. -For users who prefer reduced motion, the flash appears in place without sliding and hides after the same 5 seconds. The `--op-animation-reduced-motion-flash` token controls this animation. +For users who prefer reduced motion, the flash appears in place without sliding and hides after 5 seconds. If you override `--op-animation-flash`, also override it inside `@media (prefers-reduced-motion: reduce)`. Put the time in the delay, not the duration, because the reset shortens every animation duration to 0.01ms. Flash