-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(react-motions): restructure docs (#30573)
- Loading branch information
1 parent
10be419
commit 2d8daef
Showing
29 changed files
with
195 additions
and
252 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...-motions-preview/stories/CreateMotionComponent/CreateMotionComponent.stories.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
You can create completely custom motion that are defined by `AtomMotion` interface. `AtomMotion` contains definitions for `keyframes` and its options that are used internally to create [`KeyframeEffect`](https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect) for an animation. | ||
|
||
```tsx | ||
import type { AtomMotion, createMotionComponent } from '@fluentui/react-motions-preview'; | ||
|
||
const customAtom: AtomMotion = { | ||
// opacity will be animated from 0 to 1 | ||
keyframes: [{ opacity: 0 }, { opacity: 1 }], | ||
// duration of the animation will be "1000ms" | ||
duration: 1000, | ||
}; | ||
const CustomMotion = createMotionComponent(customAtom); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...tions-preview/stories/CreateMotionComponent/CreateMotionComponentDescription.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
`createMotionComponent()` is a factory function that creates a custom motion component powered by Web Animations API. | ||
|
||
<!-- Don't allow prettier to collapse code block into single line --> | ||
<!-- prettier-ignore --> | ||
> **⚠️ Preview packages are considered unstable:** | ||
> - Features and APIs may change before final release | ||
> - Please contact us if you intend to use this in your product |
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...ents/react-motions-preview/stories/CreateMotionComponent/TokensUsage.stories.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fluent UI provides a set of design tokens, via `tokens` object, for example `tokens.colorNeutralForeground1`. You can use them to create your own motions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...ges/react-components/react-motions-preview/stories/CreateMotionComponent/index.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import CreateMotionComponentDescription from './CreateMotionComponentDescription.md'; | ||
|
||
export { CreateMotionComponentDefault as Default } from './CreateMotionComponentDefault.stories'; | ||
|
||
export { CreateMotionComponent as createMotionComponent } from './CreateMotionComponent.stories'; | ||
|
||
export { ImperativeRefPlayState as imperativeRef } from './ImperativeRefPlayState.stories'; | ||
export { TokensUsage as tokens } from './TokensUsage.stories'; | ||
|
||
export default { | ||
title: 'Utilities/Web Motions (Preview)/createMotionComponent', | ||
component: null, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: CreateMotionComponentDescription, | ||
}, | ||
}, | ||
}, | ||
}; |
27 changes: 27 additions & 0 deletions
27
...ions-preview/stories/CreatePresenceComponent/CreatePresenceComponent.stories.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
You can create completely custom motions with `createPresenceComponent()` factory. `PresenceMotion` contains definitions for `enter` and `exit` atoms defined by `AtomMotion` interface: | ||
|
||
```tsx | ||
import { createPresenceComponent } from '@fluentui/react-motions-preview'; | ||
import type { AtomMotion, PresenceMotion } from '@fluentui/react-motions-preview'; | ||
|
||
const enterAtom: AtomMotion = { | ||
// opacity will be animated from 0 to 1 | ||
keyframes: { opacity: [0, 1] }, | ||
// duration of the animation will be "1000ms" | ||
duration: 1000, | ||
}; | ||
|
||
const exitAtom: AtomMotion = { | ||
// opacity will be animated from 1 to 0 | ||
keyframes: { opacity: [1, 0] }, | ||
// duration of the animation will be "500ms" | ||
duration: 500, | ||
}; | ||
|
||
const presense: PresenceMotion = { | ||
enter: enterAtom, | ||
exit: exitAtom, | ||
}; | ||
|
||
const Fade = createPresenceComponent(presense); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...otions-preview/stories/CreatePresenceComponent/CreatePresenceComponentDefault.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { makeStyles, shorthands, tokens, Checkbox } from '@fluentui/react-components'; | ||
import { createPresenceComponent, motionTokens } from '@fluentui/react-motions-preview'; | ||
import * as React from 'react'; | ||
|
||
const useClasses = makeStyles({ | ||
container: { | ||
display: 'grid', | ||
gridTemplateColumns: '1fr', | ||
...shorthands.gap('10px'), | ||
}, | ||
card: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
|
||
...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3), | ||
...shorthands.borderRadius(tokens.borderRadiusMedium), | ||
...shorthands.padding('10px'), | ||
|
||
alignItems: 'center', | ||
}, | ||
item: { | ||
backgroundColor: tokens.colorBrandBackground, | ||
...shorthands.borderRadius('50%'), | ||
|
||
width: '100px', | ||
height: '100px', | ||
}, | ||
description: { | ||
...shorthands.margin('5px'), | ||
}, | ||
controls: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
|
||
marginTop: '20px', | ||
|
||
...shorthands.border('3px', 'solid', tokens.colorNeutralForeground3), | ||
...shorthands.borderRadius(tokens.borderRadiusMedium), | ||
...shorthands.padding('10px'), | ||
}, | ||
}); | ||
|
||
const Fade = createPresenceComponent({ | ||
enter: { | ||
keyframes: [{ opacity: 0 }, { opacity: 1 }], | ||
duration: motionTokens.durationSlow, | ||
}, | ||
exit: { | ||
keyframes: [{ opacity: 1 }, { opacity: 0 }], | ||
duration: motionTokens.durationSlow, | ||
}, | ||
}); | ||
|
||
export const CreatePresenceComponentDefault = () => { | ||
const classes = useClasses(); | ||
const [visible, setVisible] = React.useState<boolean>(false); | ||
|
||
return ( | ||
<> | ||
<div className={classes.container}> | ||
<div className={classes.card}> | ||
<Fade visible={visible}> | ||
<div className={classes.item} /> | ||
</Fade> | ||
|
||
<code className={classes.description}>fadeSlow</code> | ||
</div> | ||
</div> | ||
|
||
<div className={classes.controls}> | ||
<div> | ||
<Checkbox label={<code>visible</code>} checked={visible} onChange={() => setVisible(v => !v)} /> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
...s-preview/stories/CreatePresenceComponent/CreatePresenceComponentDescription.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
`createPresenceComponent()` is a factory function that creates a React component based on the provided presence definition. This component can be used to animate any element and intended to have a state via the `visible` prop. | ||
|
||
<!-- Don't allow prettier to collapse code block into single line --> | ||
<!-- prettier-ignore --> | ||
> **⚠️ Preview packages are considered unstable:** | ||
> - Features and APIs may change before final release | ||
> - Please contact us if you intend to use this in your product |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
...s/react-components/react-motions-preview/stories/CreatePresenceComponent/index.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import CreatePresenceComponentDescription from './CreatePresenceComponentDescription.md'; | ||
|
||
export { CreatePresenceComponentDefault as Default } from './CreatePresenceComponentDefault.stories'; | ||
|
||
export { CreatePresenceComponent as createPresenceComponent } from './CreatePresenceComponent.stories'; | ||
|
||
export { PresenceAppear as appear } from './PresenceAppear.stories'; | ||
export { PresenceUnmountOnExit as unmountOnExit } from './PresenceUnmountOnExit.stories'; | ||
export { PresenceOnMotionFinish as onMotionFinish } from './PresenceOnMotionFinish.stories'; | ||
|
||
export { MotionFunctions as functions } from './MotionFunctions.stories'; | ||
|
||
export default { | ||
title: 'Utilities/Web Motions (Preview)/createPresenceComponent', | ||
component: null, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: CreatePresenceComponentDescription, | ||
}, | ||
}, | ||
}, | ||
}; |
1 change: 0 additions & 1 deletion
1
...omponents/react-motions-preview/stories/Motion/CreateMotionComponent.stories.md
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.