Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/animated-layout-curve-tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

@vjeux
7 changes: 7 additions & 0 deletions .changeset/list-animated-layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[feat] `List` takes `animatedLayout`, the handle from `useAnimatedLayout({containerRef})`, and `ListItem` takes `itemKey`, the row's identity. With the handle, when rows are inserted, removed or reordered, an inserted row enters, a removed row (a swiped one with its action showing) collapses in place, and a row that crosses rows moving the other way rides above them with the surface color behind it, as an iOS table's opaque cell does. The rows after a change and the content after the list, up to the handle's container, glide to their new places. All of it runs on one shared motion and starts together, under every pointer; under Reduce Motion nothing travels. A row without an `itemKey` changes at once, and without the handle the whole list does.

@vjeux
152 changes: 152 additions & 0 deletions apps/storybook/stories/List.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {Icon} from '@astryxdesign/core/Icon';
import {Switch} from '@astryxdesign/core/Switch';
import {Heading, Text} from '@astryxdesign/core/Text';
import {VStack} from '@astryxdesign/core/Layout';
import {useAnimatedLayout} from '@astryxdesign/core/hooks';
import {rtlStyles} from '@astryxdesign/core/utils';
import {
Cog6ToothIcon,
Expand Down Expand Up @@ -762,3 +763,154 @@ export const HeaderInFlexParent: Story = {
},
},
};

function AnimatedChangesDemo() {
const [rows, setRows] = useState([
'Inbox',
'Sent',
'Drafts',
'Archive',
'Spam',
]);
const [next, setNext] = useState(1);
const containerRef = useRef<HTMLDivElement>(null);
const animatedLayout = useAnimatedLayout({containerRef});
return (
<div ref={containerRef}>
<VStack gap={4}>
<List animatedLayout={animatedLayout} hasDividers>
{rows.map(label => (
<ListItem
key={label}
itemKey={label}
label={label}
onClick={() => {}}
/>
))}
</List>
<Text data-testid="after-list">{`${rows.length} folders`}</Text>
<Button
label="Insert a row second"
onClick={() => {
setRows(current => [
current[0],
`Folder ${next}`,
...current.slice(1),
]);
setNext(n => n + 1);
}}
/>
<Button
label="Remove the second row"
onClick={() =>
setRows(current => current.filter((_, index) => index !== 1))
}
/>
<Button
label="Move the last row first"
onClick={() =>
setRows(current => [
current[current.length - 1],
...current.slice(0, -1),
])
}
/>
</VStack>
</div>
);
}

export const AnimatedChanges: Story = {
render: () => <AnimatedChangesDemo />,
parameters: {
docs: {
description: {
story:
'With `animatedLayout` (the handle from `useAnimatedLayout`) and ' +
'an `itemKey` on each row, an inserted row enters, a removed row ' +
'collapses in place, a row crossing rows that move the other way ' +
'rides above them with the surface color behind it, and the rows ' +
'after a change and the buttons below the list glide to their new ' +
'places, all on one shared motion, under every pointer.',
},
},
},
};

/** The swipe story's row with no swipe actions. */
const PLAIN_ROW = 'Notes';

function AnimatedChangesSwipeDemo() {
const [rows, setRows] = useState([
'Inbox',
'Sent',
'Drafts',
'Archive',
PLAIN_ROW,
]);
const containerRef = useRef<HTMLDivElement>(null);
const animatedLayout = useAnimatedLayout({containerRef});
const moveFirst = (label: string) =>
setRows(current =>
current.includes(label)
? [label, ...current.filter(row => row !== label)]
: current,
);
return (
<div ref={containerRef}>
<List animatedLayout={animatedLayout} hasDividers>
{rows.map(label => (
<ListItem
key={label}
itemKey={label}
label={label}
onClick={() => {}}
swipeActions={
label === PLAIN_ROW
? undefined
: {
trailing: [
{
label: 'Delete',
variant: 'destructive',
hasRemoval: true,
onActivate: () =>
setRows(current =>
current.filter(row => row !== label),
),
},
],
}
}
/>
))}
</List>
<Button
label="Move Archive first"
variant="secondary"
onClick={() => moveFirst('Archive')}
/>
<Button
label="Move Notes first"
variant="secondary"
onClick={() => moveFirst(PLAIN_ROW)}
/>
</div>
);
}

export const AnimatedChangesSwipe: Story = {
render: () => <AnimatedChangesSwipeDemo />,
parameters: {
docs: {
description: {
story:
'With `animatedLayout`, a row swiped away with a removal action ' +
'collapses in place, its action showing, while the rows below ' +
'glide up into its gap on the shared motion. A row moved up ' +
'across the swipeable rows, with swipe actions (Archive) or ' +
'without (Notes), rides above the rows it crosses.',
},
},
},
};
2 changes: 1 addition & 1 deletion apps/storybook/stories/ThemeMotionTempo.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
14 changes: 13 additions & 1 deletion docs/specs/AST-105-animated-layout/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const animatedLayout = useAnimatedLayout({containerRef: scrollRef});
element plays its own animation, entering, exiting, or resizing, and the
content after it moves with it. Both play the same motion, so the timing is
governed 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 curve
tokens, never a spring, and no character or option plays a
platform-measured curve for it (`spec:AST-094` FR45). Both start on the same
Expand Down Expand Up @@ -262,6 +262,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, AppShell's content
area and List share it, as one motion.

Rejected: `--duration-medium-min`.

## Open questions

None.
4 changes: 3 additions & 1 deletion docs/specs/components/List/List.spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ verified_by:
packages/core/src/Item/Item.test.tsx,
packages/core/src/List/ListItem.hitArea.test.tsx,
packages/core/src/List/__tests__/ListTouchHitArea.interaction.browser.spec.ts,
packages/core/src/List/listLayoutUpdates.test.tsx,
packages/core/src/List/__tests__/ListUpdates.interaction.browser.spec.ts,
packages/core/src/theme/derivedVarRegistry.test.ts,
packages/core/src/theme/generateThemeRules.test.ts,
apps/storybook/stories/List.stories.tsx,
Expand Down Expand Up @@ -51,7 +53,7 @@ system_specs:
| Behavior | One edge treatment applies to every ListItem row and decides where row content and row paint sit relative to the list's edges and the host's padding. With `reorderable`, rows reorder by dragging a handle or through reorder mode (`spec:AST-103` FR3, FR4). Under a coarse pointer a row's press follows the cell profile (`spec:AST-094` FR11); with `animatedLayout`, row updates animate (`spec:AST-105`). A row menu opens from the row's own `<li>` on the context request (FR13). |
| End-user impact | Row text can share the line of the list header and a heading above, with row paint stopping at the text, reaching into the host padding, or reaching the host edges. Touch users get a 44 px row target (FR10) and the cell press (FR11); with `animatedLayout`, row updates animate for every pointer (FR12). A row with a menu opens it by a long press, a right click, or Shift+F10, or through its More actions button (FR13). |
| Builder impact | One `edge` choice per list. `flush` works anywhere; `outset` and `bleed` act only inside a host that publishes container padding. Passing an `animatedLayout` handle is one new choice, and a row menu is the other: the caller passes a ListItem's ref to `useContextMenu` (FR13), and who draws a plain row's More actions button is open (OQ2); and rows animate only with an `itemKey`; the touch target and press need none. |
| Compatibility/readiness | Additive; omission keeps current geometry; `edgeCompensation` keeps working with a codemod to `edge`. `reorderable` and `itemKey` are additive and stable, specified and not implemented yet; without them nothing changes. `animatedLayout` is additive and specified, not implemented yet. The touch target (FR10) and the press's compositor release (FR11) are implemented under coarse primary pointers. Neither changes anything under a fine pointer. Row menus (FR13) are additive and specified, not implemented yet. |
| Compatibility/readiness | Additive; omission keeps current geometry; `edgeCompensation` keeps working with a codemod to `edge`. `reorderable` is additive and stable, specified and not implemented yet. `itemKey` and `animatedLayout`'s row updates (FR12) are implemented; its start and end content motion is not. The touch target (FR10) and the press's compositor release (FR11) are implemented under coarse primary pointers. Neither changes anything under a fine pointer. Row menus (FR13) are additive and specified, not implemented yet. |
| Review checks | Reject header movement, row paint past the host's padding edge, duplicated padding values, physical-edge logic, automatic opt-in, a ListItem-level edge prop, or a second prop that can contradict `edge`. |
| Governing rules | `architecture:container-padding/INV3`, `INV9–INV11`; `spec:AST-002/DEC-1–DEC-2`; `spec:AST-017/FR4`; `spec:AST-057/FR9`. `spec:AST-103`. `spec:AST-094` FR4, FR5, FR11, FR13; `spec:AST-105` FR1–FR5, FR8. `spec:AST-107` FR8 (row menus). |

Expand Down
8 changes: 3 additions & 5 deletions docs/specs/components/List/ListItem.spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ review_triggers: [public-api, behavior, layout, theming]
verified_by:
[
packages/core/src/List/List.test.tsx,
packages/core/src/List/listLayoutUpdates.test.tsx,
packages/core/src/theme/themingTargets.test.ts,
scripts/check-knowledge.mjs,
apps/storybook/rtl-audit/targets.json,
Expand All @@ -36,11 +37,11 @@ system_specs: [spec:AST-057, spec:AST-103]

| Area | Contract |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Public contract | `ListItem` with `label`, `description`, `startContent`, `endContent`, `onClick`, `interactiveRef`, `href`, `target`, `rel`, `align`, `isDisabled`, `isSelected`, `swipe`, `xstyle`, `className`, `style`, and `ref`, with the deprecated `swipeActions` and `swipeBehavior` until `spec:AST-057` CLN-0025; the row carries `component:List`'s `list-item` target. `itemKey` (`spec:AST-103` DEC-4) is specified but not shipped. |
| Public contract | `ListItem` with `label`, `description`, `startContent`, `endContent`, `onClick`, `interactiveRef`, `href`, `target`, `rel`, `align`, `isDisabled`, `isSelected`, `itemKey`, `swipe`, `xstyle`, `className`, `style`, and `ref`, with the deprecated `swipeActions` and `swipeBehavior` until `spec:AST-057` CLN-0025; the row carries `component:List`'s `list-item` target. `itemKey` is the item's key (`spec:AST-103` DEC-4). |
| Behavior | One `<li>` row rendered by `component:Item`, which receives every row prop. Inside a List the row takes the list's density, dividers, edge treatment, and marker; outside a List it uses Item's defaults and draws no marker. |
| End-user impact | Each list entry reads as one list item, with the list's bullet, number, or task checkbox before it and the same interaction Item gives any row. |
| Builder impact | The deprecated `swipeActions` and `swipeBehavior` move to `swipe={createSwipe(…)}` under `spec:AST-057` DEP-0017; its `astryx upgrade` codemod is an opt-in early migration from the deprecating release and runs again in 0.8.0's upgrade with CLN-0025's removal. |
| Compatibility/readiness | Records shipped behavior; no public change. Three implementation gaps, listed under Current-state impact. |
| Compatibility/readiness | Records shipped behavior; `itemKey` is additive. Two implementation gaps, listed under Current-state impact. |
| Review checks | Reject a row that is not an `<li>`, a ListItem-level edge, density, or divider prop, a marker drawn outside a marked List, or a dropped Item prop. |
| Governing rules | `component:Item` (`align` for start and end content); `component:List`; `family:navigation-destinations`; `spec:AST-057`; `spec:AST-103`; `architecture:component-theming-surface`; `architecture:component-style-authoring` INV7. |

Expand Down Expand Up @@ -73,9 +74,6 @@ Consumer migration instructions belong in consumer docs and release notes.
pseudo-element, beside the row's content. `architecture:component-style-authoring`
INV7 carries decoration with no semantic role on a pseudo-element rather than
an added element.
- **ListItem has no `itemKey` yet.** `spec:AST-103` DEC-4 and `component:List`
FR12 have each reorderable row name its item through an `itemKey` prop;
ListItem does not accept one yet.
- **ListItem has no `swipe` yet.** `spec:AST-057` FR1 has ListItem pass
`swipe` through to `Item`, which replaces the deprecated `swipeActions`
and `swipeBehavior` (`spec:AST-057` DEP-0017); `swipe` is not built, so
Expand Down
2 changes: 2 additions & 0 deletions packages/core/api-report.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading