-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Fade): migrate to new variant structure (#33080)
Co-authored-by: Alexander Katrukhin <[email protected]>
- Loading branch information
1 parent
5001626
commit 39269ba
Showing
7 changed files
with
72 additions
and
30 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-motion-components-preview-4d993355-e9f1-49f7-93c4-a90c4af9c96d.json
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 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "refactor: migrate Fade motion component to new variant structure", | ||
"packageName": "@fluentui/react-motion-components-preview", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
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
44 changes: 29 additions & 15 deletions
44
...ages/react-components/react-motion-components-preview/library/src/components/Fade/Fade.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 |
---|---|---|
@@ -1,22 +1,36 @@ | ||
import { | ||
motionTokens, | ||
PresenceMotion, | ||
createPresenceComponent, | ||
createPresenceComponentVariant, | ||
} from '@fluentui/react-motion'; | ||
import { motionTokens, createPresenceComponent } from '@fluentui/react-motion'; | ||
import type { PresenceMotionCreator } from '../../types'; | ||
|
||
const duration = motionTokens.durationNormal; | ||
const easing = motionTokens.curveEasyEase; | ||
type FadeVariantParams = { | ||
/** Time (ms) for the enter transition (fade-in). Defaults to the `durationNormal` value (200 ms). */ | ||
enterDuration?: number; | ||
|
||
/** Define a presence motion for fade in/out */ | ||
const fadeMotion: PresenceMotion = { | ||
enter: { duration, easing, keyframes: [{ opacity: 0 }, { opacity: 1 }] }, | ||
exit: { duration, easing, keyframes: [{ opacity: 1 }, { opacity: 0 }] }, | ||
/** Easing curve for the enter transition (fade-in). Defaults to the `easeEase` value. */ | ||
enterEasing?: string; | ||
|
||
/** Time (ms) for the exit transition (fade-out). Defaults to the `enterDuration` param for symmetry. */ | ||
exitDuration?: number; | ||
|
||
/** Easing curve for the exit transition (fade-out). Defaults to the `enterEasing` param for symmetry. */ | ||
exitEasing?: string; | ||
}; | ||
|
||
/** Define a presence motion for fade in/out */ | ||
export const createFadePresence: PresenceMotionCreator<FadeVariantParams> = ({ | ||
enterDuration = motionTokens.durationNormal, | ||
enterEasing = motionTokens.curveEasyEase, | ||
exitDuration = enterDuration, | ||
exitEasing = enterEasing, | ||
} = {}) => ({ | ||
enter: { duration: enterDuration, easing: enterEasing, keyframes: [{ opacity: 0 }, { opacity: 1 }] }, | ||
exit: { duration: exitDuration, easing: exitEasing, keyframes: [{ opacity: 1 }, { opacity: 0 }] }, | ||
}); | ||
|
||
/** A React component that applies fade in/out transitions to its children. */ | ||
export const Fade = createPresenceComponent(fadeMotion); | ||
export const Fade = createPresenceComponent(createFadePresence()); | ||
|
||
export const FadeSnappy = createPresenceComponentVariant(Fade, { all: { duration: motionTokens.durationFast } }); | ||
export const FadeSnappy = createPresenceComponent(createFadePresence({ enterDuration: motionTokens.durationFast })); | ||
|
||
export const FadeExaggerated = createPresenceComponentVariant(Fade, { all: { duration: motionTokens.durationGentle } }); | ||
export const FadeExaggerated = createPresenceComponent( | ||
createFadePresence({ enterDuration: motionTokens.durationGentle }), | ||
); |
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
14 changes: 13 additions & 1 deletion
14
packages/react-components/react-motion-components-preview/library/src/types.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
16 changes: 9 additions & 7 deletions
16
...s/react-motion-components-preview/stories/src/Fade/FadeCustomization.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
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