Repository navigation
Add motion design tokens (duration and easing) to @wordpress/theme #76097
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
8e0cf57
b17ec00
19f255d
22936b7
ac08416
ce10fc0
2bcddc6
6811911
c42b7f8
ec5b305
8d745f4
47baac9
98a3dda
39b4e87
121f131
2d54793
b06c288
b039f89
8b5eef9
fd9ec8a
e6198f2
81c6d7e
09e8461
d6e208c
5a15ee7
36f6ed8
fa149b6
66945cb
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 |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| // Motion configuration for dropdown-like popovers. | ||
| // Keep constants in sync with: packages/ui/src/utils/css/dropdown-motion.module.css | ||
| // Values should stay in sync with --wpds-motion-* design tokens. | ||
|
Contributor
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. The duplication of values across tokens and various JS/TS implementations is something they should ideally tackle as a follow-up. Maybe the best choice for dropdown (and other typescript-based component styles) is to migrate away from Emotion, so that we can consume the CSS variables directly? |
||
|
|
||
| export const DROPDOWN_MOTION = Object.freeze( { | ||
| SLIDE_DISTANCE: 4, | ||
| SLIDE_DURATION: 200, | ||
| SLIDE_EASING: { | ||
| function: 'cubic-bezier', | ||
| args: [ 0, 0, 0, 1 ] as const, | ||
| args: [ 0.25, 0, 0, 1 ] as const, | ||
| }, | ||
| FADE_DURATION: 80, | ||
| FADE_DURATION: 100, | ||
| FADE_EASING: { | ||
| function: 'linear', | ||
| }, | ||
|
|
@@ -24,6 +25,9 @@ const convertEasingToString = ( easing: { | |
| return easing.function; | ||
| }; | ||
|
|
||
| // Note: --wpds-* tokens can't be used here directly because the build-time | ||
| // fallback injection is not compatible with Emotion. This file is consumed | ||
| // by Menu's Emotion styles. | ||
| export const DROPDOWN_MOTION_CSS = Object.freeze( { | ||
| SLIDE_DISTANCE: `${ DROPDOWN_MOTION.SLIDE_DISTANCE }px`, | ||
| SLIDE_DURATION: `${ DROPDOWN_MOTION.SLIDE_DURATION }ms`, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| { | ||
| "wpds-motion": { | ||
| "duration": { | ||
| "$type": "duration", | ||
| "xs": { | ||
| "$value": { "value": 50, "unit": "ms" }, | ||
| "$description": "Micro-delays and transition offsets" | ||
| }, | ||
| "sm": { | ||
| "$value": { "value": 100, "unit": "ms" }, | ||
| "$description": "Micro-interactions like focus rings and state changes" | ||
| }, | ||
| "md": { | ||
| "$value": { "value": 200, "unit": "ms" }, | ||
| "$description": "Standard transitions like menus and popovers" | ||
| }, | ||
| "lg": { | ||
| "$value": { "value": 300, "unit": "ms" }, | ||
| "$description": "Deliberate animations like slides and reveals" | ||
| }, | ||
| "xl": { | ||
| "$value": { "value": 400, "unit": "ms" }, | ||
| "$description": "Extended animations like complex or multi-step transitions" | ||
| } | ||
| }, | ||
| "easing": { | ||
| "$type": "cubicBezier", | ||
| "subtle": { | ||
| "$value": [ 0.15, 0, 0.15, 1 ], | ||
| "$description": "Nearly imperceptible easing for hover, color, and background transitions" | ||
| }, | ||
| "balanced": { | ||
| "$value": [ 0.4, 0, 0.2, 1 ], | ||
| "$description": "General-purpose easing for on-screen movement like resizing, morphing, and layout shifts" | ||
| }, | ||
| "expressive": { | ||
| "$value": [ 0.25, 0, 0, 1 ], | ||
| "$description": "Noticeable easing for enter/exit and spatial transitions like menus, popovers, dialogs, and drawers" | ||
| } | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.