Repository navigation
docs(theme): an extending theme's motion inherits field by field - #8748
Conversation
The theme authoring guide grouped motion with typography, radius and color as scale configs the child replaces entirely. defineTheme seeds the child's tokens from its base, and expandMotionScale writes the slow band and the easing only when they are set, so a child that leaves slow or easing unset keeps the base's tokens (spec:AST-108 FR5). The guide now says so for motion, and a test pins it.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
|
There was a problem hiding this comment.
Changes requested: the corrected motion row follows spec:AST-108 FR5 and the new test pins the inheritance, but the row still misdescribes one case. A child must set ratio whenever it sets motion, yet that ratio never reaches an inherited slow band (your test keeps --duration-slow-min at 300ms, 400 × the base's 0.75, with the child at 0.8), while the row says the fields the child sets regenerate their tokens.
- Reword the row and the changeset so an omitted
slowkeeps the base's whole slow band, min and max at the base'sratio, and say that restatingslowre-derives it. - Carve
motionout of the note inpackages/cli/assets/theme.template.ts(lines 93–96) that says the scale configs replace the base's, since it now contradicts the guide.
[Automated review]
| ['indicators', 'Shallow-merged: child indicators override matching names from the base.'], | ||
| ['onDark, onLight', "Deep-merged per surface: the base's resolved surface first, then the child's overrides."], | ||
| ['typography, motion, radius, color', 'Child config replaces base entirely (these are scale inputs, not additive).'], | ||
| ['motion', "Field by field: the fields the child sets regenerate their tokens, and a field it leaves unset (`slow`, `easing`) keeps the base theme's value."], |
There was a problem hiding this comment.
A child must set ratio whenever it sets motion, but that ratio never reaches an inherited slow band: in this PR's test the child sets ratio: 0.8 and --duration-slow-min stays 300ms (400 × the base's 0.75), and a neutralTheme child at 0.8 keeps 525/935 ms rather than 560/875 ms. "The fields the child sets regenerate their tokens" reads as if the slow band would follow. A wording that matches defineTheme:
['motion', "Field by field: `fast`, `medium` and `ratio` regenerate the fast and medium bands. A field the child leaves unset keeps the base theme's generated tokens: without `slow`, the base's slow band stays whole, min and max at the base's `ratio` (restate `slow` to re-derive it); without `easing`, the base's `--ease-standard` stays."],| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [docs] The theme authoring guide says an extending theme's `motion` inherits field by field: the fields the child sets regenerate their duration tokens, and `slow` or `easing` left unset keep the base theme's values. It used to say the child's motion config replaced the base's entirely. |
There was a problem hiding this comment.
Same wording as the guide row: a child's ratio does not re-derive an inherited slow band, so "the fields the child sets regenerate their duration tokens" over-promises. Something like:
[docs] The theme authoring guide says an extending theme's `motion` inherits field by field: `fast`, `medium` and `ratio` regenerate the fast and medium duration bands, and `slow` or `easing` left unset keep the base theme's generated values (an omitted `slow` keeps the base's whole slow band, at the base's `ratio`). It used to say the child's motion config replaced the base's entirely.
CodeBunny: a child's ratio regenerates the fast and medium bands but leaves an inherited slow band at the base's ratio. The guide row and changeset now say so.
There was a problem hiding this comment.
Incremental review of 213ce6d..96d0163; prior findings carried: user_impact, concrete_defects, disposition
Changes requested: the reworded motion row and changeset now describe the inheritance accurately, including the slow band staying at the base's ratio, and the new test pins it. One item from the earlier review remains: the note in packages/cli/assets/theme.template.ts (lines 93–96), which astryx init --features theme and astryx theme template write into a project, still says the scale configs, motion included, replace the base's rather than merging, contradicting spec:AST-108 FR5 and the corrected guide. Carving motion out of that sentence with the row's wording resolves it.
[Automated review]
…field by field CodeBunny: the theme file astryx init and astryx theme template write still said every scale config replaces the base's.
There was a problem hiding this comment.
Incremental review of 96d0163..8df2f28; prior findings carried: none
Recommending approval: the template's extends note now says motion inherits field by field, matching spec:AST-108 FR5, the corrected guide row and what defineTheme does, and both astryx theme template and astryx init --features theme write it. Nothing else is needed for this pull request. As an optional follow-up, the REPLACE wording kept for typography (here and in the guide's typography, radius, color row) is also looser than the code: a child that sets only typography.body keeps the base's font sizes and code font.
[Automated review]
There was a problem hiding this comment.
Incremental review of 8df2f28..9d63206; prior findings carried: none
Recommending approval: the updated author-a-theme digest in the experimental-isolation golden is exactly what the corrected guide's Merge behavior table produces, so the stable-docs test passes with the split motion row, and the guide row, the template note and the new defineTheme test still match spec:AST-108 FR5. Nothing else is needed for this pull request. As an optional follow-up, the REPLACE wording kept for typography (in the template note and the guide's typography, radius, color row) is looser than the code: a child that sets only typography.body keeps the base's font sizes and code font.
[Automated review]
Main brings meta#8748, which documents and tests that an extending theme's motion inherits field by field: the child's fast, medium and ratio regenerate the fast and medium bands, and a slow or easing left unset keeps the base's tokens, so an inherited slow band stays at the base's ratio. - author-a-theme.doc.mjs takes meta#8748's inheritance row as merged and adds one sentence for the knobs: each one the child leaves unset keeps the base's, and explicit motion tokens anywhere in the lineage still win. - defineTheme merged the motion configuration and regenerated every band, so a child's ratio moved an inherited slow band (320 ms where meta#8748's test expects 300 ms). A child that sets its own ratio but no slow now keeps the base's slow-band tokens; a base duration scale still wins over a child's tempo.
meta#8661 now carries main c86dc62 (meta#8748's field-by-field motion inheritance) and its fix: a child theme that sets its own ratio but no slow keeps the base's slow-band tokens. Merging it here, rather than main alone, keeps meta#8748's new test green on this branch, which carries meta#8661's motion inheritance through meta#8677. No conflicts.
…n generated Her ruling on meta#8661, from current records: drop INV15's lineage-wide clause. It said an explicit motion token anywhere in a theme's lineage keeps winning over what a child's knobs generate, which conflicts with `architecture:theme-authoring-contract`'s precedence: an extending theme's tokens resolve base first, then generated. - defineTheme no longer re-applies a base's explicit motion tokens over the child's generated ones, for a defined base or a built one. A child that sets no slow of its own still keeps its base's slow band (meta#8748), and a theme's own explicit tokens still win over its own knobs. - INV15 and the theme guide drop the clause. - Two cases now pin the precedence, and both fail on the previous head: a child's tempo or inherited tempo regenerates a base's explicit duration, for a defined base and an installed built one, and a built base's entrance curve stays when the child generates none.
## Why A theme author cannot say how motion should feel, quicker, crisper or reduced, without overriding durations and curves per component. `spec:AST-108` (#8613) gives `defineTheme`'s `motion` three knobs: `tempo`, `character` and `reducedMotion`. This pull request ships `tempo` and `character`, and exports their types (`ThemeMotionConfig`, `ThemeMotionKnobs`, `MotionCharacter`). `reducedMotion` stays out of the public type until `'always'` works: component Reduce Motion styles, script readers and the animator must follow it first. Every theme follows each person's setting, as `'system'` does. ## What led to it This comes from the work to make Astryx's touch components behave as native iOS ones do, where a theme's motion must reach springs and press feedback, not only CSS. Themes could scale their duration tokens, but easing was one curve for everything, and Reduce Motion only followed the system setting. ## Options and tradeoffs - CSS-only knobs compose through the cascade but cost the animator a style read per motion; attribute-only knobs are free for scripts but invisible to CSS. - Busy loops (Spinner, Skeleton) could be exempted from `tempo` by name, or read a copy of each duration taken before `tempo`. - An extending theme could resolve base first, then generated (the theme-authoring contract), or let a base's explicit motion tokens win over its children's knobs. ## Why this choice - CSS gets tokens now; the attributes the animator reads come with the animator's own pull request. - The copies: every layer that writes a duration writes one, so later components need nothing special. - The contract's precedence, as the maintainer ruled; a child with no `slow` keeps its base's slow band (#8748). - `--ease-exit` is #8004's; this defines none, and `character` never moves it. - `reducedMotion: 'always'` would have reached only motion-keyed adaptation rules and the press release fade, so a theme setting it would reduce a little of the page and leave Spinner, Skeleton and most components moving. With `'system'` as the only value the field would do nothing, so the public type leaves it out until every component follows `'always'`. ## How to check it 1. Wrap a Dialog story in `<Theme theme={defineTheme({name: 'Slow', motion: {tempo: 1.5}})}>`: it opens 1.5 times slower; a Spinner beside it keeps its speed. 2. Add `character: 'expressive'`: `--ease-entrance` and `--ease-move` take the overshooting curve, so a style that eases on them overshoots on entrance; `--ease-standard` and exits do not change. Dialog still eases on `--ease-standard`, so it does not overshoot yet. 3. Under tempo 1.5, tap or click a Button: its pressed highlight fades out over 300 ms instead of 200 ms. 4. Extend a theme that sets `--duration-medium: 300ms` with `tempo: 1.2`: the child's is 492 ms. 5. `defineTheme({name: 'Partial', motion: {fast: 100, tempo: 1.2}})` throws: a duration scale needs `fast`, `medium` and `ratio`, from the theme or its base. ## Evidence - Tests: `packages/core/src/theme/themeMotion.test.ts` and `packages/core/src/utils/pressFeedback.test.ts`. Each new case fails without its part of the change. - The theme, press feedback, Spinner and Skeleton suites, the theme private-variable and CSS build checks, the CLI doc goldens, type check and lint pass on this head. ## Writing rubric results R1 narration, R2 research, R4 rejected alternatives, R5 change references and R6 open questions: none. R3 evidence: INV15's row cites its test file. ## Scope - [x] One capability is added. - [x] Unrelated fixes, cleanup, and policy changes were removed or split. - [x] Consumer docs, focused tests, and migration evidence ship with the feature. - [x] Public text and artifacts contain no internal Meta context.
Reader impact
A theme author extending a base theme reads that a child's
motionconfig replaces the base's entirely, so they copy every motion field into the child to be safe, or expect a field they leave out to fall back to Astryx's defaults. In fact a field they leave unset (slow,easing) keeps the base theme's value. After this change the guide tells them whatdefineThemedoes, so they can set only the motion fields they mean to change.Source of truth
spec:AST-108FR5 (authoritycurrent): "an extending theme inherits field by field: aMotionScaleConfigfield or a knob the child leaves unset keeps its base's value."resolveThemeValuesseeds the child's tokens from its base, andexpandMotionScalewrites the slow band and--ease-standardonly whenslowandeasingare set.fast,mediumandratioare required, so a child that setsmotionalways regenerates those bands.Correction
author-a-theme→ Extending a Theme → Merge behavior:typography, motion, radius, color— "Child config replaces base entirely (these are scale inputs, not additive)."motion— "Field by field: the child'sfast,mediumandratioregenerate the fast and medium duration tokens;slowandeasingleft unset keep the base theme's tokens, so an inherited slow band stays at the base's ratio."typography, radius, colorkeep the existing row; this PR does not change what it says about them.The theme file
astryx initandastryx theme templatewrite (packages/cli/assets/theme.template.ts) said the same in itsextendscomment; it now says the typography, radius and color scale configs replace the base's andmotioninherits field by field.Evidence
astryx docs author-a-theme extending-a-themeon this branch:A new
defineThemetest pins the behavior: a base withfast,medium,slow,ratioandeasing, extended by a child that sets onlyfast,mediumandratio, keeps the base's--duration-slow*tokens (at the base's ratio) and--ease-standard, and regenerates the fast and medium bands. With the base seed removed fromresolveThemeValues, the test fails.Scope
Testing
pnpm vitest run packages/core/src/theme/defineTheme.test.ts(137 passed)pnpm vitest run packages/cli/api/docs(166 passed)pnpm vitest runover the theme-template, init behavior and init API tests (55 passed)check:knowledge,check:changesets, andcheck:cli-structure