Skip to content

Commit 721cc97

Browse files
committed
feat(Rotate): enhance design token usage and improve accessibility in stories
1 parent ba2593c commit 721cc97

File tree

2 files changed

+44
-18
lines changed

2 files changed

+44
-18
lines changed

packages/react-components/react-motion-components-preview/stories/src/Rotate/RotateCardFlip.stories.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ const useClasses = makeStyles({
77
container: {
88
display: 'flex',
99
flexDirection: 'column',
10-
gap: '20px',
11-
padding: '20px',
10+
gap: tokens.spacingVerticalXL, // 20px
11+
padding: tokens.spacingVerticalXL, // 20px
1212
maxWidth: '1000px',
1313
},
1414
controls: {
1515
display: 'flex',
16-
gap: '10px',
16+
gap: tokens.spacingHorizontalMNudge, // 10px
1717
alignItems: 'center',
1818
flexWrap: 'wrap',
19-
marginBottom: '20px',
19+
marginBottom: tokens.spacingVerticalXL, // 20px
2020
},
2121
patternsGrid: {
2222
display: 'grid',
2323
gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))',
24-
gap: '20px',
24+
gap: tokens.spacingVerticalXL, // 20px
2525
},
2626
cardWrapper: {
2727
perspective: '500px',
@@ -92,7 +92,7 @@ const patterns: RotatePattern[] = [
9292
angle: 180,
9393
easing: curveSpringRelaxed,
9494
exitEasing: motionTokens.curveDecelerateMid,
95-
duration: 2000,
95+
duration: motionTokens.durationUltraSlow * 4, // 2000ms = 500ms * 4
9696
exitDuration: motionTokens.durationUltraSlow,
9797
},
9898
{
@@ -105,7 +105,7 @@ const patterns: RotatePattern[] = [
105105
angle: 180,
106106
easing: curveSpringRelaxed,
107107
exitEasing: motionTokens.curveDecelerateMid,
108-
duration: 2000,
108+
duration: motionTokens.durationUltraSlow * 4, // 2000ms = 500ms * 4
109109
exitDuration: motionTokens.durationUltraSlow,
110110
},
111111
{
@@ -118,7 +118,7 @@ const patterns: RotatePattern[] = [
118118
angle: 180,
119119
easing: curveSpringRelaxed,
120120
exitEasing: motionTokens.curveDecelerateMid,
121-
duration: 2000,
121+
duration: motionTokens.durationUltraSlow * 4, // 2000ms = 500ms * 4
122122
exitDuration: motionTokens.durationUltraSlow,
123123
},
124124
];
@@ -152,7 +152,9 @@ export const CardFlip = () => {
152152
return (
153153
<div className={classes.container}>
154154
<div className={classes.controls}>
155-
<Button onClick={toggleAllPatterns}>Flip All</Button>
155+
<Button onClick={toggleAllPatterns} aria-label="Toggle all rotation patterns">
156+
Flip All
157+
</Button>
156158
</div>
157159

158160
<div className={classes.patternsGrid}>
@@ -168,7 +170,20 @@ export const CardFlip = () => {
168170
exitDuration={pattern.exitDuration}
169171
animateOpacity={false}
170172
>
171-
<Card className={classes.patternCard} onClick={() => togglePattern(pattern.id)} appearance="outline">
173+
<Card
174+
className={classes.patternCard}
175+
onClick={() => togglePattern(pattern.id)}
176+
appearance="outline"
177+
role="button"
178+
tabIndex={0}
179+
aria-label={`Toggle ${pattern.name} rotation`}
180+
onKeyDown={e => {
181+
if (e.key === 'Enter' || e.key === ' ') {
182+
e.preventDefault();
183+
togglePattern(pattern.id);
184+
}
185+
}}
186+
>
172187
<div className={classes.demoIcon} style={{ backgroundColor: pattern.color }}>
173188
{pattern.icon}
174189
</div>

packages/react-components/react-motion-components-preview/stories/src/Rotate/RotateDefault.stories.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import * as React from 'react';
2-
import { Field, makeStyles, tokens, Switch, useId, Label, Slider, RadioGroup, Radio } from '@fluentui/react-components';
2+
import {
3+
Field,
4+
makeStyles,
5+
tokens,
6+
Switch,
7+
useId,
8+
Label,
9+
Slider,
10+
RadioGroup,
11+
Radio,
12+
motionTokens,
13+
} from '@fluentui/react-components';
314
import { Rotate } from '@fluentui/react-motion-components-preview';
415
import { Axis3D } from '../../../library/src/atoms/rotate-atom';
516

@@ -9,13 +20,13 @@ const useClasses = makeStyles({
920
container: {
1021
display: 'grid',
1122
gridTemplate: `"controls ." "card card" / 1fr 1fr`,
12-
gap: '20px 10px',
23+
gap: `${tokens.spacingVerticalXL} ${tokens.spacingHorizontalMNudge}`, // 20px 10px
1324
// perspective: '1000px',
1425
overflow: 'clip',
1526
},
1627
card: {
1728
gridArea: 'card',
18-
padding: '10px',
29+
padding: tokens.spacingHorizontalMNudge, // 10px
1930
},
2031
controls: {
2132
display: 'flex',
@@ -25,7 +36,7 @@ const useClasses = makeStyles({
2536
border: `${tokens.strokeWidthThicker} solid ${tokens.colorNeutralForeground3}`,
2637
borderRadius: tokens.borderRadiusMedium,
2738
boxShadow: tokens.shadow16,
28-
padding: '10px',
39+
padding: tokens.spacingHorizontalMNudge, // 10px
2940
},
3041
field: {
3142
flex: 1,
@@ -49,7 +60,7 @@ export const Default = (props: React.ComponentProps<typeof Rotate>) => {
4960
const [visible, setVisible] = React.useState<boolean>(false);
5061
const [autoplay, setAutoplay] = React.useState<boolean>(false);
5162
const [perspective, setPerspective] = React.useState<string>('1000px');
52-
const [duration, setDuration] = React.useState<number>(500);
63+
const [duration, setDuration] = React.useState<number>(motionTokens.durationUltraSlow); // 500ms
5364
const [axis, setAxis] = React.useState<Axis3D>('y');
5465
const [angle, setEnterAngle] = React.useState<number>(-90);
5566

@@ -59,8 +70,8 @@ export const Default = (props: React.ComponentProps<typeof Rotate>) => {
5970

6071
const perspectiveMin = 200;
6172
const perspectiveMax = 2000;
62-
const durationMin = 50;
63-
const durationMax = 1000;
73+
const durationMin = motionTokens.durationUltraFast; // 50ms
74+
const durationMax = motionTokens.durationUltraSlow * 2; // 1000ms
6475
const angleMin = -180;
6576
const angleMax = 180;
6677

@@ -114,7 +125,7 @@ export const Default = (props: React.ComponentProps<typeof Rotate>) => {
114125
<Slider
115126
min={durationMin}
116127
max={durationMax}
117-
defaultValue={duration}
128+
defaultValue={motionTokens.durationUltraSlow} // 500ms
118129
id={durationSliderId}
119130
onChange={(_, data) => {
120131
setDuration(data.value);

0 commit comments

Comments
 (0)