Repository navigation
docs(motion): use the motion tokens in your own CSS, with the Reduce Motion fallback #12535
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
Draft
cixzhang
wants to merge
9
commits into
main
Choose a base branch
from
lane2/docs-motion-tokens-own-css
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+56
−1
Draft
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c781563
docs(motion): use the motion tokens in your own CSS, with the Reduce …
cixzhang a642094
docs(motion): say that your own CSS follows the person's setting, not…
cixzhang ef2ed6a
docs(motion): drop the sentence about reducedMotion 'always', which n…
cixzhang e3b741b
docs(motion): a shorter heading for the table of contents, and no lon…
cixzhang e080029
docs(motion): the touch cross-fade also plays when the panel hides
cixzhang 9be91b7
docs(motion): the example's panel leaves on the exit tokens
cixzhang 2a6e0c4
Merge remote-tracking branch 'origin/main' into lane2/docs-motion-tok…
cixzhang 1643c85
test(cli): the stable docs goldens list the Motion doc's own-css section
cixzhang d39ecf0
Merge remote-tracking branch 'origin/main' into lane2/docs-motion-tok…
cixzhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| --- | ||
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [docs] The Motion foundations doc shows how to use the `--duration-*` and `--ease-*` motion tokens in your own CSS, with the Reduce Motion fallback: no travel, an immediate change with a mouse, and an opacity cross-fade of 200 ms or less under a finger. | ||
|
|
||
| @cixzhang |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -143,6 +143,48 @@ const styles = stylex.create({ | |
| }, | ||
| ], | ||
| }, | ||
| { | ||
| id: 'own-css', | ||
| title: 'Motion tokens in your CSS', | ||
| category: 'foundations', | ||
| content: [ | ||
| { | ||
| type: 'prose', | ||
| text: "The motion tokens are CSS custom properties, so plain CSS reads them with `var()`; for the Web Animations API, read a token's value with `getComputedStyle` first. Time an animation with a `--duration-*` token and ease it with an `--ease-*` token, so it follows the theme's motion. Under Reduce Motion, keep the change but drop the travel: nothing moves, scales or clips. With a mouse or trackpad the change happens at once; under a finger it cross-fades, opacity only, in 200 ms or less.", | ||
|
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. Non-blocking: a token read with |
||
| }, | ||
| { | ||
| type: 'code', | ||
| lang: 'css', | ||
| label: 'A panel that slides in, with its Reduce Motion fallback', | ||
| code: `.panel { | ||
| transition: | ||
| transform var(--duration-medium) var(--ease-entrance), | ||
| opacity var(--duration-medium) var(--ease-entrance); | ||
| } | ||
| .panel[data-hidden] { | ||
| transform: translateY(16px); | ||
| opacity: 0; | ||
| } | ||
|
astracat-bot[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| @media (prefers-reduced-motion: reduce) { | ||
| /* No travel: the panel appears in its final place. */ | ||
| .panel, | ||
| .panel[data-hidden] { | ||
| transform: none; | ||
| transition: none; | ||
| } | ||
| } | ||
|
|
||
| @media (prefers-reduced-motion: reduce) and (pointer: coarse) { | ||
| /* Under a finger, a short cross-fade instead, both ways. */ | ||
| .panel, | ||
| .panel[data-hidden] { | ||
| transition: opacity 200ms linear; | ||
| } | ||
|
astracat-bot[bot] marked this conversation as resolved.
Resolved
|
||
| }`, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| id: 'theme-motion', | ||
| title: 'Tune motion from the theme', | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.