Skip to content

Commit 1efb0d5

Browse files
authored
fix: Respect prefers-reduced-motion setting in examples (#8945)
1 parent 433f9ed commit 1efb0d5

File tree

9 files changed

+30
-3
lines changed

9 files changed

+30
-3
lines changed

packages/@react-spectrum/s2/src/Disclosure.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ const panelStyles = style({
299299
font: 'body',
300300
height: '--disclosure-panel-height',
301301
overflow: 'clip',
302-
transition: '[height]'
302+
transition: {
303+
default: '[height]',
304+
'@media (prefers-reduced-motion: reduce)': 'none'
305+
}
303306
});
304307

305308
const panelInner = style({

packages/dev/s2-docs/pages/react-aria/SegmentedControl.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
border-radius: 8px;
1818
background: var(--gray-50);
1919
outline: 2px solid var(--gray-600);
20+
21+
@media (prefers-reduced-motion: reduce) {
22+
transition: none;
23+
}
2024
}
2125

2226
.segmented-control-item {

packages/react-aria-components/docs/Disclosure.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ import {ChevronRight} from 'lucide-react';
9999
height: var(--disclosure-panel-height);
100100
transition: height 250ms;
101101
overflow: clip;
102+
103+
@media (prefers-reduced-motion: reduce) {
104+
transition: none;
105+
}
102106
}
103107
```
104108

packages/react-aria-components/docs/Tabs.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ import {Tabs, TabList, Tab, TabPanel, SelectionIndicator} from 'react-aria-compo
123123
position: absolute;
124124
transition-property: translate, width, height;
125125
transition-duration: 200ms;
126+
127+
@media (prefers-reduced-motion: reduce) {
128+
transition: none;
129+
}
126130
}
127131

128132
&[data-hovered],

packages/react-aria-components/docs/ToggleButtonGroup.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ import {ToggleButtonGroup, ToggleButton, SelectionIndicator} from 'react-aria-co
242242
border-radius: 8px;
243243
background: var(--gray-50);
244244
outline: 2px solid var(--gray-600);
245+
246+
@media (prefers-reduced-motion: reduce) {
247+
transition: none;
248+
}
245249
}
246250

247251
.react-aria-ToggleButton {

starters/docs/src/Disclosure.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@
3838
height: var(--disclosure-panel-height);
3939
transition: height 250ms;
4040
overflow: clip;
41+
42+
@media (prefers-reduced-motion: reduce) {
43+
transition: none;
44+
}
4145
}

starters/docs/src/Tabs.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
position: absolute;
6060
transition-property: translate, width, height;
6161
transition-duration: 200ms;
62+
63+
@media (prefers-reduced-motion: reduce) {
64+
transition: none;
65+
}
6266
}
6367

6468
&[data-selected] {

starters/tailwind/src/Disclosure.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export interface DisclosurePanelProps extends AriaDisclosurePanelProps {
9797

9898
export function DisclosurePanel({ children, ...props }: DisclosurePanelProps) {
9999
return (
100-
<AriaDisclosurePanel {...props} className={composeTailwindRenderProps(props.className, 'h-(--disclosure-panel-height) transition-[height] overflow-clip')}>
100+
<AriaDisclosurePanel {...props} className={composeTailwindRenderProps(props.className, 'h-(--disclosure-panel-height) motion-safe:transition-[height] overflow-clip')}>
101101
<div className="px-4 py-2">{children}</div>
102102
</AriaDisclosurePanel>
103103
);

starters/tailwind/src/Tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function Tab(props: TabProps) {
7777
)}>
7878
{composeRenderProps(props.children, children => (<>
7979
{children}
80-
<SelectionIndicator className="absolute top-0 left-0 w-full h-full z-10 bg-white rounded-full mix-blend-difference transition-[translate,width,height]" />
80+
<SelectionIndicator className="absolute top-0 left-0 w-full h-full z-10 bg-white rounded-full mix-blend-difference motion-safe:transition-[translate,width,height] " />
8181
</>))}
8282
</RACTab>
8383
);

0 commit comments

Comments
 (0)