An open source design system that's fully customizable and agent ready
TypeScript
fix(core): the layout glide takes --duration-medium (#10261)
Christopher Chedeau3c63e6e1833b
diff --git a/.changeset/animated-layout-curve-tokens.md b/.changeset/animated-layout-curve-tokens.mdindex a199104b8d..c5e45a67e3 100644--- a/.changeset/animated-layout-curve-tokens.md+++ b/.changeset/animated-layout-curve-tokens.md@@ -2,6 +2,6 @@'@astryxdesign/core': patch----[fix] Animated layout: the glide, the in-place swap and the edge reveal play the theme's move curve (`--ease-move`) over `--duration-medium-min` instead of a spring, so they follow the theme's `character` and `tempo` and land with the motion around them. Reduce Motion is unchanged: a cross-fade under a coarse pointer, an immediate change otherwise. The glides of AppShell's content area, Collapsible, Table's row expansion and TreeList change feel: 225 ms in the Neutral theme, 310 ms with no theme, instead of about 735 ms. A theme whose move easing is a `linear()` or `steps()` function glides on it, as the browser plays it. The segmented control's selection, which reads its timing the same way, now plays such an easing too instead of moving at once.+[fix] Animated layout: the glide, the in-place swap and the edge reveal play the theme's move curve (`--ease-move`) over `--duration-medium` instead of a spring, so they follow the theme's `character` and `tempo` and land with the motion around them. Reduce Motion is unchanged: a cross-fade under a coarse pointer, an immediate change otherwise. The glides of AppShell's content area, Collapsible, Table's row expansion and TreeList change feel: 300 ms in the Neutral theme, 410 ms with no theme, instead of about 735 ms. A theme whose move easing is a `linear()` or `steps()` function glides on it, as the browser plays it. The segmented control's selection, which reads its timing the same way, now plays such an easing too instead of moving at once.@vjeuxdiff --git a/apps/storybook/stories/ThemeMotionTempo.stories.tsx b/apps/storybook/stories/ThemeMotionTempo.stories.tsxindex 650161f045..10fdf10574 100644--- a/apps/storybook/stories/ThemeMotionTempo.stories.tsx+++ b/apps/storybook/stories/ThemeMotionTempo.stories.tsx@@ -133,7 +133,7 @@ const durationScaleTheme = defineTheme({/*** A theme with only a duration scale, nested in a theme at tempo 1.5. Its- * glide plays its own scale's `--duration-medium-min`, which the outer tempo+ * glide plays its own scale's `--duration-medium`, which the outer tempo* does not reach.*/export const NestedDurationScale: Story = {diff --git a/docs/specs/AST-105-animated-layout/spec.md b/docs/specs/AST-105-animated-layout/spec.mdindex 4df4750ba7..beabc58659 100644--- a/docs/specs/AST-105-animated-layout/spec.md+++ b/docs/specs/AST-105-animated-layout/spec.md@@ -89,7 +89,7 @@ const animatedLayout = useAnimatedLayout({containerRef: scrollRef});element plays its own animation, entering, exiting, or resizing, and thecontent after it moves with it. Both play the same motion, so the timing isgoverned centrally, never per component: the theme's move curve,- `--ease-move`, over `--duration-medium-min`, which follow the theme's+ `--ease-move`, over `--duration-medium`, which follow the theme's`character` and `tempo` (`spec:AST-108` FR1, FR2). The glide is curvetokens, never a spring, and no character or option plays aplatform-measured curve for it (`spec:AST-094` FR45). Both start on the same@@ -270,6 +270,18 @@ tokens, never a spring (`spec:AST-094` FR45).Rejected: the measured spring as the glide; a platform-measured opt-in, such as a separate character.+### DEC-3 — The glide takes the medium duration++**Reference:** `spec:AST-105/DEC-3`+**Decider:** `cixzhang`, `2026-11-06`++The glide plays over `--duration-medium`, the middle of the theme's medium+durations: 300 ms in the Neutral theme and 410 ms with no theme, both scaled+by `tempo`. Collapsible, TreeList, Table's row expansion and AppShell's+content area share it, as one motion.++Rejected: `--duration-medium-min`.+## Open questionsNone.diff --git a/packages/core/src/motion/__tests__/animatedLayout.interaction.browser.spec.ts b/packages/core/src/motion/__tests__/animatedLayout.interaction.browser.spec.tsindex 33fa1d2d07..e7d656d606 100644--- a/packages/core/src/motion/__tests__/animatedLayout.interaction.browser.spec.ts+++ b/packages/core/src/motion/__tests__/animatedLayout.interaction.browser.spec.ts@@ -880,7 +880,7 @@ test.describe('spec:AST-105 Coverage', () => {page,`<div id="area" class="area"><div id="grow" class="grow"></div><div id="second" class="grow"></div><div id="after" class="row"></div></div>`,- '#area { --duration-medium-min: 1000ms; }',+ '#area { --duration-medium: 1000ms; }',);await change(page);await page.waitForTimeout(100);@@ -1961,11 +1961,11 @@ test.describe('spec:AST-105 FR2–FR4', () => {expect(grow[0].startTime).toBe(follower[0].startTime);expect(grow[0].duration).toBeCloseTo(follower[0].duration, 3);// With no stylesheet, the tokens read core's declared values.- expect(follower[0].duration).toBeCloseTo(310, 3);+ expect(follower[0].duration).toBeCloseTo(410, 3);expectOnCurve(await page.evaluate(() => window.curveOf('#a')),[0.24, 1, 0.4, 1],- 310,+ 410,);});@@ -2349,30 +2349,30 @@ test.describe('spec:AST-105 FR2–FR4', () => {for (const theme of [{name: 'at tempo 0.75',- style: '--duration-medium-min: 232.5ms',- ms: 232.5,+ style: '--duration-medium: 307.5ms',+ ms: 307.5,points: [0.24, 1, 0.4, 1],},{name: 'at tempo 1.5',- style: '--duration-medium-min: 465ms',- ms: 465,+ style: '--duration-medium: 615ms',+ ms: 615,points: [0.24, 1, 0.4, 1],},{name: "at character 'crisp'",style: '--ease-move: cubic-bezier(0, 0, 0.2, 1)',- ms: 310,+ ms: 410,points: [0, 0, 0.2, 1],},{name: "at character 'expressive'",style: '--ease-move: cubic-bezier(0.3, 1.2, 0.5, 1)',- ms: 310,+ ms: 410,points: [0.3, 1.2, 0.5, 1],},] as const) {- test(`a theme ${theme.name}: the glide plays its --ease-move over its --duration-medium-min (FR4)`, async ({+ test(`a theme ${theme.name}: the glide plays its --ease-move over its --duration-medium (FR4)`, async ({page,}) => {// The tokens a theme with that knob writes on its scope.@@ -2407,11 +2407,11 @@ test.describe('spec:AST-105 FR2–FR4', () => {await change(page);const motions = await page.evaluate(() => window.motionOf('#a'));expect(motions, 'the content after the change glides').toHaveLength(1);- expect(motions[0].duration).toBeCloseTo(310, 3);+ expect(motions[0].duration).toBeCloseTo(410, 3);expectOnEase(await page.evaluate(() => window.curveOf('#a')),theme.ease,- 310,+ 410,);});}@@ -2423,8 +2423,8 @@ test.describe('spec:AST-105 FR2–FR4', () => {await open(page,PAGE,- `#area { --duration-medium-min: 310ms; --ease-move: cubic-bezier(0.24, 1, 0.4, 1); }- #grow { --duration-medium-min: 620ms; --ease-move: cubic-bezier(0, 0, 0.2, 1); }`,+ `#area { --duration-medium: 310ms; --ease-move: cubic-bezier(0.24, 1, 0.4, 1); }+ #grow { --duration-medium: 620ms; --ease-move: cubic-bezier(0, 0, 0.2, 1); }`,);await change(page);const [motion] = await page.evaluate(() => window.motionOf('#a'));diff --git a/packages/core/src/motion/__tests__/themeTempo.interaction.browser.spec.ts b/packages/core/src/motion/__tests__/themeTempo.interaction.browser.spec.tsindex aaacc17980..0a881ff402 100644--- a/packages/core/src/motion/__tests__/themeTempo.interaction.browser.spec.ts+++ b/packages/core/src/motion/__tests__/themeTempo.interaction.browser.spec.ts@@ -238,18 +238,18 @@ test('a duration scale nested in a tempo theme glides on its own duration token'page,}) => {await openStory(page, NESTED_STORY, 3);- // Each row's `--duration-medium-min`, in ms, as its theme writes it.+ // Each row's `--duration-medium`, in ms, as its theme writes it.const tokenMs = async (row: string) =>page.evaluate(selector =>Number.parseFloat(getComputedStyle(document.querySelector(selector) as Element,- ).getPropertyValue('--duration-medium-min'),+ ).getPropertyValue('--duration-medium'),),row,);- // Each row glides on the `--duration-medium-min` of the theme it is in.+ // Each row glides on the `--duration-medium` of the theme it is in.for (const row of ['plain', 'outer', 'nested']) {const selector = `section[data-row="${row}"]`;expect(await glideMs(page, selector), row).toBeCloseTo(@@ -260,6 +260,6 @@ test('a duration scale nested in a tempo theme glides on its own duration token'// The nested scale's own value: the outer tempo is not on it.const own = expandMotionScale({fast: 130, medium: 310, ratio: 0.75});expect(await tokenMs('section[data-row="nested"]')).toBe(- Number.parseFloat(own['--duration-medium-min']),+ Number.parseFloat(own['--duration-medium']),);});diff --git a/packages/core/src/motion/animatedLayout.test.ts b/packages/core/src/motion/animatedLayout.test.tsindex df4c4c063c..2f53bf7eb2 100644--- a/packages/core/src/motion/animatedLayout.test.ts+++ b/packages/core/src/motion/animatedLayout.test.ts@@ -361,7 +361,7 @@ describe('one shared motion (spec:AST-105 FR4)', () => {);}- it("plays the changed element and its followers on the theme's move curve over --duration-medium-min, with one duration", async () => {+ it("plays the changed element and its followers on the theme's move curve over --duration-medium, with one duration", async () => {// With no stylesheet, the tokens read core's declared values.await changeOnce();const follower = played.find(p => (p.element as HTMLElement).id === 'a');@@ -369,16 +369,16 @@ describe('one shared motion (spec:AST-105 FR4)', () => {expect(follower).toBeDefined();expect(own).toBeDefined();expect(own?.options.duration).toBe(follower?.options.duration);- expect(Number(follower?.options.duration)).toBeCloseTo(310, 6);- const remaining = remainingOn([0.24, 1, 0.4, 1], 310);+ expect(Number(follower?.options.duration)).toBeCloseTo(410, 6);+ const remaining = remainingOn([0.24, 1, 0.4, 1], 410);for (const {t, y} of verticalCurveOf(follower as Played)) {expect(y).toBeCloseTo(-80 * remaining(t), 3);}});- it('plays the --duration-medium-min and --ease-move of the theme the area is in', async () => {+ it('plays the --duration-medium and --ease-move of the theme the area is in', async () => {await changeOnce(- '--duration-medium-min: 200ms; --ease-move: cubic-bezier(0, 0, 1, 1)',+ '--duration-medium: 200ms; --ease-move: cubic-bezier(0, 0, 1, 1)',);const follower = played.find(p => (p.element as HTMLElement).id === 'a');expect(Number(follower?.options.duration)).toBeCloseTo(200, 6);@@ -389,17 +389,15 @@ describe('one shared motion (spec:AST-105 FR4)', () => {it("follows the theme's tempo through its duration token, never scaled twice (spec:AST-108 FR2)", async () => {// A theme at tempo 1.5 writes the scaled token beside its tempo.- await changeOnce(- '--duration-medium-min: 465ms; --_astryx-motion-tempo: 1.5',- );+ await changeOnce('--duration-medium: 615ms; --_astryx-motion-tempo: 1.5');const follower = played.find(p => (p.element as HTMLElement).id === 'a');const own = played.find(p => (p.element as HTMLElement).id === 'changed');- expect(Number(follower?.options.duration)).toBeCloseTo(465, 6);+ expect(Number(follower?.options.duration)).toBeCloseTo(615, 6);expect(own?.options.duration).toBe(follower?.options.duration);});it('lands at once when the theme sets a zero duration', async () => {- await changeOnce('--duration-medium-min: 0ms');+ await changeOnce('--duration-medium: 0ms');expect(played).toEqual([]);});@@ -424,7 +422,7 @@ describe('one shared motion (spec:AST-105 FR4)', () => {it('retargets an element already gliding: one glide, started from where it is on screen', async () => {// A long, even curve, so the first glide still moves fast 100 ms in.const {area, changed, phase} = setUp(- '<div id="area" style="--duration-medium-min: 1000ms; --ease-move: cubic-bezier(0, 0, 1, 1)"><div id="changed"></div><div id="a"></div></div>',+ '<div id="area" style="--duration-medium: 1000ms; --ease-move: cubic-bezier(0, 0, 1, 1)"><div id="changed"></div><div id="a"></div></div>',);const a = document.getElementById('a') as HTMLElement;let top = 0;@@ -759,14 +757,14 @@ describe('the indicator transition', () => {expect(chevron.style.getPropertyValue('transition-timing-function')).toBe('cubic-bezier(0.24, 1, 0.4, 1)',);- expect(chevron.style.getPropertyValue('transition-duration')).toBe('310ms');+ expect(chevron.style.getPropertyValue('transition-duration')).toBe('410ms');applyLayoutChangeTransition(null, chevron);expect(chevron.style.getPropertyValue('transition-duration')).toBe('');});it('takes the timing read where the area is, whatever scope sits between them', () => {- document.body.innerHTML = `<div id="area" style="--duration-medium-min: 465ms; --ease-move: cubic-bezier(0, 0, 0.2, 1)">- <div style="--duration-medium-min: 620ms; --ease-move: cubic-bezier(0.3, 1.2, 0.5, 1)"><svg id="chevron"></svg></div></div>`;+ document.body.innerHTML = `<div id="area" style="--duration-medium: 465ms; --ease-move: cubic-bezier(0, 0, 0.2, 1)">+ <div style="--duration-medium: 620ms; --ease-move: cubic-bezier(0.3, 1.2, 0.5, 1)"><svg id="chevron"></svg></div></div>`;const area = document.getElementById('area') as HTMLElement;const chevron = document.getElementById('chevron',diff --git a/packages/core/src/motion/animatedLayout.ts b/packages/core/src/motion/animatedLayout.tsindex e6b682ae59..88b5a29854 100644--- a/packages/core/src/motion/animatedLayout.ts+++ b/packages/core/src/motion/animatedLayout.ts@@ -137,14 +137,14 @@ function matches(element: Element, query: string): boolean {}/**- * The theme's move curve over its shortest medium duration where `area` is:+ * The theme's move curve over its medium duration where `area` is:* one value for the glide, the changed element and the indicator. The tokens* carry the theme's `character` and `tempo`. Null when the duration is zero* or the browser plays no such easing, and then the change lands at once.*/function glideProgress(area: Element): GlideProgress | null {const curve = readThemeTiming(area, {- duration: '--duration-medium-min',+ duration: '--duration-medium',easing: '--ease-move',});const easing = readThemeTokenText(area, '--ease-move');