An open source design system that's fully customizable and agent ready
TypeScript
feat(sandbox): motion-lab Table rows preview reads the state token, follows Reduce Motion, and shows no transition (#8616)
Cindy Zhangd5cd551f2ae3
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabDemos.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabDemos.tsxindex b6a2fdd3af..c0ab61df43 100644--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabDemos.tsx+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabDemos.tsx@@ -1043,28 +1043,60 @@ export function LoopRig({policy}: {policy: 'today' | 'delete' | 'degrade'}) {// --- table tint (the 150ms rows) ----------------------------------------------export function TintRig({mode}: {mode: Mode}) {+const TINT_ROWS = [+ ['Quarterly report', 'Draft', '2 min ago'],+ ['Design review', 'Scheduled', '1 h ago'],+ ['Launch checklist', 'In progress', '3 h ago'],+ ['Onboarding flow', 'Shipped', 'Yesterday'],+ ['Pricing page', 'Draft', 'Yesterday'],+ ['Support macros', 'In review', '2 days ago'],+ ['Search ranking', 'Blocked', '3 days ago'],+ ['Release notes', 'Shipped', 'Last week'],+];++/**+ * Table rows' hover tint, over enough rows that sweeping the pointer down the+ * table shows what the duration costs. `before` is Table today (a hardcoded+ * 150ms on the CSS default curve); `after` reads the state token and changes at+ * once under Reduce Motion (design:reduced-motion DR3); `none` deletes the+ * transition, which is the option the rubric asks the preview to make visible.+ */+export function TintRig({mode}: {mode: Mode | 'none'}) {+ const rowClass =+ mode === 'none'+ ? `${styles.tintRow} ${styles.tintRowNone}`+ : mode === 'after'+ ? `${styles.tintRow} ${styles.tintRowToken}`+ : styles.tintRow;return (<VStack gap={1} {...stylex.props(sx.full)}>- {['Row one', 'Row two', 'Row three'].map(row => (- <div- key={row}- className={styles.tintRow}- style={- mode === 'after'- ? {- ['--tint-duration' as string]: 'var(--lab-duration-state)',- ['--tint-ease' as string]: 'var(--ease-state)',- }- : undefined- }>- <Text type="supporting">{row}</Text>- </div>- ))}+ <table className={styles.tintTable}>+ <tbody>+ {TINT_ROWS.map(([name, status, updated]) => (+ <tr key={name} className={rowClass}>+ <td>+ <Text type="supporting">{name}</Text>+ </td>+ <td>+ <Text type="supporting" color="secondary">+ {status}+ </Text>+ </td>+ <td>+ <Text type="supporting" color="secondary">+ {updated}+ </Text>+ </td>+ </tr>+ ))}+ </tbody>+ </table><Hint>{mode === 'before'- ? 'Hardcoded 150ms with the CSS default curve.'- : 'The state token, at 175ms with --ease-state.'}+ ? 'Hardcoded 150ms with the CSS default curve. A literal: no token, rail switch or device setting reaches it, so it fades the same everywhere.'+ : mode === 'after'+ ? 'The state token with --ease-state. When the device asks for reduced motion, the tint changes at once on every rail setting (design:reduced-motion DR3): the colour still says which row is under the pointer.'+ : "No transition at all: the tint is immediate, whatever the rail or the device's reduced-motion setting. Sweep the pointer down the table and compare it with the fades."}</Hint></VStack>);diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionLab.module.css b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionLab.module.cssindex 3e958a7579..81a71ae575 100644--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionLab.module.css+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionLab.module.css@@ -786,7 +786,24 @@/* The Table hover tint, at whatever duration and curve is being argued over.Rows 1-9 of the violation table are this, and the honest finding is that- 150ms and 175ms are near-indistinguishable at 1x. */+ 150ms and 175ms are near-indistinguishable at 1x, which is why the preview+ also shows the tint with no transition at all. */+.tintTable {+ width: 100%;+ /* Three panes share a narrow window: the columns shrink to the pane. */+ table-layout: fixed;+ border-collapse: separate;+ border-spacing: 0;+}++.tintTable td {+ padding: var(--space-2, 6px) var(--space-3, 10px);+ border-bottom: 1px solid var(--color-border);+ overflow-wrap: anywhere;+}++/* Also the "real rule" rows on the Bugs page, which are divs: the padding+ and radius are theirs (a table row ignores both). */.tintRow {padding: var(--space-2, 6px) var(--space-3, 10px);border-radius: var(--radius-sm, 6px);@@ -794,10 +811,31 @@var(--tint-ease, ease);}+/* The hover overlay token Astryx ships (the rig used to read two names no+ theme defines, so the tint never showed). */.tintRow:hover {background-color: var(--color-overlay-hover);}+/* The state token, as Table would read it. */+.tintRowToken {+ transition: background-color var(--lab-duration-state) var(--ease-state);+}++/* Reduce Motion: the tint is a change of state, so with a fine pointer it+ lands at once (design:reduced-motion DR3), and an instant change is also+ within DR2's "200 ms or less" on touch. */+@media (prefers-reduced-motion: reduce) {+ .tintRowToken {+ transition: none;+ }+}++/* Deleting the transition, the option the preview makes visible. */+.tintRowNone {+ transition: none;+}+/* NavItem's hover tint (NavTintRig). Before: as shipped, it snaps on wherethe device hovers. After: it fades on the duration and curve the rig passesin, and only where the device hovers with a fine pointer. */diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/reduced-motion/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/reduced-motion/page.tsxindex 321ce0a5a4..4d39b937b9 100644--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/reduced-motion/page.tsx+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/reduced-motion/page.tsx@@ -379,12 +379,17 @@ export default function ReducedMotionPage() {label: 'Tokenised --duration-state',content: <TintRig mode="after" />,},+ {+ tone: 'neutral',+ label: 'No transition',+ content: <TintRig mode="none" />,+ },]}/><DemoBody><Text type="supporting">Set the rail to <strong>Degrade</strong> and hover: movement stops- across the lab and these rows keep their fade. Colour is not+ across the lab and the tokenised rows keep their fade. Colour is notmovement, and this tint is exactly the feedback degrade exists topreserve — which is why delete is defensible on a hover tint andindefensible on a spinner, where the motion <em>is</em> the message.@@ -395,14 +400,17 @@ export default function ReducedMotionPage() {literal cannot be reached by a switch, a media query or a sweep.</Text><Text type="supporting" color="secondary">- <strong>Try it: </strong>on <strong>Degrade</strong> the right pane- keeps its tint and loses only movement — the state feedback+ <strong>Try it: </strong>on <strong>Degrade</strong> the tokenised+ pane keeps its tint and loses only movement — the state feedbacksurvives. On <strong>Delete</strong> the tint snaps, and theaffordance goes with it. That is the whole decision, in one hover.(This behaviour was itself a bug in the lab until the policy wasmoved out of the stylesheet: the store writes the duration aliasesinline, and an inline custom property outranks any selector, so the- delete rule looked right and did nothing.)+ delete rule looked right and did nothing.) With the device set to+ reduce motion, the tokenised pane changes at once on every rail+ setting (design:reduced-motion DR3); turn that setting off to see+ the rail's policies on it.</Text></DemoBody></DemoCard>diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/violations/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/violations/page.tsxindex 06d056d10e..2a2a6fab6e 100644--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/violations/page.tsx+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/violations/page.tsx@@ -262,6 +262,11 @@ export default function ViolationsPage() {label: 'Proposed — --duration-state, --ease-state',content: <TintRig mode="after" />,},+ {+ tone: 'neutral',+ label: 'No transition',+ content: <TintRig mode="none" />,+ },]}/>)}@@ -294,6 +299,8 @@ export default function ViolationsPage() {between 150 and 175 at all. That it is hard to see at 1×is the honest finding, and it is the argument for treatingthis family as a lint fix rather than a design change.+ With the device set to reduce motion, the tokenised pane+ changes at once at any speed.</Text></>)}