Skip to content

Commit 013240f

Browse files
committed
feat(Rotate): update RotateCommonPatterns to include exit easing and duration
1 parent 9c9e512 commit 013240f

File tree

2 files changed

+27
-45
lines changed

2 files changed

+27
-45
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { Rotate, type RotateParams } from './Rotate';
1+
export { Rotate } from './Rotate';

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

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,16 @@
11
import * as React from 'react';
2-
import { makeStyles, tokens, Button, Card, Title3, Body2, Caption1 } from '@fluentui/react-components';
2+
import { makeStyles, tokens, Button, Card, Title3, Body2, Caption1, motionTokens } from '@fluentui/react-components';
33
import { Rotate } from '@fluentui/react-motion-components-preview';
44
import { RotateParams } from '../../../library/src/components/Rotate/rotate-types';
55

6-
type RotatePattern = {
7-
/** Unique identifier for the pattern */
8-
id: string;
9-
/** Display name of the pattern */
10-
name: string;
11-
/** Description of what the pattern does */
12-
description: string;
13-
/** Emoji icon for visual representation */
14-
icon: string;
15-
/** Background color for the demo card */
16-
color: string;
17-
/** The axis of rotation: 'x', 'y', or 'z' - matches Rotate component */
18-
axis: Required<RotateParams['axis']>;
19-
/** The starting rotation angle in degrees - matches Rotate component */
20-
angle: Required<RotateParams['angle']>;
21-
/** Time (ms) for the animation - matches Rotate component */
22-
duration: Required<RotateParams['duration']>;
23-
/** Easing curve for the animation - matches Rotate component */
24-
easing: Required<RotateParams['easing']>;
25-
};
26-
276
const useClasses = makeStyles({
287
container: {
298
display: 'flex',
309
flexDirection: 'column',
3110
gap: '20px',
3211
padding: '20px',
3312
maxWidth: '1000px',
13+
perspective: '500px',
3414
},
3515
controls: {
3616
display: 'flex',
@@ -81,17 +61,33 @@ const useClasses = makeStyles({
8161

8262
const curveSpringRelaxed = `linear(0.000 0.000%, 0.06073 1.000%, 0.1215 2.000%, 0.1822 3.000%, 0.2429 4.000%, 0.3036 5.000%, 0.3644 6.000%, 0.4251 7.000%, 0.4858 8.000%, 0.5465 9.000%, 0.6073 10.00%, 0.6680 11.00%, 0.7287 12.00%, 0.7895 13.00%, 0.8502 14.00%, 0.9109 15.00%, 0.9716 16.00%, 1.031 17.00%, 1.085 18.00%, 1.131 19.00%, 1.168 20.00%, 1.198 21.00%, 1.220 22.00%, 1.234 23.00%, 1.241 24.00%, 1.242 25.00%, 1.236 26.00%, 1.226 27.00%, 1.211 28.00%, 1.192 29.00%, 1.171 30.00%, 1.148 31.00%, 1.124 32.00%, 1.099 33.00%, 1.074 34.00%, 1.050 35.00%, 1.028 36.00%, 1.007 37.00%, 0.9880 38.00%, 0.9714 39.00%, 0.9572 40.00%, 0.9455 41.00%, 0.9364 42.00%, 0.9298 43.00%, 0.9255 44.00%, 0.9235 45.00%, 0.9236 46.00%, 0.9255 47.00%, 0.9291 48.00%, 0.9339 49.00%, 0.9399 50.00%, 0.9467 51.00%, 0.9541 52.00%, 0.9618 53.00%, 0.9697 54.00%, 0.9774 55.00%, 0.9849 56.00%, 0.9920 57.00%, 0.9986 58.00%, 1.004 59.00%, 1.010 60.00%, 1.014 61.00%, 1.018 62.00%, 1.020 63.00%, 1.022 64.00%, 1.024 65.00%, 1.024 66.00%, 1.024 67.00%, 1.023 68.00%, 1.022 69.00%, 1.021 70.00%, 1.019 71.00%, 1.017 72.00%, 1.014 73.00%, 1.012 74.00%, 1.009 75.00%, 1.007 76.00%, 1.004 77.00%, 1.002 78.00%, 1.000 79.00%, 0.9984 80.00%, 0.9968 81.00%, 0.9954 82.00%, 0.9943 83.00%, 0.9935 84.00%, 0.9929 85.00%, 0.9925 86.00%, 0.9923 87.00%, 0.9924 88.00%, 0.9926 89.00%, 0.9930 90.00%, 0.9935 91.00%, 0.9941 92.00%, 0.9948 93.00%, 0.9956 94.00%, 0.9964 95.00%, 0.9972 96.00%, 0.9979 97.00%, 0.9987 98.00%, 0.9994 99.00%, 1.000 100.0%)`;
8363

64+
type RotatePattern = {
65+
id: string;
66+
name: string;
67+
description: string;
68+
icon: string;
69+
color: string;
70+
axis: Required<RotateParams['axis']>;
71+
angle: Required<RotateParams['angle']>;
72+
duration: Required<RotateParams['duration']>;
73+
easing: Required<RotateParams['easing']>;
74+
exitEasing: Required<RotateParams['easing']>;
75+
exitDuration: Required<RotateParams['duration']>;
76+
};
77+
8478
const patterns: RotatePattern[] = [
8579
{
8680
id: 'flip-horizontal',
8781
name: 'Horizontal Flip',
88-
description: 'Classic Y-axis rotation',
82+
description: 'Y-axis rotation',
8983
icon: '↔️',
9084
color: tokens.colorPaletteBlueForeground2,
9185
axis: 'y',
9286
angle: 90,
9387
easing: curveSpringRelaxed,
88+
exitEasing: motionTokens.curveDecelerateMid,
9489
duration: 2000,
90+
exitDuration: motionTokens.durationUltraSlow,
9591
},
9692
{
9793
id: 'flip-vertical',
@@ -102,7 +98,9 @@ const patterns: RotatePattern[] = [
10298
axis: 'x',
10399
angle: 90,
104100
easing: curveSpringRelaxed,
101+
exitEasing: motionTokens.curveDecelerateMid,
105102
duration: 2000,
103+
exitDuration: motionTokens.durationUltraSlow,
106104
},
107105
{
108106
id: 'spin',
@@ -113,13 +111,15 @@ const patterns: RotatePattern[] = [
113111
axis: 'z',
114112
angle: 90,
115113
easing: curveSpringRelaxed,
114+
exitEasing: motionTokens.curveDecelerateMid,
116115
duration: 2000,
116+
exitDuration: motionTokens.durationUltraSlow,
117117
},
118118
];
119119

120120
export const CommonPatterns = () => {
121121
const classes = useClasses();
122-
const [activePatterns, setActivePatterns] = React.useState<Set<string>>(new Set());
122+
const [activePatterns, setActivePatterns] = React.useState<Set<string>>(new Set(patterns.map(p => p.id)));
123123

124124
const togglePattern = (patternId: string) => {
125125
setActivePatterns(prev => {
@@ -133,23 +133,6 @@ export const CommonPatterns = () => {
133133
});
134134
};
135135

136-
const demonstrateAll = () => {
137-
setActivePatterns(new Set());
138-
139-
patterns.forEach((pattern, index) => {
140-
setTimeout(() => {
141-
setActivePatterns(prev => new Set([...prev, pattern.id]));
142-
setTimeout(() => {
143-
setActivePatterns(prev => {
144-
const newSet = new Set(prev);
145-
newSet.delete(pattern.id);
146-
return newSet;
147-
});
148-
}, pattern.duration + 200);
149-
}, index * 300);
150-
});
151-
};
152-
153136
const toggleAllPatterns = () => {
154137
if (activePatterns.size === patterns.length) {
155138
// All are showing, so hide all
@@ -165,9 +148,6 @@ export const CommonPatterns = () => {
165148
return (
166149
<div className={classes.container}>
167150
<div className={classes.controls}>
168-
<Button appearance="primary" onClick={demonstrateAll}>
169-
Demonstrate All Patterns
170-
</Button>
171151
<Button onClick={toggleAllPatterns}>{allPatternsVisible ? 'Hide All' : 'Show All'}</Button>
172152
</div>
173153

@@ -180,6 +160,8 @@ export const CommonPatterns = () => {
180160
angle={pattern.angle}
181161
duration={pattern.duration}
182162
easing={pattern.easing}
163+
exitEasing={pattern.exitEasing}
164+
exitDuration={pattern.exitDuration}
183165
>
184166
<Card className={classes.patternCard} onClick={() => togglePattern(pattern.id)}>
185167
<div className={classes.demoIcon} style={{ backgroundColor: pattern.color }}>

0 commit comments

Comments
 (0)