-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(dashboards): Use Motion design tokens for animation #102415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3cac39b
30a407f
7a7169d
0d8f123
524c51a
228fcde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -252,20 +252,42 @@ const generateTokens = (colors: Colors) => ({ | |
| }, | ||
| }); | ||
|
|
||
| const generateMotion = () => { | ||
| type Curve = 'smooth' | 'snap' | 'enter' | 'exit'; | ||
| type ControlPoints = [number, number, number, number]; | ||
|
|
||
| const BEZIER_CONTROL_POINTS: Record<Curve, ControlPoints> = { | ||
| smooth: [0.72, 0, 0.16, 1], | ||
| snap: [0.8, -0.4, 0.5, 1], | ||
| enter: [0.24, 1, 0.32, 1], | ||
| exit: [0.64, 0, 0.8, 0], | ||
| }; | ||
|
|
||
| function formatBezierCurve(points: ControlPoints): string { | ||
| return `cubic-bezier(${points.join(', ')})`; | ||
| } | ||
|
|
||
| type AnimationDuration = 'fast' | 'moderate' | 'slow'; | ||
|
|
||
| const MOTION_DURATIONS: Record<AnimationDuration, number> = { | ||
| fast: 0.12, | ||
| moderate: 0.16, | ||
| slow: 0.24, | ||
| }; | ||
|
|
||
| const withDuration = (easing: string) => { | ||
| return { | ||
| smooth: withDuration('cubic-bezier(0.72, 0, 0.16, 1)'), | ||
| snap: withDuration('cubic-bezier(0.8, -0.4, 0.5, 1)'), | ||
| enter: withDuration('cubic-bezier(0.24, 1, 0.32, 1)'), | ||
| exit: withDuration('cubic-bezier(0.64, 0, 0.8, 0)'), | ||
| fast: `${MOTION_DURATIONS.fast}s ${easing}`, | ||
| moderate: `${MOTION_DURATIONS.moderate}s ${easing}`, | ||
| slow: `${MOTION_DURATIONS.slow}s ${easing}`, | ||
| }; | ||
| }; | ||
|
|
||
| const withDuration = (easing: string) => { | ||
| const generateMotion = () => { | ||
| return { | ||
| fast: `120ms ${easing}`, | ||
| moderate: `160ms ${easing}`, | ||
| slow: `240ms ${easing}`, | ||
| smooth: withDuration(formatBezierCurve(BEZIER_CONTROL_POINTS.smooth)), | ||
| snap: withDuration(formatBezierCurve(BEZIER_CONTROL_POINTS.snap)), | ||
| enter: withDuration(formatBezierCurve(BEZIER_CONTROL_POINTS.enter)), | ||
| exit: withDuration(formatBezierCurve(BEZIER_CONTROL_POINTS.exit)), | ||
| }; | ||
| }; | ||
|
|
||
|
|
@@ -1152,6 +1174,8 @@ const commonTheme = { | |
|
|
||
| space, | ||
| motion: generateMotion(), | ||
| motionControlPoints: BEZIER_CONTROL_POINTS, | ||
| motionDurations: MOTION_DURATIONS, | ||
|
Comment on lines
1176
to
+1178
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could these be merged into
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| // Icons | ||
| iconSizes, | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import {useTheme} from '@emotion/react'; | ||
| import type {Transition} from 'framer-motion'; | ||
|
|
||
| export function useWidgetBuilderTransitionSettings(): Transition { | ||
| const theme = useTheme(); | ||
|
|
||
| return { | ||
| type: 'tween', | ||
| ease: theme.motionControlPoints.snap, | ||
| duration: 0.5, // TODO: Introduce a slower value | ||
| }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of a bummer we went from physics controller moment to a fixed linear bezier motion curve. Will have to play with it, but my experience with simple bezier curves is that it's hard to get it to feel nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷🏻♂️ you tell me, I'm opting to use the motion tokens that we have. If that's not appropriate for panels I'm totally fine to move it back, as long as they can run at high FPS in busy situations