-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
MotionPage.tsx
382 lines (366 loc) · 13.7 KB
/
MotionPage.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
import * as React from 'react';
import {
AnimationDetail,
AnimationDetailGrid,
AnimationExample,
IPageSectionProps,
Markdown,
MarkdownHeader,
Table,
Video
} from '@uifabric/example-app-base/lib/index2';
import { IStylesPageProps, StylesAreaPage } from '../StylesAreaPage';
import { MotionPageProps } from './MotionPage.doc';
import { Platforms } from '../../../interfaces/Platforms';
const baseUrl = 'https://github.com/OfficeDev/office-ui-fabric-react/tree/master/apps/fabric-website/src/pages/Styles/MotionPage/docs';
const PatternTable = ({ rows }) => (
<Table
columns={[
{
title: 'Element',
data: 'element'
},
{
title: 'Animation',
data: 'animation'
},
{
title: 'Duration',
data: 'duration'
},
{
title: 'Timing function',
data: 'timing'
},
{
title: 'Delay',
data: 'delay'
}
]}
rows={rows}
// tslint:disable-next-line jsx-no-lambda
formatter={(column, row) => row[column.data]}
/>
);
export const MotionPage: React.StatelessComponent<IStylesPageProps> = props => {
const { platform } = props;
return <StylesAreaPage {...props} {...MotionPageProps[platform]} otherSections={_otherSections(platform) as IPageSectionProps[]} />;
};
function _otherSections(platform: Platforms): IPageSectionProps<Platforms>[] {
switch (platform) {
case 'web':
return [
{
sectionName: 'Animation Patterns',
editUrl: `${baseUrl}/web/MotionAnimationPatterns.md`,
content: (
<>
<Markdown>
{require('!raw-loader!@uifabric/fabric-website/src/pages/Styles/MotionPage/docs/web/MotionAnimationPatterns.md') as string}
</Markdown>
<MarkdownHeader as="h3">Delete & Slide</MarkdownHeader>
<p>This pattern for deleting an object from the view and how the remaining objects realign themselves.</p>
<Video source="https://static2.sharepointonline.com/files/fabric/fabric-website/video/deleteslide.mp4" />
<PatternTable
rows={[
{
element: 'Repositioned content',
animation: 'Slide',
duration: '300 ms',
timing: 'Decelerate',
delay: '0 ms'
},
{
element: 'Exiting content',
animation: 'Fade out',
duration: '300 ms',
timing: 'Decelerate',
delay: '50 ms'
}
]}
/>
<MarkdownHeader as="h3">Slide & Add</MarkdownHeader>
<p>This pattern for adding an object to a view, and how the other objects react to the new element.</p>
<Video source="https://static2.sharepointonline.com/files/fabric/fabric-website/video/slideadd.mp4" />
<PatternTable
rows={[
{
element: 'Repositioned content',
animation: 'Slide',
duration: '300 ms',
timing: 'Decelerate',
delay: '0 ms'
},
{
element: 'Entering content',
animation: 'Fade in',
duration: '300 ms',
timing: 'Decelerate',
delay: '50 ms'
}
]}
/>
<MarkdownHeader as="h3">Drill In</MarkdownHeader>
<p>
This pattern handles the transition from one view into another. Some elements persist, some leave the view, and new ones
enter as well.
</p>
<Video source="https://static2.sharepointonline.com/files/fabric/fabric-website/video/drillin.mp4" />
<PatternTable
rows={[
{
element: 'Exiting content',
animation: 'Fade out',
duration: '100 ms',
timing: 'Linear',
delay: '0 ms'
},
{
element: 'Entering content',
animation: 'Scale down in',
duration: '300 ms',
timing: 'Decelerate',
delay: '100 ms'
}
]}
/>
<MarkdownHeader as="h3">Drill In with Continuity</MarkdownHeader>
<p>
This pattern handles the transition from one view into another. Some elements persist, some leave the view, and new ones
enter as well.
</p>
<Video source="https://static2.sharepointonline.com/files/fabric/fabric-website/video/drillinwithcontinuity.mp4" />
<PatternTable
rows={[
{
element: 'Exiting content',
animation: 'Fade out',
duration: '100 ms',
timing: 'Linear',
delay: '0 ms'
},
{
element: 'Repositioned content',
animation: 'Slide',
duration: '300 ms',
timing: 'Decelerate',
delay: '0 ms'
},
{
element: 'Entering content',
animation: 'Scale down in',
duration: '300 ms',
timing: 'Decelerate',
delay: '100 ms'
}
]}
/>
<MarkdownHeader as="h3">Tabs & Pivots</MarkdownHeader>
<p>
This pattern describes the transition from selecting one tab to another. Includes the selection state that travels across
the tab set. Also describes the tab content coming in and out as well.
</p>
<Video source="https://static2.sharepointonline.com/files/fabric/fabric-website/video/tabspivots.mp4" />
<PatternTable
rows={[
{
element: 'Underline (active indicator)',
animation: 'Slide',
duration: '300 ms',
timing: 'Decelerate',
delay: '0 ms'
},
{
element: 'Exiting ribbon content',
animation: 'Slide out',
duration: '300 ms',
timing: 'Decelerate',
delay: '0 ms'
},
{
element: 'Entering ribbon content',
animation: 'Slide in',
duration: '300 ms',
timing: 'Decelerate',
delay: '100 ms'
}
]}
/>
</>
)
},
{
sectionName: 'Basic Animations',
editUrl: `${baseUrl}/web/MotionBasicAnimations.md`,
content: (
<>
<Markdown>
{require('!raw-loader!@uifabric/fabric-website/src/pages/Styles/MotionPage/docs/web/MotionBasicAnimations.md') as string}
</Markdown>
<MarkdownHeader as="h3">Fade</MarkdownHeader>
<p>The most basic and fundamental animation for adding and removing objects. Use fades as the default choice.</p>
<AnimationDetailGrid>
<AnimationDetail animation="Fade in" coreClass="ms-motion-fadeIn" reactVariable="MotionAnimations.fadeIn" />
<AnimationDetail animation="Fade out" coreClass="ms-motion-fadeOut" reactVariable="MotionAnimations.fadeOut" />
</AnimationDetailGrid>
<MarkdownHeader as="h3">Scale</MarkdownHeader>
<p>
A more dramatic animation than fading, scaling draws the eye and implies a sense of depth. Use these animations sparingly
where more emphasis is needed.
</p>
<AnimationDetailGrid>
<AnimationDetail animation="Scale down in" coreClass="ms-motion-scaleDownIn" reactVariable="MotionAnimations.scaleDownIn" />
<AnimationDetail
animation="Scale down out"
coreClass="ms-motion-scaleDownOut"
reactVariable="MotionAnimations.scaleDownOut"
/>
</AnimationDetailGrid>
<MarkdownHeader as="h3">Slide</MarkdownHeader>
<p>
Use sliding animations for when there is an obvious directionality to the entrance and exit of an object. These animations
help users build a mental model of where the object can be found when it isn’t visible.
</p>
<AnimationDetailGrid>
<AnimationDetail animation="Slide up in" coreClass="ms-motion-slideUpIn" reactVariable="MotionAnimations.slideUpIn" />
<AnimationDetail animation="Slide up out" coreClass="ms-motion-slideUpOut" reactVariable="MotionAnimations.slideUpOut" />
<AnimationDetail
animation="Slide right in"
coreClass="ms-motion-slideRightIn"
reactVariable="MotionAnimations.slideRightIn"
/>
<AnimationDetail
animation="Slide right out"
coreClass="ms-motion-slideRightOut"
reactVariable="MotionAnimations.slideRightOut"
/>
<AnimationDetail animation="Slide down in" coreClass="ms-motion-slideDownIn" reactVariable="MotionAnimations.slideDownIn" />
<AnimationDetail
animation="Slide down out"
coreClass="ms-motion-slideDownOut"
reactVariable="MotionAnimations.slideDownOut"
/>
<AnimationDetail animation="Slide left in" coreClass="ms-motion-slideLeftIn" reactVariable="MotionAnimations.slideLeftIn" />
<AnimationDetail
animation="Slide left out"
coreClass="ms-motion-slideLeftOut"
reactVariable="MotionAnimations.slideLeftOut"
/>
</AnimationDetailGrid>
</>
)
},
{
sectionName: 'Durations',
content: (
<Table
columns={[
{
title: 'Duration',
data: 'duration',
percentWidth: 50
},
{
title: 'Core variable',
data: 'core'
},
{
title: 'React variable',
data: 'react'
}
]}
rows={[
{
duration: '100ms',
core: '$ms-motion-duration-1',
react: 'MotionDurations.duration1'
},
{
duration: '200ms',
core: '$ms-motion-duration-2',
react: 'MotionDurations.duration2'
},
{
duration: '300ms',
core: '$ms-motion-duration-3',
react: 'MotionDurations.duration3'
},
{
duration: '400ms',
core: '$ms-motion-duration-4',
react: 'MotionDurations.duration4'
}
]}
// tslint:disable-next-line jsx-no-lambda
formatter={(column, row) => row[column.data]}
/>
)
},
{
sectionName: 'Timing Functions',
content: (
<Table
columns={[
{
title: 'Name',
data: 'name'
},
{
title: 'Value',
data: 'value'
},
{
title: 'Core variable',
data: 'core'
},
{
title: 'React variable',
data: 'react'
}
]}
rows={[
{
name: 'Linear',
value: 'cubic-bezier(0, 0, 1, 1)',
core: '$ms-motion-timing-linear',
react: 'MotionTimings.linear'
},
{
name: 'Standard',
value: 'cubic-bezier(0.8, 0, 0.2, 1)',
core: '$ms-motion-timing-standard',
react: 'MotionTimings.standard'
},
{
name: 'Accelerate',
value: 'cubic-bezier(0.9, 0.1, 1, 0.2)',
core: '$ms-motion-timing-accelerate',
react: 'MotionTimings.accelerate'
},
{
name: 'Decelerate',
value: 'cubic-bezier(0.1, 0.9, 0.2, 1)',
core: '$ms-motion-timing-decelerate',
react: 'MotionTimings.decelerate'
}
]}
// tslint:disable-next-line jsx-no-lambda
formatter={(column, row) => {
if (column.title === 'Example') {
return <AnimationExample animation={row.class} />;
}
return row[column.data];
}}
/>
)
}
];
default:
return [
{
sectionName: 'Coming Soon',
content: 'Coming Soon'
}
];
}
}