Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

refactor(sandbox): keep the Motion Lab in one folder (#5579)

Ernestc7a6a49af0ec
diff --git a/apps/sandbox/package.json b/apps/sandbox/package.json
index 5894d78815..455e47f33b 100644
--- a/apps/sandbox/package.json
+++ b/apps/sandbox/package.json
@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"build:deps": "pnpm -F @astryxdesign/theme-neutral build && pnpm -F @astryxdesign/theme-matcha build && pnpm -F @astryxdesign/theme-stone build && pnpm -F @astryxdesign/theme-gothic build && pnpm -F @astryxdesign/theme-chocolate build && pnpm -F @astryxdesign/theme-y2k build && pnpm -F @astryxdesign/theme-butter build",
- "generate:motion-audit": "node scripts/generate-motion-audit.mjs",
+ "generate:motion-audit": "node \"src/app/(sandbox)/pages/motion-lab/generate-motion-audit.mjs\"",
"generate:changelog": "node scripts/generate-changelog.js",
"generate:cli": "node scripts/generate-cli-registry.mjs",
"generate:xle": "node scripts/generate-xle-registry.mjs && node scripts/generate-xle-tokenizer.mjs",
diff --git a/apps/sandbox/src/motion/LabDemos.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabDemos.tsx
similarity index 100%
rename from apps/sandbox/src/motion/LabDemos.tsx
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabDemos.tsx
diff --git a/apps/sandbox/src/motion/LabPrimitives.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabPrimitives.tsx
similarity index 100%
rename from apps/sandbox/src/motion/LabPrimitives.tsx
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabPrimitives.tsx
diff --git a/apps/sandbox/src/motion/MotionControlRail.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionControlRail.tsx
similarity index 100%
rename from apps/sandbox/src/motion/MotionControlRail.tsx
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionControlRail.tsx
diff --git a/apps/sandbox/src/motion/MotionLab.module.css b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionLab.module.css
similarity index 100%
rename from apps/sandbox/src/motion/MotionLab.module.css
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionLab.module.css
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionLabShell.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionLabShell.tsx
new file mode 100644
index 0000000000..73300575ab
--- /dev/null
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionLabShell.tsx
@@ -0,0 +1,129 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+/**
+ * @file MotionLabShell.tsx
+ * @input Motion Lab store, control rail, section registry
+ * @output The scope element, the lab's own nav panel, and the control rail
+ * @position Motion Lab chrome; used by the section layout
+ *
+ * Two jobs.
+ *
+ * The scope element is where the tuned custom properties land. Keeping them
+ * here rather than on `:root` means the lab can retune `--ease-standard` to
+ * argue about it without the sandbox's own chrome starting to move differently.
+ *
+ * The nav panel is here because the sandbox frames a tool as one entry in its
+ * catalog — there is no per-tool rail to hang fifteen pages off, so without one
+ * every page is a dead end. A start panel is the house pattern for it
+ * (`LayoutPanelNavigation`), and it groups the pages the way the registry does,
+ * which is the order they are meant to be read in.
+ */
+
+import {usePathname} from 'next/navigation';
+import {useEffect, useRef, type ReactNode} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import {
+ Layout,
+ LayoutContent,
+ LayoutPanel,
+ VStack,
+} from '@astryxdesign/core/Layout';
+import {List, ListItem} from '@astryxdesign/core/List';
+import {Text} from '@astryxdesign/core/Text';
+import {useMotionLab} from './MotionLabStore';
+import {MotionControlRail} from './MotionControlRail';
+import {MOTION_SECTIONS} from './sections';
+import styles from './MotionLab.module.css';
+
+const sx = stylex.create({
+ scope: {width: '100%'},
+ panel: {
+ // The panel scrolls independently: fifteen items plus their group headings
+ // outrun a short viewport, and the page beside it is long.
+ height: '100%',
+ overflowY: 'auto',
+ },
+ groupLabel: {
+ paddingInlineStart: '10px',
+ paddingBlockStart: '10px',
+ paddingBlockEnd: '2px',
+ },
+ firstGroupLabel: {
+ paddingBlockStart: '2px',
+ },
+});
+
+/** The export sets `trailingSlash: true`, so normalise before comparing. */
+function isCurrent(pathname: string, href: string): boolean {
+ const a = pathname.endsWith('/') ? pathname : `${pathname}/`;
+ const b = href.endsWith('/') ? href : `${href}/`;
+ return a === b;
+}
+
+function LabNav() {
+ const pathname = usePathname();
+ const groups = [...new Set(MOTION_SECTIONS.map(s => s.group))];
+
+ return (
+ <nav aria-label="Motion Lab pages" {...stylex.props(sx.panel)}>
+ {groups.map((group, i) => (
+ <div key={group}>
+ <Text
+ type="supporting"
+ color="secondary"
+ weight="semibold"
+ {...stylex.props(sx.groupLabel, i === 0 && sx.firstGroupLabel)}>
+ {group}
+ </Text>
+ <List density="compact">
+ {MOTION_SECTIONS.filter(s => s.group === group).map(section => (
+ <ListItem
+ key={section.href}
+ label={section.title}
+ href={section.href}
+ isSelected={isCurrent(pathname, section.href)}
+ />
+ ))}
+ </List>
+ </div>
+ ))}
+ </nav>
+ );
+}
+
+export function MotionLabShell({children}: {children: ReactNode}) {
+ const {registerScope, reducedMotion} = useMotionLab();
+ const ref = useRef<HTMLDivElement | null>(null);
+
+ useEffect(() => {
+ registerScope(ref.current);
+ return () => registerScope(null);
+ }, [registerScope]);
+
+ return (
+ <div
+ ref={ref}
+ className={styles.scope}
+ data-reduced-motion={reducedMotion}
+ {...stylex.props(sx.scope)}>
+ <Layout
+ height="fill"
+ start={
+ <LayoutPanel hasDivider width={228} padding={0} role="navigation">
+ <LabNav />
+ </LayoutPanel>
+ }
+ content={
+ <LayoutContent padding={0}>
+ <VStack gap={0}>
+ <MotionControlRail />
+ {children}
+ </VStack>
+ </LayoutContent>
+ }
+ />
+ </div>
+ );
+}
diff --git a/apps/sandbox/src/motion/MotionLabStore.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionLabStore.tsx
similarity index 100%
rename from apps/sandbox/src/motion/MotionLabStore.tsx
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionLabStore.tsx
diff --git a/apps/sandbox/src/motion/PageFrame.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/PageFrame.tsx
similarity index 100%
rename from apps/sandbox/src/motion/PageFrame.tsx
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/PageFrame.tsx
diff --git a/apps/sandbox/src/motion/__generated__/motionAudit.ts b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/__generated__/motionAudit.ts
similarity index 99%
rename from apps/sandbox/src/motion/__generated__/motionAudit.ts
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/__generated__/motionAudit.ts
index 70cf49cbf1..1cd04703a5 100644
--- a/apps/sandbox/src/motion/__generated__/motionAudit.ts
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/__generated__/motionAudit.ts
@@ -558,7 +558,7 @@ export const HARDCODED_SITES: ReadonlyArray<HardcodedSite> = [
file: 'core/Table/plugins/groupedRows/useTableGroupedRows.tsx',
package: 'core',
component: 'Table',
- line: 163,
+ line: 179,
kind: 'duration',
prop: 'transitionDuration',
value: '150ms',
@@ -707,7 +707,7 @@ export const DURATION_WITHOUT_CURVE: ReadonlyArray<SiteRef> = [
file: 'core/Table/plugins/groupedRows/useTableGroupedRows.tsx',
package: 'core',
component: 'Table',
- line: 161,
+ line: 177,
decl: "transitionDuration: '150ms'",
},
{
@@ -899,7 +899,7 @@ export const TRANSFORM_TRANSITIONS: ReadonlyArray<SiteRef> = [
file: 'core/Table/plugins/groupedRows/useTableGroupedRows.tsx',
package: 'core',
component: 'Table',
- line: 162,
+ line: 178,
decl: "transitionProperty: 'transform'",
},
{
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/bugs/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/bugs/page.tsx
index 5bd0022420..137c8f8326 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/bugs/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/bugs/page.tsx
@@ -1,10 +1,756 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's bugs page.
+ * @file page.tsx
+ * @input The generated audit, the installed core source, the lab store
+ * @output Which structural findings survive contact with the code
+ * @position /motion/bugs
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * Of the four structural findings, one is real and underplayed, one is a
+ * misreading of three components, one is correct code the scanner flags, and
+ * one cannot be verified in this app at all. Every claim here is checked
+ * against the installed package and cited file:line, including the places
+ * where the generated audit was itself wrong.
*/
-export {default} from '../../../../../motion/pages/bugs';
+import {useCallback, useEffect, useRef, useState} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Card} from '@astryxdesign/core/Card';
+import {CodeBlock} from '@astryxdesign/core/CodeBlock';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Switch} from '@astryxdesign/core/Switch';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import {LabPage} from '../PageFrame';
+import {
+ ComparePanes,
+ DemoBody,
+ DemoCard,
+ LabSlider,
+ Runner,
+ useLoop,
+} from '../LabPrimitives';
+import {useMotionLab} from '../MotionLabStore';
+import {
+ AUDIT_COUNTS,
+ DURATION_WITHOUT_CURVE,
+ NOOP_TRANSITIONS,
+ TIMEOUT_LITERALS,
+ TRANSFORM_TRANSITIONS,
+ TRANSITION_ALL,
+} from '../__generated__/motionAudit';
+import styles from '../MotionLab.module.css';
+
+const sx = stylex.create({
+ full: {width: '100%'},
+ mono: {fontFamily: 'var(--font-family-code)', fontSize: '12px'},
+ rows: {width: '100%'},
+ readout: {
+ fontFamily: 'var(--font-family-code)',
+ fontSize: '13px',
+ },
+ drawerBack: {padding: '14px', maxWidth: '34%'},
+});
+
+/** The rotation rule the brief reads as dead, verbatim from the package. */
+const SELECTOR_SOURCE = `// Rotation lives on the chevron glyph itself (passed through \`xstyle\`), not
+// on the layout wrapper above, so the icon's \`selector-indicator-icon\` theme
+// target and the open/closed transform sit on one element — a theme can
+// restyle the mark and its rotation through a single selector. The wrapper
+// keeps only layout. The status branch renders a different icon, so it never
+// picks these up and needs no transition opt-out.
+triggerIconRotation: {
+ transitionProperty: 'transform',
+ transitionDuration: durationVars['--duration-fast'],
+ transitionTimingFunction: easeVars['--ease-standard'],
+ transformOrigin: 'center',
+},
+triggerIconOpen: {
+ transform: 'rotate(180deg)',
+},`;
+
+const LIGHTBOX_SOURCE = `image: {
+ maxWidth: '100%',
+ maxHeight: '100%',
+ objectFit: 'contain',
+ pointerEvents: 'none',
+ transitionProperty: 'transform',
+ transitionDuration: {
+ default: '200ms',
+ '@media (prefers-reduced-motion: reduce)': '0ms',
+ },
+ transitionTimingFunction: 'ease-out',
+},
+imageDragging: {
+ transitionProperty: 'none',
+},
+
+// ...applied only while the pointer is down, Lightbox.tsx:691
+isDragging && styles.imageDragging,`;
+
+const TIMER_FIX = `// What the brief describes: a literal that has to be kept in sync by hand.
+setTimeout(() => setMounted(false), 250);
+
+// What removes the class of bug: the element says when it is done.
+const panel = panelRef.current;
+if (panel == null) {
+ setMounted(false);
+ return;
+}
+Promise.allSettled(panel.getAnimations().map(a => a.finished)).then(() =>
+ setMounted(false),
+);
+
+// The transitionend form, for a single known property. Note the guard: a
+// bubbling transitionend from a child would unmount the panel early, and a
+// zero duration fires nothing at all — which is why --duration-instant
+// cannot simply be 0.
+panel.addEventListener('transitionend', event => {
+ if (event.target === panel && event.propertyName === 'transform') {
+ setMounted(false);
+ }
+});`;
+
+const INSTANT_DWC = DURATION_WITHOUT_CURVE.filter(
+ site => site.decl?.includes('0.01s') === true,
+);
+const SUBSTANTIVE_DWC = DURATION_WITHOUT_CURVE.filter(
+ site => site.decl?.includes('0.01s') !== true,
+);
+const SUBSTANTIVE_DWC_COMPONENTS = [
+ ...new Set(SUBSTANTIVE_DWC.map(site => site.component)),
+].sort();
+
+/** transform declared inside a longer property list, which a grep never finds. */
+const MULTI_PROPERTY_TRANSFORMS = TRANSFORM_TRANSITIONS.filter(
+ site => site.decl?.includes(',') === true,
+);
+const SINGLE_PROPERTY_TRANSFORMS =
+ TRANSFORM_TRANSITIONS.length - MULTI_PROPERTY_TRANSFORMS.length;
+/** ...and the ones that also animate a layout property, which is criterion 6. */
+const LAYOUT_MIXED_TRANSFORMS = MULTI_PROPERTY_TRANSFORMS.filter(site =>
+ /width|height|top|left|margin|padding|inset/.test(site.decl ?? ''),
+);
+
+const LINT_MAP: ReadonlyArray<{
+ readonly finding: string;
+ readonly rule: string;
+ readonly status: string;
+}> = [
+ {
+ finding: 'A duration with no declared curve',
+ rule: 'require-timing-function — a transitionDuration in a rule with no transitionTimingFunction and no shorthand.',
+ status: `${AUDIT_COUNTS.durationWithoutCurve} sites today, ${SUBSTANTIVE_DWC.length} of them substantive.`,
+ },
+ {
+ finding: 'A transitionProperty with no duration',
+ rule: "no-noop-transition — same shape, inverted. Must exempt transitionProperty: 'none', which is a deliberate opt-out.",
+ status: `${AUDIT_COUNTS.noopTransitions} site today, and it is the exemption case.`,
+ },
+ {
+ finding: 'transition: all',
+ rule: 'no-transition-all — a property list containing all.',
+ status: `${TRANSITION_ALL.length} today. Pure regression guard.`,
+ },
+ {
+ finding: 'A hardcoded duration, delay or curve',
+ rule: 'motion-tokens-only — any time literal or bezier literal outside the token file.',
+ status: `${AUDIT_COUNTS.hardcodedTotal} today. Needs an allowlist for the reduced-motion escape.`,
+ },
+ {
+ finding: 'A timer literal standing in for a transition',
+ rule: 'no-animation-timeout — a setTimeout whose literal matches a duration token value, inside a component that transitions.',
+ status: `${TIMEOUT_LITERALS.length} literal timer in core, and it is unrelated to motion.`,
+ },
+ {
+ finding: 'A CSS transition on transform',
+ rule: 'no-transform-transition — criterion 12, the motion-library blocker.',
+ status: `${AUDIT_COUNTS.transformTransitions} sites across ${AUDIT_COUNTS.transformTransitionComponents} components — criterion 12's entire caseload.`,
+ },
+];
+
+/** Rows carrying the no-op rule, beside rows carrying a real one. */
+function Rows({variant}: {variant: 'noop' | 'tint'}) {
+ return (
+ <VStack gap={1} {...stylex.props(sx.rows)}>
+ {['Row one', 'Row two', 'Row three'].map(row => (
+ // The CSS module owns both rules: the point of the pane is the
+ // declaration itself, so it has to be the real one.
+ <div
+ key={row}
+ className={variant === 'noop' ? styles.noopRow : styles.tintRow}>
+ <Text type="supporting">{row}</Text>
+ </div>
+ ))}
+ </VStack>
+ );
+}
+
+/**
+ * The unmount timer racing the slide. Both sliders are live and both tracks
+ * run in real time, because the finding is a relationship between two numbers
+ * rather than either number on its own.
+ */
+function DrawerCutDemo() {
+ const {speed} = useMotionLab();
+ const [slideMs, setSlideMs] = useState(410);
+ const [timerMs, setTimerMs] = useState(250);
+ const [derived, setDerived] = useState(false);
+ const [open, setOpen] = useState(true);
+ const [cut, setCut] = useState(false);
+
+ const slideFill = useRef<HTMLSpanElement | null>(null);
+ const timerFill = useRef<HTMLSpanElement | null>(null);
+ const raf = useRef<number | null>(null);
+ const timers = useRef<Array<number>>([]);
+
+ const effectiveTimer = derived ? slideMs : timerMs;
+ const slideRun = slideMs * speed;
+ const timerRun = effectiveTimer * speed;
+ const completed = Math.min(100, (effectiveTimer / slideMs) * 100);
+
+ const clear = useCallback(() => {
+ for (const id of timers.current) {
+ window.clearTimeout(id);
+ }
+ timers.current = [];
+ if (raf.current != null) {
+ cancelAnimationFrame(raf.current);
+ raf.current = null;
+ }
+ }, []);
+
+ const play = useCallback(() => {
+ clear();
+ setCut(false);
+ setOpen(true);
+ if (slideFill.current != null) {
+ slideFill.current.style.width = '0%';
+ }
+ if (timerFill.current != null) {
+ timerFill.current.style.width = '0%';
+ }
+ timers.current.push(
+ window.setTimeout(() => {
+ setOpen(false);
+ const start = performance.now();
+ const span = Math.max(slideRun, timerRun);
+ const step = (now: number) => {
+ const elapsed = now - start;
+ if (slideFill.current != null) {
+ slideFill.current.style.width = `${Math.min(100, (elapsed / slideRun) * 100)}%`;
+ }
+ if (timerFill.current != null) {
+ timerFill.current.style.width = `${Math.min(100, (elapsed / timerRun) * 100)}%`;
+ }
+ if (elapsed < span) {
+ raf.current = requestAnimationFrame(step);
+ }
+ };
+ raf.current = requestAnimationFrame(step);
+ timers.current.push(window.setTimeout(() => setCut(true), timerRun));
+ }, 700),
+ );
+ }, [clear, slideRun, timerRun]);
+
+ useEffect(() => clear, [clear]);
+ useLoop(play, Math.max(2600, slideRun + timerRun + 1400));
+
+ return (
+ <VStack gap={3} {...stylex.props(sx.full)}>
+ <div className={`${styles.stage} ${styles.stageBlock}`}>
+ <VStack gap={1} {...stylex.props(sx.drawerBack)}>
+ <Text type="supporting" color="secondary">
+ Page behind
+ </Text>
+ </VStack>
+ {/* The transition, the visibility hand-off and the cut are all in the
+ CSS module: a style object cannot express the [data-open] pair. */}
+ <div
+ data-open={open}
+ style={{['--drawer-slide' as string]: `${slideRun}ms`}}
+ className={
+ cut ? `${styles.drawer} ${styles.drawerCut}` : styles.drawer
+ }>
+ <VStack gap={1}>
+ <Text weight="semibold">Drawer</Text>
+ <Text type="supporting" color="secondary">
+ Slides on --ease-drawer. Removed by a timer that does not know
+ about it.
+ </Text>
+ </VStack>
+ </div>
+ </div>
+
+ <Grid columns={{minWidth: 260}} gap={3}>
+ <VStack gap={1}>
+ <Text type="supporting" weight="semibold">
+ Slide — {slideMs}ms
+ </Text>
+ <span className={styles.track}>
+ <span
+ ref={slideFill}
+ className={`${styles.trackFill} ${styles.trackSlide}`}
+ />
+ </span>
+ </VStack>
+ <VStack gap={1}>
+ <Text type="supporting" weight="semibold">
+ Unmount timer — {effectiveTimer}ms
+ </Text>
+ <span className={styles.track}>
+ <span
+ ref={timerFill}
+ className={`${styles.trackFill} ${styles.trackTimer}`}
+ />
+ </span>
+ </VStack>
+ </Grid>
+
+ <Text {...stylex.props(sx.readout)}>
+ {completed >= 100
+ ? 'The panel survives its whole exit — 100% of the slide runs.'
+ : `The panel is removed at ${Math.round(completed)}% of its travel. ${Math.round(
+ 100 - completed,
+ )}% of the exit never runs.`}
+ </Text>
+
+ <LabSlider
+ label="Slide duration"
+ value={slideMs}
+ min={150}
+ max={800}
+ step={10}
+ format={v => `${v}ms`}
+ onChange={setSlideMs}
+ />
+ <LabSlider
+ label="Unmount timer"
+ value={timerMs}
+ min={50}
+ max={800}
+ step={10}
+ format={v => `${v}ms`}
+ onChange={setTimerMs}
+ />
+ <Switch
+ label="Derive the timer from the transition"
+ description="What the fix does: the panel unmounts when its own animation finishes, so the two numbers cannot drift apart."
+ value={derived}
+ onChange={setDerived}
+ />
+ </VStack>
+ );
+}
+
+export default function MotionBugsPage() {
+ const noop = NOOP_TRANSITIONS[0];
+
+ return (
+ <LabPage
+ title="Small bugs"
+ intro="Four structural findings in the brief. One is real and underplayed, one is a misreading of three components, one is correct code the scanner flags, and one cannot be verified in this app at all."
+ badges={<Badge variant="warning" label="1 of 4 survives as written" />}
+ decides="Which of the structural findings are real once you look at the code.">
+ <Banner
+ status="warning"
+ title="The three dead no-op transitions are not there"
+ description={
+ <Text>
+ The brief lists three dead no-op transitions in Selector,
+ ComplexSelector and MultiSelector. All three rules exist, and all
+ three carry a tokenised duration
+ <em> and </em> a tokenised curve. The audit finds exactly one no-op
+ in the whole package —{' '}
+ <code>
+ {noop?.file}:{noop?.line}
+ </code>{' '}
+ — and it is a deliberate{' '}
+ <code>transitionProperty: &lsquo;none&rsquo;</code> that turns a
+ transition off during a drag. Correct code, flagged by a scanner.
+ </Text>
+ }
+ />
+
+ <DemoCard
+ title="The three that are not dead"
+ question="Selector, ComplexSelector and MultiSelector all declare the same rotation rule. Is anything missing from it?"
+ badges={<Badge variant="success" label="No finding" />}>
+ <DemoBody>
+ <CodeBlock
+ language="tsx"
+ title="Selector/Selector.tsx:201-214 — identical at ComplexSelector.tsx:154-166 and MultiSelector.tsx:178-191"
+ code={SELECTOR_SOURCE}
+ hasCopyButton
+ maxHeight={340}
+ />
+ <Text type="supporting">
+ Property, duration and curve, all three tokenised, paired with{' '}
+ <code>triggerIconOpen</code> which supplies the transform. There is
+ nothing dead here.
+ </Text>
+ <Text type="supporting" color="secondary">
+ The misreading is easy to make and the source explains it: the
+ rotation was moved off the layout wrapper and onto the chevron
+ glyph, which receives it through <code>xstyle</code>. Read the
+ wrapper and you see a component that rotates something with no
+ transition anywhere near it. Worth re-checking before it becomes a
+ milestone line item — it is currently costed as three fixes that do
+ not exist.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="The one real no-op is correct"
+ question={`${noop?.file}:${noop?.line} — a transitionProperty with no duration. Bug, or opt-out?`}
+ badges={<Badge variant="success" label="Working as intended" />}>
+ <DemoBody>
+ <CodeBlock
+ language="tsx"
+ title="Lightbox/Lightbox.tsx:180-194, applied at :691"
+ code={LIGHTBOX_SOURCE}
+ hasCopyButton
+ maxHeight={380}
+ />
+ <Text type="supporting">
+ The zoomed image transitions <code>transform</code> over 200ms so a
+ zoom step glides. While the pointer is down,{' '}
+ <code>imageDragging</code> replaces that with{' '}
+ <code>transitionProperty: &lsquo;none&rsquo;</code>, so the image
+ tracks the pointer 1:1 instead of easing 200ms behind it. Removing
+ it would make dragging feel like dragging through syrup.
+ </Text>
+ <Text type="supporting" color="secondary">
+ The audit is right that the shape is a no-op and wrong that it is a
+ defect. The lint rule needs the exemption written in from the start:{' '}
+ <code>none</code> is the only value of{' '}
+ <code>transitionProperty</code> that legitimately appears without a
+ duration.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="Why the shape is still worth linting"
+ question="Both panes declare a transition. Only one of them animates. Which is which, at a glance in review?"
+ actions={<Badge variant="neutral" label="Hover the rows" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label:
+ 'transitionProperty, no duration — reads like motion, does nothing',
+ content: <Rows variant="noop" />,
+ },
+ {
+ tone: 'after',
+ label: 'The same rule with a duration and a curve',
+ content: <Rows variant="tint" />,
+ },
+ ]}
+ />
+ <DemoBody>
+ <Text type="supporting" color="secondary">
+ This is the argument for the rule even though the package has one
+ instance and it is exempt: the failure is invisible in review. A
+ reviewer sees the word <code>transition</code> and moves on, and the
+ component ships with a state change that snaps.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title={`${AUDIT_COUNTS.durationWithoutCurve} durations with no declared curve`}
+ question="A duration with no timing function silently gets the CSS default, which is ease — not --ease-standard. How different are they?"
+ badges={
+ <Badge variant="warning" label="The largest structural finding" />
+ }>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'ease — what these sites actually run',
+ content: (
+ <Runner
+ durationToken="--duration-reveal"
+ easeToken="--ease-state"
+ />
+ ),
+ },
+ {
+ tone: 'after',
+ label: '--ease-standard — the curve core ships',
+ content: (
+ <Runner
+ durationToken="--duration-reveal"
+ easeToken="--ease-standard-today"
+ />
+ ),
+ },
+ ]}
+ />
+ <DemoBody>
+ <Text type="supporting">
+ <code>ease</code> is <code>cubic-bezier(0.25, 0.1, 0.25, 1)</code> —
+ a gentle symmetrical curve. <code>--ease-standard</code> is{' '}
+ <code>cubic-bezier(0.24, 1, 0.4, 1)</code>, which leaves immediately
+ and decelerates hard. Every site below is running the first one
+ while its neighbours run the second, and nobody wrote that decision
+ down.
+ </Text>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Site</TableHeaderCell>
+ <TableHeaderCell>Declaration</TableHeaderCell>
+ <TableHeaderCell>Reading</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {DURATION_WITHOUT_CURVE.map(site => {
+ const instant = site.decl?.includes('0.01s') === true;
+ return (
+ <TableRow key={`${site.file}:${site.line}`}>
+ <TableCell>
+ <Text
+ {...stylex.props(
+ sx.mono,
+ )}>{`${site.file}:${site.line}`}</Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {site.decl}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {instant
+ ? 'Reduced-motion escape — the curve is irrelevant at 10ms'
+ : 'Substantive: a real duration silently taking the CSS default'}
+ </Text>
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ </TableBody>
+ </Table>
+ </Card>
+ <Text type="supporting">
+ {SUBSTANTIVE_DWC.length} of the {AUDIT_COUNTS.durationWithoutCurve}{' '}
+ are substantive — a real duration silently taking <code>ease</code>{' '}
+ — across {SUBSTANTIVE_DWC_COMPONENTS.join(', ')}. Only{' '}
+ {INSTANT_DWC.length} is the <code>0.01s</code> escape, where having
+ no curve is the right answer. The brief underplays this finding, and
+ the figure has already moved twice as the scanner improved: read it
+ out of the audit rather than quoting it.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="The drawer exit, cut short"
+ question="Slide 410ms, unmount at 250ms. Drag either slider: at what point does an exit stop being an exit?"
+ badges={<Badge variant="error" label="Confirmed in lab" />}>
+ <DemoBody>
+ <Text type="supporting">
+ <strong>The brief is right, to the millisecond.</strong>{' '}
+ <code>lab/Drawer/Drawer.tsx:459</code> hardcodes a <code>250</code>
+ ms close timer, while <code>:157</code> and <code>:219</code> set
+ the panel and scrim transitions to <code>--duration-medium</code> —
+ 410ms. The dialog is closed at 61% of its own travel, so the last
+ 160ms of the slide never renders.
+ </Text>
+ <Text type="supporting" color="secondary">
+ The reduced-motion branch beside it is the tell: the same expression
+ picks <code>10</code>ms when the user asks for less motion, which
+ means someone thought carefully about the timer and still had to
+ restate the duration by hand. Nothing in either package derives a
+ timer from its transition; MobileNav is the only component that even
+ tries, and it does it by reading <code>getComputedStyle</code>. That
+ is the argument for the JS token mirror in one file.
+ </Text>
+ </DemoBody>
+ <DemoBody>
+ <DrawerCutDemo />
+ </DemoBody>
+ <DemoBody>
+ <CodeBlock
+ language="tsx"
+ title="The class of bug, and the two ways out of it"
+ code={TIMER_FIX}
+ hasCopyButton
+ maxHeight={420}
+ />
+ <Text type="supporting" color="secondary">
+ The bug is not the number 250. It is that two numbers have to agree
+ and only one of them is a token: retune{' '}
+ <code>--duration-overlay</code> and the timer keeps its old value,
+ so the cut appears in a diff that never touched the drawer.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="transition: all"
+ question={`${TRANSITION_ALL.length} sites. Is a rule with nothing to fix worth writing?`}
+ badges={
+ <Badge variant="success" label={`${TRANSITION_ALL.length} today`} />
+ }>
+ <DemoBody>
+ <Text type="supporting">
+ Yes, and it is the cheapest rule in the set.{' '}
+ <code>transition: all</code> animates every property that ever
+ changes, including layout properties nobody intended to animate, and
+ it arrives in a codebase one careless line at a time. Core is clean
+ today; the rule keeps it clean and costs one regex.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <VStack gap={3}>
+ <Heading level={2}>
+ The count moved twice, and the brief was right
+ </Heading>
+ <Text color="secondary">
+ Every structural number on this page is a scanner output, so what the
+ scanner can see decides what gets scheduled. This section started as a
+ grep run against a generated count that looked too small; the
+ generator has since been fixed twice, and criterion 12&rsquo;s
+ caseload went from something smaller than the brief&rsquo;s estimate
+ to something larger than it.
+ </Text>
+ <Grid columns={{minWidth: 300}} gap={3}>
+ <Card padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">A scanner sees shape, not intent</Text>
+ <Text type="supporting" color="secondary">
+ The one no-op it reports is the Lightbox drag opt-out above:
+ correct code with the shape of a defect. Every rule the lint
+ gains has to carry its exemptions from the start, or the first
+ thing it produces is work that ends in &ldquo;working as
+ intended&rdquo;.
+ </Text>
+ </VStack>
+ </Card>
+ <Card padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">A grep sees less than a scanner</Text>
+ <Text type="supporting" color="secondary">
+ {SINGLE_PROPERTY_TRANSFORMS} of the{' '}
+ {TRANSFORM_TRANSITIONS.length} transform transitions declare{' '}
+ <code>transform</code> on its own.{' '}
+ {MULTI_PROPERTY_TRANSFORMS.length} declare it inside a longer
+ property list, where a search for{' '}
+ <code>transitionProperty: &lsquo;transform&rsquo;</code> never
+ finds them — which is how one repository yields three different
+ counts depending on who counted.
+ </Text>
+ </VStack>
+ </Card>
+ </Grid>
+ <Text color="secondary">
+ The multi-property declarations are the interesting half: criterion 12
+ findings like the rest, and {LAYOUT_MIXED_TRANSFORMS.length} of them
+ criterion 6 findings as well, because they animate a layout property
+ in the same breath as a compositor one.
+ </Text>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Site</TableHeaderCell>
+ <TableHeaderCell>Declaration</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {MULTI_PROPERTY_TRANSFORMS.map(site => (
+ <TableRow key={`${site.file}:${site.line}`}>
+ <TableCell>
+ <Text
+ {...stylex.props(
+ sx.mono,
+ )}>{`${site.file}:${site.line}`}</Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {site.decl}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ <HStack gap={2} wrap="wrap">
+ <Badge
+ variant="success"
+ label={`Audit, fixed: ${AUDIT_COUNTS.transformTransitions} sites / ${AUDIT_COUNTS.transformTransitionComponents} components`}
+ />
+ <Badge variant="neutral" label="Brief: 20+ components" />
+ </HStack>
+ <Text type="supporting" color="secondary">
+ This page found the discrepancy by grepping when the generated number
+ looked too small, and the generator has since been fixed twice: once
+ so a value that wraps onto its own line is still read, and once so a
+ rule containing nested per-state objects is still scanned. Both bugs
+ hid matches, and both made the brief look wrong when it was right. The
+ lasting fix is a parser rather than a regex — a StyleX rule is a
+ TypeScript object literal and can be read as one — but the habit
+ matters more than the tool: when a generated count disagrees with
+ someone who has read the code, check the generator first.
+ </Text>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>What would have caught each of these</Heading>
+ <Card padding={0}>
+ <Table density="balanced">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Finding</TableHeaderCell>
+ <TableHeaderCell>Lint rule</TableHeaderCell>
+ <TableHeaderCell>Caseload today</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {LINT_MAP.map(row => (
+ <TableRow key={row.finding}>
+ <TableCell>
+ <Text weight="semibold">{row.finding}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting">{row.rule}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {row.status}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ <Text type="supporting" color="secondary">
+ Five of the six are mechanical. The sixth — a timer standing in for a
+ transition — is the only one that needs a heuristic, and it is the
+ only one of the six that describes a bug a user would notice.
+ </Text>
+ </VStack>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/exit-gap/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/exit-gap/page.tsx
index 357c4076d1..6c6b5be1ef 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/exit-gap/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/exit-gap/page.tsx
@@ -1,10 +1,331 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's exit-gap page.
+ * @file page.tsx
+ * @input LabDemos rigs, published guidance, the lab store
+ * @output The exit-gap argument, with both documents on screen
+ * @position /motion/exit-gap
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * The brief calls this the single highest-leverage fix in the audit. It is
+ * also the one place where the thing being called a defect is the published
+ * guidance, so the page leads with that rather than burying it.
*/
-export {default} from '../../../../../motion/pages/exit-gap';
+import * as stylex from '@stylexjs/stylex';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Card} from '@astryxdesign/core/Card';
+import {CodeBlock} from '@astryxdesign/core/CodeBlock';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Link} from '@astryxdesign/core/Link';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {LabPage} from '../PageFrame';
+import {ComparePanes, DemoBody, DemoCard, TokenSlider} from '../LabPrimitives';
+import {DialogRig, LayerRig, NativePopoverProbe} from '../LabDemos';
+import {GUIDANCE_CONFLICTS} from '../publishedGuidance';
+
+const sx = stylex.create({
+ full: {width: '100%'},
+ quote: {
+ borderInlineStart: '2px solid var(--color-border)',
+ paddingInlineStart: '12px',
+ maxWidth: '62ch',
+ },
+});
+
+/** The eleven, as the brief lists them, plus the dialog family. */
+const LAYER_CONSUMERS = [
+ 'Tooltip',
+ 'HoverCard',
+ 'Popover',
+ 'DropdownMenu',
+ 'ContextMenu',
+ 'Selector',
+ 'ComplexSelector',
+ 'PowerSearch',
+ 'Typeahead',
+ 'MoreMenu',
+ 'Breadcrumbs overflow',
+];
+
+const RIGS = [
+ {
+ title: 'Tooltip',
+ subtitle: 'useLayer · highest-frequency surface in the system',
+ triggerLabel: 'Hover me',
+ trigger: 'hover' as const,
+ origin: 'top center',
+ question:
+ 'The published page names tooltips specifically as a surface that may vanish. Does the exit earn its 175ms here, on something seen hundreds of times a day?',
+ },
+ {
+ title: 'HoverCard',
+ subtitle: 'useLayer · the most visible instance of the gap',
+ triggerLabel: 'Hover a name',
+ trigger: 'hover' as const,
+ origin: 'top left',
+ question:
+ 'A larger surface travelling the same distance. Judge the scale-from value here rather than on Tooltip — 0.96 reads differently at size.',
+ },
+ {
+ title: 'Popover',
+ subtitle: 'useLayer',
+ triggerLabel: 'Click me',
+ trigger: 'click' as const,
+ origin: 'top left',
+ question:
+ 'Click twice quickly. The exit has to retarget rather than restart, or rapid dismissal looks broken.',
+ },
+ {
+ title: 'DropdownMenu',
+ subtitle: 'useLayer · submenus too',
+ triggerLabel: 'Open menu',
+ trigger: 'click' as const,
+ origin: 'top left',
+ question:
+ 'A menu snapping shut is the case people notice. Does the exit help, or does it just delay the next click?',
+ },
+];
+
+export default function ExitGapPage() {
+ const conflict = GUIDANCE_CONFLICTS.find(c => c.id === 'exit-optional');
+ const blocking = GUIDANCE_CONFLICTS.find(c => c.id === 'blocking');
+
+ return (
+ <LabPage
+ title="The exit gap"
+ intro="Eleven components animate in and vanish out — every surface built on useLayer, plus Dialog, AlertDialog and CommandPalette. One change to layerAnimations and useLayer would give all eleven a dismissal animation, which is why the brief calls it the highest-leverage fix in the audit."
+ decides="Whether presence surfaces should animate out at all, and what enter and exit cost."
+ badges={
+ <Badge variant="warning" label="conflicts with the published page" />
+ }>
+ {conflict != null && (
+ <Banner
+ status="warning"
+ title="This is not drift — it is the published guidance, correctly followed"
+ description={
+ <VStack gap={2}>
+ <Text {...stylex.props(sx.quote)}>
+ <em>&ldquo;{conflict.published}&rdquo;</em>
+ </Text>
+ <Text>
+ {conflict.reading} Before any of this is scheduled, decide which
+ document is right. If the proposal wins, the rewrite of that
+ paragraph ships in the same stack as the{' '}
+ <code>layerAnimations</code> change — otherwise the rubric
+ starts failing components for doing exactly what the docs still
+ instruct.
+ </Text>
+ </VStack>
+ }
+ endContent={
+ <Link href="/pages/motion-lab/published/">All conflicts</Link>
+ }
+ />
+ )}
+
+ <DemoCard
+ title="Tune the presence budget"
+ question="These two values drive every pane on this page, and every layer demo in the lab.">
+ <DemoBody>
+ <TokenSlider token="--duration-enter" label="enter" max={600} />
+ <TokenSlider token="--duration-exit" label="exit" max={600} />
+ <TokenSlider token="--duration-overlay" label="overlay" max={900} />
+ <Text type="supporting" color="secondary">
+ Exit is deliberately shorter than enter, because old content should
+ leave faster than new content arrives. Drag them equal and a
+ dismissal starts to feel sticky.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ {RIGS.map(rig => (
+ <DemoCard
+ key={rig.title}
+ title={rig.title}
+ question={rig.question}
+ badges={<Badge label={rig.subtitle} />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — animates in, vanishes out',
+ content: (
+ <LayerRig
+ mode="before"
+ label={rig.title}
+ triggerLabel={rig.triggerLabel}
+ trigger={rig.trigger}
+ origin={rig.origin}
+ />
+ ),
+ },
+ {
+ tone: 'after',
+ label: 'Proposed — the exit retraces the entry',
+ content: (
+ <LayerRig
+ mode="after"
+ label={rig.title}
+ triggerLabel={rig.triggerLabel}
+ trigger={rig.trigger}
+ origin={rig.origin}
+ />
+ ),
+ },
+ ]}
+ />
+ </DemoCard>
+ ))}
+
+ <DemoCard
+ title="Dialog, AlertDialog, CommandPalette"
+ question="Two separate bugs in one surface: the panel has no exit, and the backdrop has no transition at all. Watch the focus ring on the trigger."
+ badges={<Badge variant="error" label="focus races the exit" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label:
+ 'Today — no exit, scrim hard-cuts, focus returns immediately',
+ content: <DialogRig mode="before" />,
+ },
+ {
+ tone: 'after',
+ label: 'Proposed — panel and scrim both exit, focus waits',
+ content: <DialogRig mode="after" />,
+ },
+ ]}
+ />
+ <DemoBody>
+ <Text type="supporting" color="secondary">
+ In the left pane the focus ring lights the instant the dialog
+ closes, while the dialog is still on screen. With a real exit
+ animation that means focus moves — and the page may scroll —
+ mid-animation. The brief lists this as a risk; here it is a thing
+ you can watch, and it has to be settled before the Dialog work
+ starts rather than after.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="The technique, running natively in this browser"
+ question="Is the platform enough, or does the shared primitive need a JS fallback? This card answers it for real — nothing here is simulated.">
+ <DemoBody>
+ <NativePopoverProbe />
+ </DemoBody>
+ </DemoCard>
+
+ <VStack gap={3}>
+ <Heading level={2}>What one change buys</Heading>
+ <Card padding={4}>
+ <VStack gap={2}>
+ <Text>
+ Every component below is a <code>useLayer</code> consumer, so all
+ of them inherit a dismissal animation from a single definition.
+ That is the leverage — and it is also the risk, because it is one
+ change to the code path that owns dismissal.
+ </Text>
+ <HStack gap={1} wrap="wrap">
+ {LAYER_CONSUMERS.map(name => (
+ <Badge key={name} label={name} />
+ ))}
+ </HStack>
+ </VStack>
+ </Card>
+ <CodeBlock
+ language="css"
+ title="layerAnimations — one definition, eleven consumers"
+ hasCopyButton
+ code={`.layer {
+ opacity: 0;
+ transform: scale(0.96) translateY(-4px);
+ transform-origin: var(--layer-origin);
+ transition:
+ opacity var(--duration-exit) var(--ease-exit),
+ transform var(--duration-exit) var(--ease-exit),
+ display var(--duration-exit) allow-discrete,
+ overlay var(--duration-exit) allow-discrete;
+}
+
+.layer:popover-open {
+ opacity: 1;
+ transform: scale(1) translateY(0);
+ transition:
+ opacity var(--duration-enter) var(--ease-entry),
+ transform var(--duration-enter) var(--ease-entry),
+ display var(--duration-enter) allow-discrete,
+ overlay var(--duration-enter) allow-discrete;
+}
+
+@starting-style {
+ .layer:popover-open { opacity: 0; transform: scale(0.96) translateY(-4px); }
+}`}
+ />
+ <CodeBlock
+ language="tsx"
+ title="useLayer — await the exit instead of hiding synchronously"
+ hasCopyButton
+ code={`- setOpen(false); // element gone this frame
++ setClosing(true); // stops accepting input immediately
++ await Promise.all(
++ el.getAnimations().map(a => a.finished),
++ );
++ setOpen(false); // focus return happens here`}
+ />
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>What this work has to be careful about</Heading>
+ <Grid columns={{minWidth: 300}} gap={3}>
+ <Card padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">Dismissal is load-bearing</Text>
+ <Text type="supporting" color="secondary">
+ Layer dismissal has its own invariants test for good reason.
+ Keeping an element alive through its exit doubles the state
+ matrix for focus return, outside-press and escape handling — and
+ every one of those has to be tested against an element that is
+ visible but already closing.
+ </Text>
+ </VStack>
+ </Card>
+ {blocking != null && (
+ <Card padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">
+ The published page already warns about this
+ </Text>
+ <Text type="supporting" color="secondary">
+ &ldquo;{blocking.published}&rdquo; The answer has to be that
+ the surface stops accepting input the moment dismissal starts,
+ not when the animation ends. Write that into the
+ primitive&rsquo;s contract rather than leaving it to each
+ consumer.
+ </Text>
+ </VStack>
+ </Card>
+ )}
+ <Card padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">
+ Motion is already fighting the automated gates
+ </Text>
+ <Text type="supporting" color="secondary">
+ Two fixes landed this month to stop animation interfering with
+ the accessibility audit and the visual-regression capture. More
+ motion means more of this, and there is no documented policy for
+ it. The lab&rsquo;s reduced-motion switch doubles as the freeze
+ mode a capture needs.
+ </Text>
+ </VStack>
+ </Card>
+ </Grid>
+ </VStack>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/export/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/export/page.tsx
index d30d9080dc..ae5acfefae 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/export/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/export/page.tsx
@@ -1,10 +1,527 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's export page.
+ * @file page.tsx
+ * @input Everything the lab has been tuned to this session
+ * @output The two artefacts the foundation milestone ships, plus the lint rule
+ * @position /motion/export
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * The only page that decides nothing. It emits: the token block in the shape
+ * the proposal actually lands in — an addition to two objects core already
+ * defines through StyleX, not a `:root` block, because `:root` is not how this
+ * codebase defines tokens — the JS mirror, and the lint entries that would
+ * keep both honest.
+ */
+
+import * as stylex from '@stylexjs/stylex';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Card} from '@astryxdesign/core/Card';
+import {CodeBlock} from '@astryxdesign/core/CodeBlock';
+import {EmptyState} from '@astryxdesign/core/EmptyState';
+import {Link} from '@astryxdesign/core/Link';
+import {VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import {LabPage} from '../PageFrame';
+import {parseMs, useMotionLab} from '../MotionLabStore';
+import {
+ ALL_TUNABLE_TOKENS,
+ CURRENT_EASE,
+ DEFAULT_TOKEN_VALUES,
+ PRIMITIVE_DURATIONS,
+ SEMANTIC_DURATIONS,
+ SEMANTIC_EASES,
+ SPRINGS,
+ STAGGERS,
+} from '../motionTokens';
+import {isNamedCurve, parseBezier} from '../spring';
+import {AUDIT_COUNTS, LITERAL_VALUES} from '../__generated__/motionAudit';
+
+const sx = stylex.create({
+ mono: {fontFamily: 'var(--font-family-code)'},
+ prose: {maxWidth: '72ch'},
+});
+
+const PRIMITIVE_MS = new Map(PRIMITIVE_DURATIONS);
+
+/** The brief's budget for the sweep, against the measured total. */
+const BRIEF_HARDCODED_BUDGET = 28;
+
+type CodeLine = {readonly text: string; readonly added?: boolean};
+
+function render(lines: ReadonlyArray<CodeLine>): {
+ code: string;
+ highlightLines: number[];
+} {
+ return {
+ code: lines.map(line => line.text).join('\n'),
+ highlightLines: lines
+ .map((line, i) => (line.added === true ? i + 1 : 0))
+ .filter(n => n > 0),
+ };
+}
+
+/**
+ * The token block. Semantic durations emit as `var(--primitive)` — the pattern
+ * `typeScaleDefaults` already uses for type — so a theme retunes both layers at
+ * once. A value tuned away from its primitive cannot alias, and says so.
*/
+function tokenBlockLines(
+ rawToken: (token: string) => string,
+): ReadonlyArray<CodeLine> {
+ const durationLines = SEMANTIC_DURATIONS.map(duration => {
+ const ms = parseMs(rawToken(duration.name));
+ const primitiveMs =
+ duration.primitive != null
+ ? PRIMITIVE_MS.get(duration.primitive)
+ : undefined;
+ if (primitiveMs != null && primitiveMs === ms) {
+ return {
+ text: ` '${duration.name}': 'var(${duration.primitive})',`,
+ added: true,
+ };
+ }
+ const drift =
+ primitiveMs != null
+ ? ` // tuned off ${duration.primitive} (${primitiveMs}ms) — move the primitive or accept the fork`
+ : ' // no primitive: the reduced-motion escape';
+ return {text: ` '${duration.name}': '${ms}ms',${drift}`, added: true};
+ });
+
+ return [
+ {text: '// @astryxdesign/core/src/theme/tokens.stylex.ts'},
+ {
+ text: '// Additions only. The nine primitives and --ease-standard do not move.',
+ },
+ {text: ''},
+ {text: 'export const easeDefaults = {'},
+ {
+ text: ` '${CURRENT_EASE.name}': '${CURRENT_EASE.value}', // kept; deprecated in docs, not in code`,
+ },
+ ...SEMANTIC_EASES.map(ease => ({
+ text: ` '${ease.name}': '${rawToken(ease.name)}',`,
+ added: true,
+ })),
+ {text: '} as const;'},
+ {text: ''},
+ {text: 'export const easeVars = stylex.defineVars(easeDefaults);'},
+ {text: ''},
+ {text: 'export const durationDefaults = {'},
+ ...PRIMITIVE_DURATIONS.map(([name, ms]) => ({
+ text: ` '${name}': '${ms}ms',`,
+ })),
+ {text: ''},
+ {
+ text: ' // Semantic layer. Aliased, so the motion scale a theme sets still owns',
+ },
+ {text: ' // these — the same shape typeScaleDefaults uses for type.'},
+ ...durationLines,
+ {text: '} as const;'},
+ {text: ''},
+ {text: 'export const durationVars = stylex.defineVars(durationDefaults);'},
+ {text: ''},
+ {
+ text: '// Stagger is a delay between siblings, not a duration, so it gets its own',
+ },
+ {text: '// group rather than widening DurationVarName.'},
+ {text: 'export const staggerDefaults = {', added: true},
+ ...STAGGERS.map(([name]) => ({
+ text: ` '${name}': '${parseMs(rawToken(name))}ms',`,
+ added: true,
+ })),
+ {text: '} as const;', added: true},
+ {text: '', added: true},
+ {
+ text: 'export const staggerVars = stylex.defineVars(staggerDefaults);',
+ added: true,
+ },
+ ];
+}
+
+/** Seconds and numbers — the shape Motion, WAAPI and canvas take. */
+function emitMirror(
+ rawToken: (token: string) => string,
+ springs: Readonly<Record<string, {duration: number; bounce: number}>>,
+): string {
+ const short = (name: string) =>
+ name.replace(/^--(duration|ease|stagger)-/, '');
+ const seconds = (name: string) =>
+ Number((parseMs(rawToken(name)) / 1000).toFixed(3));
+ const curve = (name: string) => {
+ const value = rawToken(name);
+ return isNamedCurve(value)
+ ? JSON.stringify(value)
+ : `[${parseBezier(value).join(', ')}]`;
+ };
+
+ return `// @generated from the Astryx theme by scripts/generate-motion-mirror.mjs.
+// Values are resolved through resolveThemeTokens, so a theme that retunes the
+// motion scale retunes this file too.
+
+export const duration = {
+${SEMANTIC_DURATIONS.map(d => ` ${short(d.name)}: ${seconds(d.name)},`).join('\n')}
+} as const;
+
+export const ease = {
+${SEMANTIC_EASES.map(e => ` ${short(e.name)}: ${curve(e.name)},`).join('\n')}
+} as const;
+
+export const stagger = {
+${STAGGERS.map(([name]) => ` ${short(name)}: ${seconds(name)},`).join('\n')}
+} as const;
+
+/** No CSS form, so authored here rather than mirrored. */
+export const spring = {
+${SPRINGS.map(
+ s =>
+ ` ${s.name}: {duration: ${springs[s.name].duration}, bounce: ${springs[s.name].bounce}},`,
+).join('\n')}
+} as const;`;
+}
+
+const LINT_CODE = `// internal/eslint-plugin-xds/index.js — rule: xds/no-hardcoded-styles
+//
+// STYLE_PROPERTIES already covers type, spacing, radius and colour. It has no
+// motion entry, which is why ${AUDIT_COUNTS.hardcodedTotal} hardcoded duration and easing values
+// pass lint today. Six additions, in the shape the map already uses:
+
+const STYLE_PROPERTIES = {
+ // ...fontSize, padding, borderRadius, color — unchanged
+
+ transitionDuration: {
+ pattern: /^['"]?[\\d.]+m?s['"]?$/,
+ tokenVar: 'durationVars',
+ message: 'Use a duration token: var(--duration-*)',
+ examples: ["durationVars['--duration-enter']"],
+ },
+ animationDuration: {
+ pattern: /^['"]?[\\d.]+m?s['"]?$/,
+ tokenVar: 'durationVars',
+ message: 'Use a duration token: var(--duration-*)',
+ examples: ["durationVars['--duration-continuous']"],
+ },
+ transitionDelay: {
+ pattern: /^['"]?[\\d.]+m?s['"]?$/,
+ tokenVar: 'staggerVars',
+ message: 'Use var(--stagger-*) for a group offset, var(--duration-*) otherwise',
+ examples: ["staggerVars['--stagger-base']"],
+ },
+ animationDelay: {
+ pattern: /^['"]?[\\d.]+m?s['"]?$/,
+ tokenVar: 'staggerVars',
+ message: 'Use var(--stagger-*) for a group offset, var(--duration-*) otherwise',
+ examples: ["staggerVars['--stagger-tight']"],
+ },
+ transitionTimingFunction: {
+ pattern: /^['"]?(cubic-bezier\\([^)]*\\)|linear|ease(-in|-out|-in-out)?|steps\\([^)]*\\))['"]?$/,
+ tokenVar: 'easeVars',
+ message: 'Use an easing token: var(--ease-*)',
+ examples: ["easeVars['--ease-entry']", "easeVars['--ease-exit']"],
+ },
+ animationTimingFunction: {
+ pattern: /^['"]?(cubic-bezier\\([^)]*\\)|linear|ease(-in|-out|-in-out)?|steps\\([^)]*\\))['"]?$/,
+ tokenVar: 'easeVars',
+ message: 'Use an easing token: var(--ease-*)',
+ examples: ["easeVars['--ease-linear']"],
+ },
+};
+
+// One carve-out is needed. SKIP_VALUES lets '0', 'none' and 'auto' through for
+// every property, which is right for padding and wrong for motion: it is what
+// hides transitionProperty: 'none'. The structural rules below need to see it.`;
+
+const STRUCTURAL_CODE = `// A second visitor, because these are properties of the style object rather
+// than of one value — the existing rule only ever looks at a single literal.
+
+'motion/require-duration-with-property': {
+ // transitionProperty with no duration in the same object inherits 0s and
+ // animates nothing. Catches: ${AUDIT_COUNTS.noopTransitions} today.
+},
+'motion/require-curve-with-duration': {
+ // A duration with no timing function silently gets the CSS default (ease),
+ // which is a decision nobody made. Catches: ${AUDIT_COUNTS.durationWithoutCurve} today.
+},
+'motion/no-transition-all': {
+ // transitionProperty: 'all' animates layout and paint properties nobody
+ // intended. Catches: ${AUDIT_COUNTS.transitionAll} today — a ratchet, not a cleanup.
+},`;
+
+const LINT_RULES: ReadonlyArray<{
+ readonly rule: string;
+ readonly allows: string;
+ readonly catches: string;
+ readonly kind: string;
+}> = [
+ {
+ rule: 'transitionDuration / animationDuration',
+ allows: 'var(--duration-*)',
+ catches: `${AUDIT_COUNTS.hardcodedDuration} hardcoded durations`,
+ kind: 'value',
+ },
+ {
+ rule: 'transitionDelay / animationDelay',
+ allows: 'var(--stagger-*), var(--duration-*)',
+ catches: 'included in the count above',
+ kind: 'value',
+ },
+ {
+ rule: 'transitionTimingFunction / animationTimingFunction',
+ allows: 'var(--ease-*)',
+ catches: `${AUDIT_COUNTS.hardcodedEasing} hardcoded curves`,
+ kind: 'value',
+ },
+ {
+ rule: 'motion/require-duration-with-property',
+ allows: 'a duration beside every transitionProperty',
+ catches: `${AUDIT_COUNTS.noopTransitions} no-op transition`,
+ kind: 'structural',
+ },
+ {
+ rule: 'motion/require-curve-with-duration',
+ allows: 'a curve beside every duration',
+ catches: `${AUDIT_COUNTS.durationWithoutCurve} durations with no declared curve`,
+ kind: 'structural',
+ },
+ {
+ rule: 'motion/no-transition-all',
+ allows: 'named properties only',
+ catches: `${AUDIT_COUNTS.transitionAll} today — prevents regressions`,
+ kind: 'structural',
+ },
+];
+
+export default function MotionExportPage() {
+ const {rawToken, springs, dirtyTokens} = useMotionLab();
+ const {code: tokenCode, highlightLines} = render(tokenBlockLines(rawToken));
+
+ const tokenDiff = ALL_TUNABLE_TOKENS.filter(
+ name => rawToken(name) !== DEFAULT_TOKEN_VALUES[name],
+ ).map(name => ({
+ name,
+ proposed: DEFAULT_TOKEN_VALUES[name],
+ tuned: rawToken(name),
+ }));
+
+ const springDiff = SPRINGS.flatMap(spec => {
+ const tuned = springs[spec.name];
+ const rows: Array<{name: string; proposed: string; tuned: string}> = [];
+ if (tuned.duration !== spec.duration) {
+ rows.push({
+ name: `spring.${spec.name}.duration`,
+ proposed: `${spec.duration}s`,
+ tuned: `${tuned.duration}s`,
+ });
+ }
+ if (tuned.bounce !== spec.bounce) {
+ rows.push({
+ name: `spring.${spec.name}.bounce`,
+ proposed: String(spec.bounce),
+ tuned: String(tuned.bounce),
+ });
+ }
+ return rows;
+ });
+
+ const changes = [...tokenDiff, ...springDiff];
+ const instantCount =
+ LITERAL_VALUES.find(([value]) => value === '0.01s')?.[1] ?? 0;
+
+ return (
+ <LabPage
+ title="Export tuning"
+ intro="Everything tuned in this session, as the two artefacts the foundation milestone ships: the token block and the JS mirror. Plus the lint entries that stop the next one from arriving."
+ decides="Nothing — it emits whatever the rest of the lab has been tuned to."
+ badges={
+ <Badge
+ variant={changes.length > 0 ? 'warning' : 'neutral'}
+ label={
+ changes.length > 0
+ ? `${changes.length} changed`
+ : 'proposal defaults'
+ }
+ />
+ }>
+ <VStack gap={3}>
+ <Heading level={2}>What moved</Heading>
+ {changes.length === 0 ? (
+ <Card padding={4}>
+ <EmptyState
+ title="Nothing has been tuned this session"
+ description="Every value below is the proposal exactly as authored. Change a curve on the tokens page or a spring on the springs page and the differences appear here."
+ />
+ </Card>
+ ) : (
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Token</TableHeaderCell>
+ <TableHeaderCell>Proposal</TableHeaderCell>
+ <TableHeaderCell>Tuned</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {changes.map(row => (
+ <TableRow key={row.name}>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)}>{row.name}</Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {row.proposed}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} weight="semibold">
+ {row.tuned}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ )}
+ {dirtyTokens.length > 0 && (
+ <Text type="supporting" color="secondary">
+ The rail counts {dirtyTokens.length} tuned token(s); springs are
+ counted separately because they are not custom properties.
+ </Text>
+ )}
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>The token block</Heading>
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ Highlighted lines are the addition. Core defines tokens through{' '}
+ <code>stylex.defineVars</code>, so this is a diff against two existing
+ objects rather than a <code>:root</code> block — <code>:root</code>{' '}
+ would bypass the theme system entirely and could not be retuned by a
+ theme. Semantic durations emit as <code>var(--primitive)</code>, which
+ is the shape <code>typeScaleDefaults</code> already uses for type, so
+ a theme that moves the motion scale moves these with it.
+ </Text>
+ <CodeBlock
+ language="ts"
+ title="@astryxdesign/core/src/theme/tokens.stylex.ts"
+ hasCopyButton
+ hasLineNumbers
+ highlightLines={highlightLines}
+ code={tokenCode}
+ />
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>The JS mirror</Heading>
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ Same values, in the shape a JS animation takes. Generated from the
+ theme in the same build step that emits the CSS — see{' '}
+ <Link href="/pages/motion-lab/js-mirror/">JS token mirror</Link> for
+ why it cannot be a handwritten constants file.
+ </Text>
+ <CodeBlock
+ language="ts"
+ title="@astryxdesign/core/motion — generated"
+ hasCopyButton
+ code={emitMirror(rawToken, springs)}
+ />
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>The lint rule</Heading>
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ The token linter already polices type, spacing, radius and colour, and
+ simply has no entry for duration or easing. That is the whole reason{' '}
+ {AUDIT_COUNTS.hardcodedTotal} values are hardcoded: nothing ever told
+ anyone not to. Six property entries drop straight into the existing
+ pattern map — three rules once the duration, delay and timing-function
+ pairs are grouped. The other three are structural: they are properties
+ of the whole style object, and the current rule only ever looks at one
+ literal at a time.
+ </Text>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Rule</TableHeaderCell>
+ <TableHeaderCell>Allows</TableHeaderCell>
+ <TableHeaderCell>Measured catch</TableHeaderCell>
+ <TableHeaderCell>Kind</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {LINT_RULES.map(rule => (
+ <TableRow key={rule.rule}>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)}>{rule.rule}</Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {rule.allows}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text>{rule.catches}</Text>
+ </TableCell>
+ <TableCell>
+ <Badge
+ variant={rule.kind === 'structural' ? 'info' : 'neutral'}
+ label={rule.kind}
+ />
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ <CodeBlock
+ language="js"
+ title="internal/eslint-plugin-xds/index.js — value entries"
+ hasCopyButton
+ isWrapped
+ code={LINT_CODE}
+ />
+ <CodeBlock
+ language="js"
+ title="The structural companions"
+ hasCopyButton
+ code={STRUCTURAL_CODE}
+ />
+ </VStack>
-export {default} from '../../../../../motion/pages/export';
+ <Banner
+ status="warning"
+ title={`The sweep is ${AUDIT_COUNTS.hardcodedTotal} sites, not ${BRIEF_HARDCODED_BUDGET}`}
+ description={
+ <Text>
+ The brief budgets {BRIEF_HARDCODED_BUDGET} hardcoded values; the
+ audit measures {AUDIT_COUNTS.hardcodedTotal} (
+ {AUDIT_COUNTS.hardcodedDuration} durations,{' '}
+ {AUDIT_COUNTS.hardcodedEasing} curves). Roughly a quarter of them —{' '}
+ {instantCount} of {AUDIT_COUNTS.hardcodedTotal},{' '}
+ {Math.round((instantCount / AUDIT_COUNTS.hardcodedTotal) * 100)}% —
+ are the <code>0.01s</code> reduced-motion idiom in BottomSheet,
+ DateInput and MobileNav, and those cannot be swept until{' '}
+ <code>--duration-instant</code> is settled at 0 or 0.01ms: a zero
+ duration fires no <code>transitionend</code>, and code sequences off
+ that event. Turning the rule on before that decision lands means{' '}
+ {instantCount} suppressions in the first diff. See{' '}
+ <Link href="/pages/motion-lab/reduced-motion/">Reduced motion</Link>{' '}
+ and{' '}
+ <Link href="/pages/motion-lab/violations/">Hardcoded values</Link>.
+ </Text>
+ }
+ />
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/scripts/generate-motion-audit.mjs b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/generate-motion-audit.mjs
similarity index 98%
rename from apps/sandbox/scripts/generate-motion-audit.mjs
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/generate-motion-audit.mjs
index 19ef0fad77..234eaf7433 100644
--- a/apps/sandbox/scripts/generate-motion-audit.mjs
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/generate-motion-audit.mjs
@@ -16,8 +16,11 @@ import fs from 'node:fs';
import path from 'node:path';
import url from 'node:url';
+// This script sits inside the lab it feeds, so everything the lab needs is in
+// one directory: the pages, the shared modules, the generated data, and the
+// generator that produces it.
const HERE = path.dirname(url.fileURLToPath(import.meta.url));
-const APP = path.resolve(HERE, '..');
+const APP = path.resolve(HERE, '../../../../..');
const REPO = path.resolve(APP, '../..');
// In the monorepo the audit reads the real package sources, so lab is
// measurable too — it is a published package here, not an absent dependency.
@@ -25,7 +28,7 @@ const PACKAGES = [
{name: 'core', root: path.join(REPO, 'packages/core/src')},
{name: 'lab', root: path.join(REPO, 'packages/lab/src')},
];
-const OUT = path.join(APP, 'src/motion/__generated__/motionAudit.ts');
+const OUT = path.join(HERE, '__generated__/motionAudit.ts');
for (const pkg of PACKAGES) {
if (!fs.existsSync(pkg.root)) {
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/js-mirror/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/js-mirror/page.tsx
index c14fe1b919..3013a4749f 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/js-mirror/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/js-mirror/page.tsx
@@ -1,10 +1,545 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's js-mirror page.
+ * @file page.tsx
+ * @input The generated audit, the lab store, the token data
+ * @output The case for a JS mirror, and the module it would emit
+ * @position /motion/js-mirror
+ *
+ * A CSS custom property is readable by exactly one consumer: CSS. Every
+ * animation library, the Web Animations API, and anything drawing to a canvas
+ * takes numbers. Motion wants seconds as a number and easing as four numbers;
+ * it cannot resolve `var(--duration-fast)`. The mirror exists so that the
+ * value in the stylesheet and the value in the chart are the same value.
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * The chart demo draws to a real canvas rather than faking one with divs,
+ * because the whole argument is that canvas sits outside the token system.
+ */
+
+import {useCallback, useEffect, useRef} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Card} from '@astryxdesign/core/Card';
+import {CodeBlock} from '@astryxdesign/core/CodeBlock';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Link} from '@astryxdesign/core/Link';
+import {VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import {LabPage} from '../PageFrame';
+import {ComparePanes, DemoBody, DemoCard, useLoop} from '../LabPrimitives';
+import {parseMs, useMotionLab} from '../MotionLabStore';
+import {
+ SEMANTIC_DURATIONS,
+ SEMANTIC_EASES,
+ SPRINGS,
+ STAGGERS,
+} from '../motionTokens';
+import {bezierAt, isNamedCurve, parseBezier} from '../spring';
+import {AUDIT_COUNTS, TIMEOUT_LITERALS} from '../__generated__/motionAudit';
+
+const sx = stylex.create({
+ full: {width: '100%'},
+ prose: {maxWidth: '72ch'},
+ mono: {fontFamily: 'var(--font-family-code)'},
+ canvas: {
+ display: 'block',
+ width: '100%',
+ height: '132px',
+ // Canvas has no access to a custom property, so the demo parks the one
+ // colour it needs on the element and reads it back with getComputedStyle.
+ color: 'var(--color-brand)',
+ },
+});
+
+const CHART_HEIGHT = 132;
+
+/** Fixed data, so both panes cycle the same values and the eye can compare. */
+const DATASETS: ReadonlyArray<ReadonlyArray<number>> = [
+ [0.42, 0.66, 0.28, 0.81, 0.55, 0.35, 0.72],
+ [0.68, 0.31, 0.74, 0.44, 0.86, 0.52, 0.29],
+ [0.24, 0.58, 0.9, 0.36, 0.61, 0.79, 0.47],
+];
+
+/** `--duration-*` in seconds, `--ease-*` as points, the shape a library takes. */
+function emitMirror(
+ rawToken: (token: string) => string,
+ springs: Readonly<Record<string, {duration: number; bounce: number}>>,
+): string {
+ const short = (name: string) =>
+ name.replace(/^--(duration|ease|stagger)-/, '');
+ const seconds = (name: string) =>
+ Number((parseMs(rawToken(name)) / 1000).toFixed(3));
+ const curve = (name: string) => {
+ const value = rawToken(name);
+ return isNamedCurve(value)
+ ? JSON.stringify(value)
+ : `[${parseBezier(value).join(', ')}]`;
+ };
+
+ return `// @generated from the Astryx theme by scripts/generate-motion-mirror.mjs.
+// Seconds and numbers, because that is what animation libraries, the Web
+// Animations API and canvas take. Regenerate when the theme changes.
+
+/** Seconds. Motion, WAAPI and canvas all want a number here. */
+export const duration = {
+${SEMANTIC_DURATIONS.map(d => ` ${short(d.name)}: ${seconds(d.name)},`).join('\n')}
+} as const;
+
+/** Four control points, or the CSS keyword when the curve is a keyword. */
+export const ease = {
+${SEMANTIC_EASES.map(e => ` ${short(e.name)}: ${curve(e.name)},`).join('\n')}
+} as const;
+
+/** Seconds between items in a group entrance. */
+export const stagger = {
+${STAGGERS.map(([name]) => ` ${short(name)}: ${seconds(name)},`).join('\n')}
+} as const;
+
+/** No CSS form at all, so these are defined here rather than mirrored. */
+export const spring = {
+${SPRINGS.map(
+ s =>
+ ` ${s.name}: {duration: ${springs[s.name].duration}, bounce: ${springs[s.name].bounce}},`,
+).join('\n')}
+} as const;`;
+}
+
+const BEFORE_CODE = `// MobileNav/MobileNav.tsx:294-311
+function resolveCloseDelay(dialog: HTMLDialogElement): number {
+ const cap = window.matchMedia('(prefers-reduced-motion: reduce)').matches
+ ? 0
+ : MAX_CLOSE_DELAY_MS;
+
+ const hold = parseShortestDurationMs(
+ window.getComputedStyle(dialog).transitionDuration,
+ );
+
+ // The hold is unreadable — an unresolved var()
+ // outside a real browser.
+ if (hold === null) {
+ return cap;
+ }
+
+ return hold <= 0 ? 0 : Math.min(cap, hold * CLOSE_WITHIN_HOLD);
+}
+
+// plus parseShortestDurationMs at :265 — 25 lines
+// that exist only to turn "0.41s, 0.12s" back into
+// a number, exported so it can be unit tested.`;
+
+const AFTER_CODE = `import {duration} from '@astryxdesign/core/motion';
+
+function resolveCloseDelay(prefersReducedMotion: boolean): number {
+ const cap = prefersReducedMotion ? 0 : MAX_CLOSE_DELAY_MS;
+ // The same value the stylesheet uses, theme-resolved,
+ // and readable in jsdom.
+ const hold = duration.overlay * 1000;
+ return Math.min(cap, hold * CLOSE_WITHIN_HOLD);
+}`;
+
+const STYLEX_GAP_CODE = `import {durationVars, easeVars} from '@astryxdesign/core/theme/tokens.stylex';
+
+durationVars['--duration-medium']; // "var(--x1kg2b7)" — a reference
+easeVars['--ease-standard']; // "var(--x9f0d3a)" — same
+
+// Correct in StyleX:
+stylex.create({panel: {transitionDuration: durationVars['--duration-medium']}});
+
+// Useless anywhere else:
+animate(el, {opacity: 1}, {duration: durationVars['--duration-medium']}); // NaN
+ctx.globalAlpha = progress(durationVars['--duration-medium']); // NaN`;
+
+/**
+ * A bar chart redrawn on a loop. Before replaces the data outright, which is
+ * what every chart in the system does today; after interpolates it with the
+ * same token the CSS uses, reached through the mirror.
*/
+function ChartPane({mode}: {mode: 'before' | 'after'}) {
+ const {rawToken, reducedMotion, scaledMs} = useMotionLab();
+ const canvasRef = useRef<HTMLCanvasElement | null>(null);
+ const currentRef = useRef<ReadonlyArray<number>>(DATASETS[0]);
+ const stepRef = useRef(1);
+ const frameRef = useRef(0);
+
+ const draw = useCallback((values: ReadonlyArray<number>) => {
+ const canvas = canvasRef.current;
+ if (canvas == null) {
+ return;
+ }
+ const ratio = window.devicePixelRatio || 1;
+ const width = canvas.clientWidth || 280;
+ const pixelWidth = Math.round(width * ratio);
+ const pixelHeight = Math.round(CHART_HEIGHT * ratio);
+ if (canvas.width !== pixelWidth || canvas.height !== pixelHeight) {
+ canvas.width = pixelWidth;
+ canvas.height = pixelHeight;
+ }
+ const ctx = canvas.getContext('2d');
+ if (ctx == null) {
+ return;
+ }
+ ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
+ ctx.clearRect(0, 0, width, CHART_HEIGHT);
+ ctx.fillStyle = window.getComputedStyle(canvas).color;
+ const gap = 8;
+ const barWidth = (width - gap * (values.length - 1)) / values.length;
+ values.forEach((value, i) => {
+ const height = Math.max(2, value * (CHART_HEIGHT - 6));
+ ctx.fillRect(
+ i * (barWidth + gap),
+ CHART_HEIGHT - height,
+ barWidth,
+ height,
+ );
+ });
+ }, []);
+
+ const advance = useCallback(() => {
+ const next = DATASETS[stepRef.current % DATASETS.length];
+ stepRef.current += 1;
+ const from = currentRef.current;
+
+ // Under either reduced-motion policy the after pane collapses into the
+ // before pane, which is what reduced motion costs a chart: the data still
+ // changes, the eye just has to find it again.
+ if (mode === 'before' || reducedMotion !== 'off') {
+ currentRef.current = next;
+ draw(next);
+ return;
+ }
+
+ const ms = Math.max(1, scaledMs('--duration-reveal'));
+ const curve = parseBezier(rawToken('--ease-move'));
+ const startedAt = performance.now();
+ window.cancelAnimationFrame(frameRef.current);
+ const step = (now: number) => {
+ const k = Math.min(1, (now - startedAt) / ms);
+ const eased = bezierAt(curve, k);
+ draw(next.map((target, i) => from[i] + (target - from[i]) * eased));
+ if (k < 1) {
+ frameRef.current = window.requestAnimationFrame(step);
+ } else {
+ currentRef.current = next;
+ }
+ };
+ frameRef.current = window.requestAnimationFrame(step);
+ }, [draw, mode, rawToken, reducedMotion, scaledMs]);
+
+ useLoop(advance, scaledMs('--duration-reveal') + 1300);
+
+ useEffect(() => () => window.cancelAnimationFrame(frameRef.current), []);
+
+ return (
+ <canvas
+ ref={canvasRef}
+ role="img"
+ aria-label={
+ mode === 'before'
+ ? 'Bar chart whose values change instantly'
+ : 'Bar chart whose values interpolate over the reveal duration'
+ }
+ {...stylex.props(sx.canvas)}
+ />
+ );
+}
+
+export default function MotionJsMirrorPage() {
+ const {rawToken, springs, scaledMs} = useMotionLab();
+ const typeahead = TIMEOUT_LITERALS[0];
+
+ return (
+ <LabPage
+ title="JS token mirror"
+ intro="CSS custom properties are unreadable to every animation library, to the Web Animations API, and to canvas and chart code. Motion takes seconds as a number and easing as a four-number array; it cannot resolve var(--duration-fast). The mirror emits the same values the stylesheets use, in the shape those consumers already expect."
+ decides="What the mirror has to expose for charts, canvas and motion libraries."
+ badges={<Badge variant="info" label="emitted live from this session" />}>
+ <DemoCard
+ title="The read that should not have to exist"
+ question={`${AUDIT_COUNTS.getComputedStyleReads} getComputedStyle reads across core. Two of them read motion values back out of CSS because there is no other way to get them.`}
+ badges={
+ <Badge variant="warning" label="MobileNav/MobileNav.tsx:303" />
+ }>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — parse the number back out of the stylesheet',
+ content: (
+ <CodeBlock
+ language="ts"
+ code={BEFORE_CODE}
+ maxHeight={340}
+ isWrapped
+ hasCopyButton={false}
+ />
+ ),
+ },
+ {
+ tone: 'after',
+ label: 'With the mirror',
+ content: (
+ <CodeBlock
+ language="ts"
+ code={AFTER_CODE}
+ maxHeight={340}
+ isWrapped
+ hasCopyButton={false}
+ />
+ ),
+ },
+ ]}
+ />
+ <DemoBody>
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ MobileNav is doing the right thing for the right reason. Its own
+ comment says so: the hold is <code>--duration-medium</code>,{' '}
+ <q>
+ which themes rewrite — the shipped y2k theme sets it to exactly
+ 250ms — so read the hold in effect rather than assuming it
+ </q>
+ . Getting that value costs a computed-style read, a 25-line time
+ parser exported for its own unit test (
+ <code>MobileNav/MobileNav.tsx:265</code>), and a null branch for the
+ case where the read comes back as an unresolved <code>var()</code>{' '}
+ outside a real browser. That is exactly right, and exactly what
+ nobody should have to write by hand.
+ </Text>
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ The opposite failure — a hardcoded unmount timer drifting away from
+ the transition it is supposed to outlast — is the one the brief
+ warns about, and the audit does not find it.{' '}
+ <code>TIMEOUT_LITERALS</code> holds exactly{' '}
+ {TIMEOUT_LITERALS.length} entry:{' '}
+ <code>
+ {typeahead.file}:{typeahead.line}
+ </code>{' '}
+ ({typeahead.ms}ms), and it is a typeahead buffer reset, not motion
+ at all. So core is currently on the safe side of that trade and
+ paying for it in ceremony. The mirror does not fix a bug here; it
+ removes the ceremony, and it makes the same number available to code
+ that has no stylesheet to read.
+ </Text>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Read</TableHeaderCell>
+ <TableHeaderCell>What it wants</TableHeaderCell>
+ <TableHeaderCell>Mirror replaces it?</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ <TableRow>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)}>
+ MobileNav/MobileNav.tsx:303
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text color="secondary">
+ <code>transitionDuration</code>, to time the dialog close
+ inside the hold
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Badge variant="success" label="yes" />
+ </TableCell>
+ </TableRow>
+ <TableRow>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)}>
+ BottomSheet/BottomSheetPanel.tsx:326
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text color="secondary">
+ <code>transitionProperty</code>,{' '}
+ <code>transitionDuration</code> and{' '}
+ <code>transitionDelay</code>, to know whether a{' '}
+ <code>transitionend</code> will arrive
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Badge variant="warning" label="partly" />
+ </TableCell>
+ </TableRow>
+ <TableRow>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)}>
+ the other {AUDIT_COUNTS.getComputedStyleReads - 2}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text color="secondary">
+ direction, writing mode, padding, border radius, scroll
+ margin — layout, not motion
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Badge label="not its job" />
+ </TableCell>
+ </TableRow>
+ </TableBody>
+ </Table>
+ </Card>
+ <Text type="supporting" color="secondary">
+ Worth saying plainly: {AUDIT_COUNTS.getComputedStyleReads} is the
+ whole computed-style caseload, not the motion one. The motion
+ argument rests on two sites and on everything that cannot read a
+ stylesheet at all — which is the next card.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="Charts are outside the token system entirely"
+ question="Canvas cannot resolve a custom property. Chart, Radial, Sankey and Schedule therefore animate on whatever numbers their author typed, or they do not animate."
+ badges={<Badge variant="neutral" label="live, on a loop" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — data replaces itself',
+ content: (
+ <VStack gap={2} {...stylex.props(sx.full)}>
+ <ChartPane mode="before" />
+ <Text type="supporting" color="secondary">
+ No token is reachable from here, so the honest default is no
+ animation at all. The chart jumps and the eye loses which
+ bar was which.
+ </Text>
+ </VStack>
+ ),
+ },
+ {
+ tone: 'after',
+ label: 'With the mirror — interpolated on the reveal token',
+ content: (
+ <VStack gap={2} {...stylex.props(sx.full)}>
+ <ChartPane mode="after" />
+ <Text type="supporting" color="secondary">
+ <code>scaledMs(&apos;--duration-reveal&apos;)</code> and{' '}
+ <code>
+ bezierAt(parseBezier(rawToken(&apos;--ease-move&apos;)),
+ k)
+ </code>{' '}
+ — the same duration and the same curve the CSS uses, applied
+ per frame.
+ </Text>
+ </VStack>
+ ),
+ },
+ ]}
+ />
+ <DemoBody>
+ <Text type="supporting" color="secondary">
+ Currently {Math.round(scaledMs('--duration-reveal'))}ms at the
+ rail&rsquo;s speed, on <code>{rawToken('--ease-move')}</code>.
+ Change either on the tokens page and both this chart and every CSS
+ demo in the lab move together — which is the whole claim: one value,
+ two consumers.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <VStack gap={3}>
+ <Heading level={2}>The module, as it stands right now</Heading>
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ Emitted from whatever this session has tuned, including springs from
+ the springs page. Copy it and it is a working module.
+ </Text>
+ <CodeBlock
+ language="ts"
+ title="@astryxdesign/core/motion — generated"
+ hasCopyButton
+ maxHeight={760}
+ code={emitMirror(rawToken, springs)}
+ />
+ </VStack>
+
+ <Grid columns={{minWidth: 460}} gap={4}>
+ <DemoCard
+ title="Why the defaults are not hardcoded in JS"
+ question="Because a theme retunes the whole scale, and a constants file would quietly stop agreeing with the stylesheet.">
+ <DemoBody>
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ A theme sets three numbers —{' '}
+ <code>{'{fast, medium, ratio}'}</code> — and{' '}
+ <code>expandMotionScale</code> derives the whole duration scale
+ from them; the shipped y2k theme lands{' '}
+ <code>--duration-medium</code> on 250ms rather than 410ms. A
+ mirror written as literals would be right for the default theme
+ and wrong for every other one, which is the failure mode MobileNav
+ is already defending against by reading the computed value.
+ </Text>
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ So the mirror parses the same token values the stylesheets use,
+ through the resolver core already has:{' '}
+ <code>resolveThemeTokens(theme, {'{mode}'})</code> returns
+ concrete strings with <code>var()</code> references already
+ followed, and needs no React context and no browser. Springs are
+ the exception and are defined in the mirror natively, because they
+ have no CSS form to parse.
+ </Text>
+ <CodeBlock
+ language="ts"
+ title="How the emitter gets its numbers"
+ isWrapped
+ code={`import {resolveThemeTokens} from '@astryxdesign/core/theme/tokens';
+
+const tokens = resolveThemeTokens(theme, {mode: 'light'});
+duration.overlay = parseMs(tokens['--duration-overlay']) / 1000;
+ease.move = parseBezier(tokens['--ease-move']);
+// spring.* has no token to read — it is authored here.`}
+ />
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="StyleX vars are not the mirror"
+ question="Core already exports durationVars and easeVars. They are the right thing for StyleX and useless everywhere else.">
+ <DemoBody>
+ <CodeBlock
+ language="ts"
+ code={STYLEX_GAP_CODE}
+ isWrapped
+ maxHeight={300}
+ />
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ <code>stylex.defineVars</code> hands back opaque{' '}
+ <code>var(...)</code> strings. That is the correct contract for a
+ stylesheet and it is precisely the gap: the value never becomes a
+ number on the JS side. The mirror is the second half of the same
+ token, not a competing source of truth.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+ </Grid>
-export {default} from '../../../../../motion/pages/js-mirror';
+ <Banner
+ status="info"
+ title="What the mirror does not solve"
+ description={
+ <Text>
+ A second artefact is a second thing to keep in sync. It only stays
+ honest if it is generated from the theme in the same build step that
+ emits the CSS, and if the lint rule treats a hardcoded number in JS
+ the same way it treats one in a stylesheet. Both of those are on{' '}
+ <Link href="/pages/motion-lab/export/">Export tuning</Link>.
+ </Text>
+ }
+ />
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/layout.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/layout.tsx
index 503b3c1b18..162322045e 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/layout.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/layout.tsx
@@ -15,8 +15,8 @@
*/
import type {ReactNode} from 'react';
-import {MotionLabProvider} from '../../../../motion/MotionLabStore';
-import {MotionLabShell} from '../../../../motion/MotionLabShell';
+import {MotionLabProvider} from './MotionLabStore';
+import {MotionLabShell} from './MotionLabShell';
export default function MotionLabLayout({children}: {children: ReactNode}) {
return (
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/library/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/library/page.tsx
index e2c6e795ee..526fb7fe29 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/library/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/library/page.tsx
@@ -1,10 +1,232 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's library page.
+ * @file page.tsx
+ * @input libraryCompat.ts and the generated audit
+ * @output The three blockers between Astryx and motion.dev, in order
+ * @position /motion/library
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * The recommendation is to stay CSS-first and become explicitly compatible.
+ * Nothing on this page argues for taking the dependency; it argues about what
+ * a consumer who takes it themselves runs into, which is a different and much
+ * cheaper list than the brief assumed.
*/
-export {default} from '../../../../../motion/pages/library';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Card} from '@astryxdesign/core/Card';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Link as AstryxLink} from '@astryxdesign/core/Link';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import {
+ AUDIT_COUNTS,
+ TRANSFORM_TRANSITIONS,
+} from '../__generated__/motionAudit';
+import {ComparePanes, DemoBody, DemoCard} from '../LabPrimitives';
+import {PressRig} from '../LabDemos';
+import {LabPage} from '../PageFrame';
+import {
+ ALREADY_RIGHT,
+ BLOCKERS,
+ CHEAP_WINS,
+ MOTION_BUNDLE_KB,
+ buttonFindings,
+} from '../libraryCompat';
+
+function Detail({label, children}: {label: string; children: string}) {
+ return (
+ <VStack gap={1}>
+ <Text type="label" weight="semibold">
+ {label}
+ </Text>
+ <Text color="secondary">{children}</Text>
+ </VStack>
+ );
+}
+
+export default function MotionLibraryPage() {
+ const button = buttonFindings();
+ const transformComponents = new Set(
+ TRANSFORM_TRANSITIONS.map(site => site.component),
+ );
+
+ return (
+ <LabPage
+ title="Motion library compatibility"
+ intro="What a team that installs motion.dev runs into today, and the smallest set of changes that makes Astryx compose with it. Three blockers, in the order they bite."
+ badges={<Badge variant="info" label="CSS-first" />}
+ decides="The three blockers, and whether Button keeps its press transition.">
+ <Banner
+ status="info"
+ title="Stay CSS-first and become explicitly compatible"
+ description={
+ <Text>
+ {`Astryx should not ship Motion: ~${MOTION_BUNDLE_KB}KB and a runtime on every consumer, to fix nothing the CSS path is failing at. But a consumer who installs it themselves should find that Astryx composes cleanly, and today three things stop that. Two of the three are already on the roadmap under other names.`}
+ </Text>
+ }
+ />
+
+ {BLOCKERS.map((blocker, index) => (
+ <DemoCard
+ key={blocker.id}
+ title={`${index + 1}. ${blocker.title}`}
+ question={blocker.symptom}
+ badges={<Badge variant="error" label={blocker.severity} />}>
+ {blocker.id === 'transform-transitions' ? (
+ <VStack gap={0}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'transition: transform — today',
+ content: <PressRig technique="transform" />,
+ },
+ {
+ tone: 'neutral',
+ label: 'transition: scale — the middle path',
+ content: <PressRig technique="scale" />,
+ },
+ {
+ tone: 'after',
+ label: 'no transition — what the brief proposes',
+ content: <PressRig technique="none" />,
+ },
+ ]}
+ />
+ <DemoBody>
+ <Detail label="Cause">{blocker.cause}</Detail>
+ <Detail label="Fix">{blocker.fix}</Detail>
+ <Banner
+ status="warning"
+ title={`Measured: ${AUDIT_COUNTS.transformTransitions} sites across ${AUDIT_COUNTS.transformTransitionComponents} components — the brief's "20+" was right`}
+ description={
+ <Text>
+ {button.transformSites.length > 0
+ ? `Button is in the list, at ${button.transformSites
+ .map(site => `${site.file}:${site.line}`)
+ .join(
+ ', ',
+ )}: it declares transform in its transition property list and takes scale(0.98) on :active. The brief calls it the worst case because it is the most-wrapped component, and the measurement agrees. Two earlier versions of the audit script reported far fewer sites and no Button at all — a wrapped value and a nested StyleX rule each hid matches. The brief was closer than the tool twice.`
+ : 'Button is absent from the measured data, which contradicts the brief. Re-check the scanner before acting on this.'}
+ </Text>
+ }
+ />
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Component</TableHeaderCell>
+ <TableHeaderCell>Site</TableHeaderCell>
+ <TableHeaderCell>Declaration</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {TRANSFORM_TRANSITIONS.map(site => (
+ <TableRow key={`${site.file}:${site.line}`}>
+ <TableCell>
+ <Text weight="semibold">{site.component}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="code">{`${site.file}:${site.line}`}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="code" color="secondary">
+ {site.decl ?? '\u2014'}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ <Text type="supporting" color="secondary">
+ {`${transformComponents.size} components, and the shape of the list is chevrons and menus rather than roots: ${[...transformComponents].join(', ')}. A consumer animating a chevron is rare; a consumer animating a Button is not, which is why the brief's framing mattered and why the correction changes the priority.`}
+ </Text>
+ <Detail label="Cost">{blocker.cost}</Detail>
+ </DemoBody>
+ </VStack>
+ ) : (
+ <DemoBody>
+ <Detail label="Cause">{blocker.cause}</Detail>
+ <Detail label="Fix">{blocker.fix}</Detail>
+ <Detail label="Cost">{blocker.cost}</Detail>
+ {blocker.id === 'overlay-exit' && (
+ <Text type="supporting" color="secondary">
+ Same mechanism as the CSS exit gap:{' '}
+ <AstryxLink href="/pages/motion-lab/exit-gap/">
+ see it fail natively
+ </AstryxLink>
+ . One fix closes both, and doing them apart means solving
+ top-layer retention twice.
+ </Text>
+ )}
+ </DemoBody>
+ )}
+ </DemoCard>
+ ))}
+
+ <VStack gap={3}>
+ <Heading level={2}>Cheap wins</Heading>
+ <Text color="secondary">
+ What moves Astryx from &ldquo;wrappable with caveats&rdquo; to
+ Motion-friendly for everything except overlay exits. None of these
+ needs the composition decision.
+ </Text>
+ <Grid columns={{minWidth: 280}} gap={3}>
+ {CHEAP_WINS.map(win => (
+ <Card key={win.id} padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">{win.title}</Text>
+ <Text type="supporting" color="secondary">
+ {win.detail}
+ </Text>
+ {win.evidence != null && <Badge label={win.evidence} />}
+ </VStack>
+ </Card>
+ ))}
+ </Grid>
+ <Text type="supporting" color="secondary">
+ The ref gap is the one number on this page the lab cannot check: the
+ audit reads the built package&rsquo;s styles, not its prop types, so
+ the brief&rsquo;s &ldquo;eight overlay components&rdquo; is unverified
+ here.
+ </Text>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>What already works</Heading>
+ <Text color="secondary">
+ Astryx is structurally better placed for this than most CSS-first
+ systems, and the part that usually needs a rewrite is the part that is
+ already right.
+ </Text>
+ <Grid columns={{minWidth: 260}} gap={3}>
+ {ALREADY_RIGHT.map(item => (
+ <Card key={item.title} padding={4}>
+ <VStack gap={1.5}>
+ <HStack gap={1.5} vAlign="center">
+ <Badge variant="success" label="ok" />
+ <Text weight="semibold">{item.title}</Text>
+ </HStack>
+ <Text type="supporting" color="secondary">
+ {item.detail}
+ </Text>
+ </VStack>
+ </Card>
+ ))}
+ </Grid>
+ </VStack>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/motion/libraryCompat.ts b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/libraryCompat.ts
similarity index 100%
rename from apps/sandbox/src/motion/libraryCompat.ts
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/libraryCompat.ts
diff --git a/apps/sandbox/src/motion/motionTokens.ts b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/motionTokens.ts
similarity index 100%
rename from apps/sandbox/src/motion/motionTokens.ts
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/motionTokens.ts
diff --git a/apps/sandbox/src/motion/openQuestions.ts b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/openQuestions.ts
similarity index 97%
rename from apps/sandbox/src/motion/openQuestions.ts
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/openQuestions.ts
index ba613fb652..226cf2171f 100644
--- a/apps/sandbox/src/motion/openQuestions.ts
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/openQuestions.ts
@@ -146,7 +146,7 @@ export const OPEN_QUESTIONS: ReadonlyArray<OpenQuestion> = [
'A design review at house level. Astryx has deliberately refused polymorphism, and a render-prop shape may fit the conventions better than asChild.',
blocks:
'Motion blocker 3, and equally router links and drag-and-drop. It should not be decided on motion\u2019s evidence alone.',
- href: '/motion/library',
+ href: '/pages/motion-lab/library/',
hrefLabel: 'The three blockers',
urgency: 'can run late',
},
@@ -157,7 +157,7 @@ export const OPEN_QUESTIONS: ReadonlyArray<OpenQuestion> = [
'A call on whether a theme carries motion personality as well as colour and type.',
blocks:
'The token work. Adding springs to the theme contract after it ships is a breaking change, so this is decided before Foundation lands even if no theme overrides them at first.',
- href: '/motion/springs',
+ href: '/pages/motion-lab/springs/',
hrefLabel: 'Tune the four springs',
urgency: 'decide first',
},
@@ -168,7 +168,7 @@ export const OPEN_QUESTIONS: ReadonlyArray<OpenQuestion> = [
'A designer and an accessibility sign-off. Note that delete is not the status quo by accident — it is what the published page instructs, so degrading is a policy change.',
blocks:
'The 36-file sweep, which writes whichever branch is chosen 36 times, and the reduced-motion hook, which has to return a policy rather than a boolean.',
- href: '/motion/reduced-motion',
+ href: '/pages/motion-lab/reduced-motion/',
hrefLabel: 'Both policies, side by side',
urgency: 'decide before the sweep',
},
@@ -179,7 +179,7 @@ export const OPEN_QUESTIONS: ReadonlyArray<OpenQuestion> = [
'A prototype of press feedback on the independent scale property. The evidence supports the brief: Button transitions transform at Button/Button.tsx:90 and takes scale(0.98) on :active, so it is exactly the conflict the brief describes.',
blocks:
'Rubric criterion 12, and the press token. The middle path costs one property name.',
- href: '/motion/library',
+ href: '/pages/motion-lab/library/',
hrefLabel: 'transform vs scale vs none',
urgency: 'decide before publishing',
},
@@ -190,7 +190,7 @@ export const OPEN_QUESTIONS: ReadonlyArray<OpenQuestion> = [
'A repo-convention call. Wiki keeps the published page clean; it also means reviewers and consumers read different documents, which is part of why the transform-only rule never reached anyone outside the team.',
blocks:
'Rubric publication, and whether consumers can self-assess before promotion.',
- href: '/motion/rubric',
+ href: '/pages/motion-lab/rubric/',
hrefLabel: 'The bench',
urgency: 'decide before publishing',
},
@@ -201,7 +201,7 @@ export const OPEN_QUESTIONS: ReadonlyArray<OpenQuestion> = [
'A bake-off verdict. It probably has no single winner — a table row cannot be a grid container — so the honest answer may be one technique with a documented exception.',
blocks:
'Converging nine surfaces, and any new disclosure surface built meanwhile.',
- href: '/motion/previews',
+ href: '/pages/motion-lab/previews/',
hrefLabel: 'The three techniques',
urgency: 'decide before the sweep',
},
@@ -213,7 +213,7 @@ export const OPEN_QUESTIONS: ReadonlyArray<OpenQuestion> = [
'A ruling. The scale stops at 1300ms, so StatusDot at 2s and Chat at 1.5s bypass it entirely; both are in the hardcoded list because of it.',
blocks:
'Those two sites in the sweep, and the definition of --duration-continuous.',
- href: '/motion/tokens',
+ href: '/pages/motion-lab/tokens/',
hrefLabel: 'The duration scale',
urgency: 'decide before the sweep',
},
@@ -224,7 +224,7 @@ export const OPEN_QUESTIONS: ReadonlyArray<OpenQuestion> = [
'A decision on the shape, not the values. Recommendation: one shared vocabulary, per-platform values — the same names resolving to different numbers, the way the colour tokens already work. Two vocabularies means two rubrics and two docs pages.',
blocks:
'Token naming, so it is cheap now and expensive after the sweep. Raised in review on the Semantic motion tokens deliverable.',
- href: '/motion/tokens',
+ href: '/pages/motion-lab/tokens/',
hrefLabel: 'The proposed vocabulary',
urgency: 'decide first',
},
@@ -235,7 +235,7 @@ export const OPEN_QUESTIONS: ReadonlyArray<OpenQuestion> = [
'A call on what the theme contract exposes. The Collapsible reveal already introduced per-component theme-tunable motion, a sixth theming mechanism no doc describes, so the answer affects more than motion.',
blocks:
'The docs rewrite, and the springs question above — both are asking what a theme is allowed to retune. Raised in review on Deliverables.',
- href: '/motion/export',
+ href: '/pages/motion-lab/export/',
hrefLabel: 'What the lab emits',
urgency: 'decide before publishing',
},
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/page.tsx
index 8fd56a1b4f..a77bee4f37 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/page.tsx
@@ -1,10 +1,360 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's overview page.
+ * @file page.tsx
+ * @input Generated audit, brief figures, section registry
+ * @output The Motion Lab overview
+ * @position /motion
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * Opens on the disagreement between the brief and the code rather than on the
+ * brief's numbers, because that is the first thing anyone acting on this needs
+ * to know: the audit was written against a reading of the repo, and the repo
+ * says something slightly different in several places.
*/
-export {default} from '../../../../motion/pages/overview';
+import * as stylex from '@stylexjs/stylex';
+import Link from 'next/link';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Card} from '@astryxdesign/core/Card';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Link as AstryxLink} from '@astryxdesign/core/Link';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import {AUDIT_COUNTS, CORE_VERSION} from './__generated__/motionAudit';
+import {GUIDANCE_CONFLICTS, PUBLISHED_PAGE_URL} from './publishedGuidance';
+import {MOTION_SECTIONS} from './sections';
+import {LabPage} from './PageFrame';
+
+const sx = stylex.create({
+ stat: {padding: '14px'},
+ statValue: {
+ fontSize: '26px',
+ fontWeight: 650,
+ letterSpacing: '-0.02em',
+ lineHeight: 1.1,
+ },
+ bad: {color: 'var(--color-text-error, #d3543f)'},
+ warn: {color: 'var(--color-text-warning, #b3760a)'},
+ full: {width: '100%'},
+ cardLink: {textDecoration: 'none', color: 'inherit', display: 'block'},
+});
+
+/**
+ * The brief's figures beside the measured ones. Rows only appear here when
+ * they differ — a table of agreements would bury the four that matter.
+ */
+const RECONCILIATION: ReadonlyArray<{
+ readonly measure: string;
+ readonly brief: string;
+ readonly measured: string;
+ readonly reading: string;
+}> = [
+ {
+ measure: 'Component directories',
+ brief: '107 (90 core, 17 lab)',
+ measured: `${AUDIT_COUNTS.componentDirs} (${AUDIT_COUNTS.coreComponentDirs} core, ${AUDIT_COUNTS.labComponentDirs} lab)`,
+ reading:
+ 'Lab matches exactly. Core is higher than the brief\u2019s 90 — the split it quotes is close but not current.',
+ },
+ {
+ measure: 'Animate something',
+ brief: '63',
+ measured: String(AUDIT_COUNTS.animatingComponents),
+ reading:
+ 'Counted as component directories with at least one transition, animation or keyframe. The brief counted across core and lab together.',
+ },
+ {
+ measure: 'Hardcoded duration / easing',
+ brief: '28',
+ measured: String(AUDIT_COUNTS.hardcodedTotal),
+ reading:
+ 'Higher, not lower. The brief undercounts: the sweep is bigger than budgeted, and about a quarter of it is a reduced-motion idiom rather than carelessness.',
+ },
+ {
+ measure: 'Files animating with no reduced-motion branch',
+ brief: '39',
+ measured: String(AUDIT_COUNTS.filesWithoutReducedMotion),
+ reading:
+ 'Close. The gap is counting method, not a disagreement worth chasing.',
+ },
+ {
+ measure: 'Dead no-op transitions',
+ brief: '3, in Selector / ComplexSelector / MultiSelector',
+ measured: `${AUDIT_COUNTS.noopTransitions}, in Lightbox`,
+ reading:
+ 'The brief\u2019s three do not exist as described. The one real instance is a deliberate transitionProperty: none. Worth re-checking before it becomes a milestone line item.',
+ },
+ {
+ measure: 'CSS transition on transform',
+ brief: '20+ components',
+ measured: `${AUDIT_COUNTS.transformTransitions} sites, ${AUDIT_COUNTS.transformTransitionComponents} components`,
+ reading:
+ 'The brief is right, and this row is a caution about the tool rather than the doc: two earlier versions of the audit script reported 13 across 9, because a wrapped value and a nested StyleX rule each hid matches. Trust a generated number only as far as its generator has been tested.',
+ },
+];
+
+function Stat({
+ value,
+ label,
+ detail,
+ tone,
+}: {
+ value: string | number;
+ label: string;
+ detail?: string;
+ tone?: 'bad' | 'warn';
+}) {
+ return (
+ <Card padding={0} {...stylex.props(sx.full)}>
+ <VStack gap={0.5} {...stylex.props(sx.stat)}>
+ <span
+ {...stylex.props(
+ sx.statValue,
+ tone === 'bad' && sx.bad,
+ tone === 'warn' && sx.warn,
+ )}>
+ {value}
+ </span>
+ <Text type="supporting">{label}</Text>
+ {detail != null && (
+ <Text type="supporting" color="secondary">
+ {detail}
+ </Text>
+ )}
+ </VStack>
+ </Card>
+ );
+}
+
+export default function MotionOverviewPage() {
+ const reversals = GUIDANCE_CONFLICTS.filter(c => c.severity === 'reversal');
+
+ return (
+ <LabPage
+ title="Motion Lab"
+ intro="A bench for the H2 2026 motion proposals. Every proposal is here as a working before-and-after with its values exposed as controls, so the decisions get made by looking rather than by arguing about numbers in a document."
+ badges={<Badge variant="info" label={`core@${CORE_VERSION}`} />}
+ decides="Whether the audit in the brief matches the code, and which decisions are actually blocking.">
+ <Banner
+ status="warning"
+ title={`${reversals.length} of the proposals reverse guidance Astryx publishes today`}
+ description={
+ <Text>
+ The published Motion page tells authors that tooltips, hover cards
+ and dropdown menus <em>may</em> disappear instantly, and that
+ reduced motion means replacing animation with instant state changes.
+ The eleven-component exit gap is not drift — it is that paragraph,
+ correctly followed. Read the conflicts before planning any of this
+ work.
+ </Text>
+ }
+ endContent={
+ <AstryxLink href="/pages/motion-lab/published/">
+ See the conflicts
+ </AstryxLink>
+ }
+ />
+
+ <VStack gap={3}>
+ <Heading level={2}>Measured against the installed package</Heading>
+ <Text color="secondary">
+ Generated by <code>scripts/generate-motion-audit.mjs</code> from{' '}
+ <code>packages/core/src</code> and <code>packages/lab/src</code> at
+ core@
+ {CORE_VERSION}, so these move when the packages do. Every finding
+ carries the package it is in.
+ </Text>
+ <Grid columns={{minWidth: 210}} gap={3}>
+ <Stat
+ value={AUDIT_COUNTS.componentDirs}
+ label="Component directories"
+ detail={`${AUDIT_COUNTS.animatingComponents} animate, ${AUDIT_COUNTS.staticComponents} do not`}
+ />
+ <Stat
+ value={1}
+ label="Easing tokens"
+ detail="--ease-standard, for every job"
+ tone="bad"
+ />
+ <Stat
+ value={9}
+ label="Duration tokens"
+ detail="named by size, not by job"
+ />
+ <Stat
+ value={AUDIT_COUNTS.hardcodedTotal}
+ label="Hardcoded duration / easing"
+ detail={`${AUDIT_COUNTS.hardcodedDuration} durations, ${AUDIT_COUNTS.hardcodedEasing} curves`}
+ tone="bad"
+ />
+ <Stat
+ value={AUDIT_COUNTS.filesWithoutReducedMotion}
+ label="Animated files with no reduced-motion branch"
+ detail={`of ${AUDIT_COUNTS.animatedFiles} animated files`}
+ tone="bad"
+ />
+ <Stat
+ value={AUDIT_COUNTS.durationWithoutCurve}
+ label="Durations with no declared curve"
+ detail="silently getting the CSS default"
+ tone="warn"
+ />
+ <Stat
+ value={AUDIT_COUNTS.transformTransitions}
+ label="Transitions on transform"
+ detail={`across ${AUDIT_COUNTS.transformTransitionComponents} components`}
+ tone="warn"
+ />
+ <Stat
+ value={AUDIT_COUNTS.getComputedStyleReads}
+ label="getComputedStyle reads"
+ detail="the JS mirror's caseload"
+ />
+ </Grid>
+ </VStack>
+
+ <Banner
+ status="info"
+ title="How the counting works, and where it misleads"
+ description={
+ <Text>
+ The audit attributes motion to the component directory the file sits
+ in. Astryx composes heavily, so a surface can animate without a
+ single transition in its own folder — Tooltip, HoverCard, Popover,
+ Typeahead and the rest inherit theirs from <code>Layer/</code>,
+ AlertDialog from <code>Dialog/</code>, IconButton and ToggleButton
+ from <code>Button/</code>, FieldStatus from{' '}
+ <code>hooks/containerReveal.stylex.ts</code>. Read the per-component
+ numbers as &ldquo;where the motion is authored&rdquo;, not
+ &ldquo;which components move&rdquo;. The same trap is waiting for
+ the rubric: a per-component score has to follow composition, or it
+ will fail a component for a curve it does not own.
+ </Text>
+ }
+ />
+
+ <VStack gap={3}>
+ <Heading level={2}>Where the brief and the code disagree</Heading>
+ <Text color="secondary">
+ Only the rows that differ. Everything else in the audit checked out.
+ </Text>
+ <Card padding={0}>
+ <Table density="balanced">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Measure</TableHeaderCell>
+ <TableHeaderCell>Brief</TableHeaderCell>
+ <TableHeaderCell>Measured</TableHeaderCell>
+ <TableHeaderCell>Reading</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {RECONCILIATION.map(row => (
+ <TableRow key={row.measure}>
+ <TableCell>
+ <Text weight="semibold">{row.measure}</Text>
+ </TableCell>
+ <TableCell>
+ <Text color="secondary">{row.brief}</Text>
+ </TableCell>
+ <TableCell>
+ <Text>{row.measured}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {row.reading}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>How to use the bench</Heading>
+ <Grid columns={{minWidth: 280}} gap={3}>
+ <Card padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">The rail applies everywhere</Text>
+ <Text type="supporting" color="secondary">
+ Slow-mo stretches every duration without moving the token, so
+ you can judge a 175ms curve at 8&times; and still export 175ms.
+ Reduced motion drives the real policy switch. Show hides one
+ half of every comparison.
+ </Text>
+ </VStack>
+ </Card>
+ <Card padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">Every slider writes a real token</Text>
+ <Text type="supporting" color="secondary">
+ Tune a value anywhere and every demo in the section updates,
+ because they all read the same custom property. When it feels
+ right, the export page emits the token block and the JS mirror.
+ </Text>
+ </VStack>
+ </Card>
+ <Card padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">Numbers are generated, prose is not</Text>
+ <Text type="supporting" color="secondary">
+ Counts and file:line citations come from the audit script.
+ Judgements about what they mean are written, and are the part
+ worth arguing with.
+ </Text>
+ </VStack>
+ </Card>
+ </Grid>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Sections</Heading>
+ <Grid columns={{minWidth: 300}} gap={3}>
+ {MOTION_SECTIONS.filter(s => s.href !== '/pages/motion-lab/').map(
+ section => (
+ <Link
+ key={section.href}
+ href={section.href}
+ {...stylex.props(sx.cardLink)}>
+ <Card padding={4} {...stylex.props(sx.full)}>
+ <VStack gap={1}>
+ <HStack gap={1.5} vAlign="center">
+ <Text weight="semibold">{section.title}</Text>
+ <Badge label={section.group} />
+ </HStack>
+ <Text type="supporting" color="secondary">
+ {section.decides}
+ </Text>
+ </VStack>
+ </Card>
+ </Link>
+ ),
+ )}
+ </Grid>
+ </VStack>
+
+ <Text type="supporting" color="secondary">
+ Published guidance:{' '}
+ <AstryxLink
+ href={PUBLISHED_PAGE_URL}
+ target="_blank"
+ rel="noopener noreferrer">
+ astryx.atmeta.com/docs/motion
+ </AstryxLink>
+ </Text>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/plan/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/plan/page.tsx
index 6f57469859..692fd2d29d 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/plan/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/plan/page.tsx
@@ -1,10 +1,279 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's plan page.
+ * @file page.tsx
+ * @input openQuestions.ts
+ * @output The sequence, what gates each stage, and who has to answer what
+ * @position /motion/plan
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * The ordering here is a dependency graph, not a schedule. Most of its edges
+ * are decisions: nine of them are still open, and four of those sit above the
+ * first stage that would write code.
*/
-export {default} from '../../../../../motion/pages/plan';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Card} from '@astryxdesign/core/Card';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Link as AstryxLink} from '@astryxdesign/core/Link';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import {AUDIT_COUNTS} from '../__generated__/motionAudit';
+import {DemoBody, DemoCard} from '../LabPrimitives';
+import {LabPage} from '../PageFrame';
+import {
+ BRIEF_DEFECTS,
+ COMMITMENTS,
+ OPEN_QUESTIONS,
+ RISKS,
+ STAGES,
+ type OpenQuestion,
+} from '../openQuestions';
+
+const URGENCY_VARIANT: Record<
+ OpenQuestion['urgency'],
+ 'error' | 'warning' | 'neutral'
+> = {
+ 'decide first': 'error',
+ 'decide before the sweep': 'warning',
+ 'decide before publishing': 'warning',
+ 'can run late': 'neutral',
+};
+
+export default function MotionPlanPage() {
+ const blocking = OPEN_QUESTIONS.filter(q => q.urgency === 'decide first');
+ const committed = COMMITMENTS.filter(c => c.level === 'committed');
+ const stretch = COMMITMENTS.filter(c => c.level === 'stretch');
+
+ return (
+ <LabPage
+ title="Plan & open questions"
+ intro="A dependency order for the work, the decisions that gate each stage, and the ones nobody has made yet. Sizes are relative; there are no dates, because the brief has none either."
+ badges={
+ <Badge
+ variant="warning"
+ label={`${OPEN_QUESTIONS.length} open questions`}
+ />
+ }
+ decides="Sequence, gates, and who has to answer what.">
+ <Banner
+ status="warning"
+ title={`${blocking.length} decisions sit above the first line of code`}
+ description={
+ <Text>
+ Springs in the theme contract and the mobile-token vocabulary both
+ change the shape of the token contract, and both are breaking
+ changes if they arrive after Foundation ships. Everything else can
+ be decided while work runs — these two cannot.
+ </Text>
+ }
+ />
+
+ <VStack gap={3}>
+ <Heading level={2}>Sequence</Heading>
+ <Text color="secondary">
+ Each stage lists what blocks it. A stage whose gate is still open does
+ not start early; it starts twice.
+ </Text>
+ {STAGES.map(stage => (
+ <DemoCard
+ key={stage.id}
+ title={`${stage.index}. ${stage.name}`}
+ question={stage.goal}
+ badges={<Badge label={stage.size} />}>
+ <DemoBody>
+ <VStack gap={1}>
+ {stage.work.map((item, i) => (
+ <Text key={item} color="secondary">
+ {`${i + 1}. ${item}`}
+ </Text>
+ ))}
+ </VStack>
+ {stage.blockedBy.length > 0 ? (
+ <VStack gap={1.5}>
+ {stage.blockedBy.map(gate => (
+ <HStack key={gate} gap={2} vAlign="center" wrap="wrap">
+ <Badge variant="error" label="gate" />
+ <Text type="supporting" color="secondary">
+ {gate}
+ </Text>
+ </HStack>
+ ))}
+ </VStack>
+ ) : (
+ <HStack gap={2} vAlign="center">
+ <Badge variant="success" label="unblocked" />
+ <Text type="supporting" color="secondary">
+ Nothing blocks this. It is the only stage that can start
+ today.
+ </Text>
+ </HStack>
+ )}
+ </DemoBody>
+ </DemoCard>
+ ))}
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Scope discipline</Heading>
+ <Banner
+ status="error"
+ title="Do not combine token retuning, presence architecture and component remediation in one rollout"
+ description={
+ <Text>
+ All three move the visual-regression baselines. Rolled out
+ separately, a failure is attributable: a baseline moved because a
+ curve changed, or because a surface now animates out, or because a
+ component was rewritten. Rolled out together, every failure is a
+ bisect, and the bisect is across a quarter of work. This is also
+ why Foundation ships tokens as aliases before it retunes a single
+ value — the alias step is provably invisible, so anything the
+ capture catches afterwards belongs to the retune.
+ </Text>
+ }
+ />
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Open questions</Heading>
+ <Text color="secondary">
+ Each one names what it needs, what it blocks, and where in the lab you
+ can look at it instead of arguing about it.
+ </Text>
+ {OPEN_QUESTIONS.map(question => (
+ <Card key={question.id} padding={4}>
+ <VStack gap={2}>
+ <HStack gap={2} vAlign="center" wrap="wrap" justify="between">
+ <Text weight="semibold">{question.question}</Text>
+ <Badge
+ variant={URGENCY_VARIANT[question.urgency]}
+ label={question.urgency}
+ />
+ </HStack>
+ <Grid columns={{minWidth: 260}} gap={3}>
+ <VStack gap={1}>
+ <Text type="label" weight="semibold">
+ Needs
+ </Text>
+ <Text type="supporting" color="secondary">
+ {question.needs}
+ </Text>
+ </VStack>
+ <VStack gap={1}>
+ <Text type="label" weight="semibold">
+ Blocks
+ </Text>
+ <Text type="supporting" color="secondary">
+ {question.blocks}
+ </Text>
+ </VStack>
+ </Grid>
+ <AstryxLink href={question.href}>{question.hrefLabel}</AstryxLink>
+ </VStack>
+ </Card>
+ ))}
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Committed and stretch</Heading>
+ <Text color="secondary">
+ {`Committed is what should be true at the end of H2 whatever else slips: ${committed.length} items. Stretch is ${stretch.length} more that are worth doing and safe to drop, because nothing in the committed list depends on them.`}
+ </Text>
+ <Card padding={0}>
+ <Table density="balanced">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Item</TableHeaderCell>
+ <TableHeaderCell>Level</TableHeaderCell>
+ <TableHeaderCell>Why</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {COMMITMENTS.map(item => (
+ <TableRow key={item.item}>
+ <TableCell>
+ <Text weight="semibold">{item.item}</Text>
+ </TableCell>
+ <TableCell>
+ <Badge
+ variant={
+ item.level === 'committed' ? 'success' : 'neutral'
+ }
+ label={item.level}
+ />
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {item.why}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Risks</Heading>
+ <Text color="secondary">
+ The brief&rsquo;s six, and what the lab does about each. One of them
+ the lab cannot help with at all, which is worth saying out loud.
+ </Text>
+ <Card padding={0}>
+ <Table density="balanced">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Risk</TableHeaderCell>
+ <TableHeaderCell>What the lab does about it</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {RISKS.map(risk => (
+ <TableRow key={risk.risk}>
+ <TableCell>
+ <Text>{risk.risk}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {risk.mitigation}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Defects in the brief itself</Heading>
+ <Text color="secondary">
+ {`Found while building the lab, alongside the measurement corrections on the overview — the sweep is ${AUDIT_COUNTS.hardcodedTotal} sites rather than 28, and the transform blocker is ${AUDIT_COUNTS.transformTransitions} sites rather than "20+".`}
+ </Text>
+ <Grid columns={{minWidth: 300}} gap={3}>
+ {BRIEF_DEFECTS.map(defect => (
+ <Card key={defect.defect} padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">{defect.defect}</Text>
+ <Text type="supporting" color="secondary">
+ {defect.detail}
+ </Text>
+ </VStack>
+ </Card>
+ ))}
+ </Grid>
+ </VStack>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/preview-plan/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/preview-plan/page.tsx
index 2a689fa8b1..edc0c7c1e4 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/preview-plan/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/preview-plan/page.tsx
@@ -1,10 +1,359 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's preview-plan page.
+ * @file page.tsx
+ * @input previewPlan.ts and the generated audit
+ * @output What every component's preview has to demonstrate before it is built
+ * @position /motion/preview-plan
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * A build plan, not a gallery. The column that matters is the hard case: a
+ * preview that only shows the easy case decides nothing, and most of the
+ * techniques in this project are chosen by one awkward instance rather than
+ * by the general shape.
*/
-export {default} from '../../../../../motion/pages/preview-plan';
+import {useMemo, useState} from 'react';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Card} from '@astryxdesign/core/Card';
+import {Divider} from '@astryxdesign/core/Divider';
+import {EmptyState} from '@astryxdesign/core/EmptyState';
+import {Grid} from '@astryxdesign/core/Grid';
+import {
+ SegmentedControl,
+ SegmentedControlItem,
+} from '@astryxdesign/core/SegmentedControl';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import {TextInput} from '@astryxdesign/core/TextInput';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {LabPage} from '../PageFrame';
+import {
+ PREVIEW_GROUPS,
+ PREVIEW_PLAN,
+ measure,
+ type PreviewRow,
+ type Verdict,
+} from '../previewPlan';
+
+const VERDICT_VARIANT: Record<
+ Verdict,
+ 'success' | 'warning' | 'error' | 'neutral'
+> = {
+ GOOD: 'success',
+ PARTIAL: 'warning',
+ ADD: 'error',
+ NONE: 'neutral',
+};
+
+const PRIORITY_LABEL: Record<1 | 2 | 3, string> = {
+ 1: 'P1 · decides an open question',
+ 2: 'P2 · high-frequency surface',
+ 3: 'P3 · completeness',
+};
+
+function Field({label, children}: {label: string; children: string}) {
+ return (
+ <VStack gap={0.5}>
+ <Text type="supporting" weight="semibold">
+ {label}
+ </Text>
+ <Text type="supporting" color="secondary">
+ {children}
+ </Text>
+ </VStack>
+ );
+}
+
+function RowCard({row}: {row: PreviewRow}) {
+ const measurement = measure(row);
+ return (
+ <Card padding={4}>
+ <VStack gap={2}>
+ <VStack gap={1}>
+ <HStack gap={1.5} vAlign="center" wrap="wrap">
+ <Text weight="semibold">{row.component}</Text>
+ <Badge variant={VERDICT_VARIANT[row.verdict]} label={row.verdict} />
+ <Badge
+ variant={row.status === 'built' ? 'success' : 'neutral'}
+ label={
+ row.status === 'built'
+ ? `built · ${row.rig ?? ''}`
+ : 'specified'
+ }
+ />
+ <Badge label={PRIORITY_LABEL[row.priority]} />
+ </HStack>
+ <HStack gap={3} wrap="wrap">
+ <Text type="supporting" color="secondary">
+ {`Today: ${row.today}`}
+ </Text>
+ </HStack>
+ <Text type="supporting" color="secondary">
+ {`Gap: ${row.gap}`}
+ </Text>
+ </VStack>
+
+ <Divider />
+
+ <Field label="The preview must show">{row.shows}</Field>
+ <Field label="The hard case that decides the technique">
+ {row.hardCase}
+ </Field>
+
+ {row.controls.length > 0 && (
+ <HStack gap={1} wrap="wrap">
+ {row.controls.map(control => (
+ <Badge key={control} variant="info" label={control} />
+ ))}
+ </HStack>
+ )}
+
+ {measurement.kind === 'contradiction' && (
+ <Banner
+ status="error"
+ title="Brief and measurement disagree"
+ description={<Text>{measurement.note}</Text>}
+ />
+ )}
+ {measurement.kind === 'nuance' && (
+ <Banner
+ status="warning"
+ title="Measured differently"
+ description={<Text>{measurement.note}</Text>}
+ />
+ )}
+ {measurement.kind === 'unmeasured' && measurement.note !== '' && (
+ <Text type="supporting" color="secondary">
+ {measurement.note}
+ </Text>
+ )}
+ </VStack>
+ </Card>
+ );
+}
+
+export default function PreviewPlanPage() {
+ const [verdict, setVerdict] = useState<string>('all');
+ const [status, setStatus] = useState<string>('all');
+ const [query, setQuery] = useState('');
+
+ const filtered = useMemo(() => {
+ const needle = query.trim().toLowerCase();
+ return PREVIEW_PLAN.filter(row => {
+ if (verdict !== 'all' && row.verdict !== verdict) {
+ return false;
+ }
+ if (status !== 'all' && row.status !== status) {
+ return false;
+ }
+ if (needle === '') {
+ return true;
+ }
+ return [
+ row.component,
+ row.today,
+ row.gap,
+ row.shows,
+ row.hardCase,
+ row.group,
+ ]
+ .join(' ')
+ .toLowerCase()
+ .includes(needle);
+ });
+ }, [verdict, status, query]);
+
+ const built = PREVIEW_PLAN.filter(row => row.status === 'built');
+ const specified = PREVIEW_PLAN.filter(row => row.status === 'specified');
+ const disagreements = PREVIEW_PLAN.filter(
+ row => measure(row).kind === 'contradiction',
+ );
+ const queue = [...specified].sort(
+ (a, b) =>
+ a.priority - b.priority ||
+ PREVIEW_GROUPS.indexOf(a.group) - PREVIEW_GROUPS.indexOf(b.group),
+ );
+
+ return (
+ <LabPage
+ title="Preview plan"
+ intro="Every component in the audit, what its preview has to demonstrate, and the controls it needs. The hard case is the column that matters: a preview that only shows the easy case is worth nothing."
+ badges={<Badge label={`${PREVIEW_PLAN.length} rows`} />}
+ decides="What every remaining preview has to show before it is worth building.">
+ <Grid columns={{minWidth: 200}} gap={3}>
+ <Card padding={4}>
+ <VStack gap={0.5}>
+ <Heading level={3}>{PREVIEW_PLAN.length}</Heading>
+ <Text type="supporting" color="secondary">
+ Rows across six surfaces
+ </Text>
+ </VStack>
+ </Card>
+ <Card padding={4}>
+ <VStack gap={0.5}>
+ <Heading level={3}>{built.length}</Heading>
+ <Text type="supporting" color="secondary">
+ Already have a rig in the lab
+ </Text>
+ </VStack>
+ </Card>
+ <Card padding={4}>
+ <VStack gap={0.5}>
+ <Heading level={3}>{specified.length}</Heading>
+ <Text type="supporting" color="secondary">
+ Specified, not built
+ </Text>
+ </VStack>
+ </Card>
+ <Card padding={4}>
+ <VStack gap={0.5}>
+ <Heading level={3}>{disagreements.length}</Heading>
+ <Text type="supporting" color="secondary">
+ Rows where the brief and the audit disagree
+ </Text>
+ </VStack>
+ </Card>
+ </Grid>
+
+ <Banner
+ status="warning"
+ title={`${disagreements.length} verdicts do not survive the measurement`}
+ description={
+ <Text>
+ Almost all of them are the same mechanism: the brief credits a
+ component with the motion it inherits, and the audit measures per
+ directory. Tooltip, HoverCard, Popover and the overflow layers get
+ their entry from <code>Layer/</code>; FieldStatus gets its slide
+ from <code>hooks/containerReveal.stylex.ts</code>. Neither reading
+ is wrong, but a rubric scoring components one at a time will score
+ these wrong unless it knows where to look.
+ </Text>
+ }
+ />
+
+ <VStack gap={3}>
+ <HStack gap={3} wrap="wrap" vAlign="end">
+ <SegmentedControl
+ label="Filter by verdict"
+ value={verdict}
+ onChange={setVerdict}
+ size="sm">
+ <SegmentedControlItem value="all" label="All" />
+ <SegmentedControlItem value="GOOD" label="GOOD" />
+ <SegmentedControlItem value="PARTIAL" label="PARTIAL" />
+ <SegmentedControlItem value="ADD" label="ADD" />
+ <SegmentedControlItem value="NONE" label="NONE" />
+ </SegmentedControl>
+ <SegmentedControl
+ label="Filter by status"
+ value={status}
+ onChange={setStatus}
+ size="sm">
+ <SegmentedControlItem value="all" label="All" />
+ <SegmentedControlItem value="built" label="Built" />
+ <SegmentedControlItem value="specified" label="Specified" />
+ </SegmentedControl>
+ <TextInput
+ label="Search"
+ isLabelHidden
+ placeholder="Search components, gaps, hard cases"
+ value={query}
+ onChange={setQuery}
+ hasClear
+ width={280}
+ />
+ <Text type="supporting" color="secondary">
+ {`${filtered.length} of ${PREVIEW_PLAN.length}`}
+ </Text>
+ </HStack>
+
+ {filtered.length === 0 ? (
+ <EmptyState
+ title="Nothing matches"
+ description="No row matches that combination of verdict, status and search."
+ />
+ ) : (
+ PREVIEW_GROUPS.map(group => {
+ const rows = filtered.filter(row => row.group === group);
+ if (rows.length === 0) {
+ return null;
+ }
+ return (
+ <VStack key={group} gap={2}>
+ <HStack gap={2} vAlign="center">
+ <Heading level={2}>{group}</Heading>
+ <Badge label={`${rows.length}`} />
+ </HStack>
+ <Grid columns={{minWidth: 420}} gap={3}>
+ {rows.map(row => (
+ <RowCard key={row.id} row={row} />
+ ))}
+ </Grid>
+ </VStack>
+ );
+ })
+ )}
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Build queue</Heading>
+ <Text color="secondary">
+ {`The ${specified.length} specified previews in priority order. P1 rows each settle an open question, so they are worth building before the decision meeting rather than after it.`}
+ </Text>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Priority</TableHeaderCell>
+ <TableHeaderCell>Component</TableHeaderCell>
+ <TableHeaderCell>Surface</TableHeaderCell>
+ <TableHeaderCell>Why it is worth building</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {queue.map(row => (
+ <TableRow key={row.id}>
+ <TableCell>
+ <Badge
+ variant={
+ row.priority === 1
+ ? 'error'
+ : row.priority === 2
+ ? 'warning'
+ : 'neutral'
+ }
+ label={`P${row.priority}`}
+ />
+ </TableCell>
+ <TableCell>
+ <Text weight="semibold">{row.component}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {row.group}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {row.hardCase}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ </VStack>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/motion/previewPlan.ts b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/previewPlan.ts
similarity index 100%
rename from apps/sandbox/src/motion/previewPlan.ts
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/previewPlan.ts
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/previews/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/previews/page.tsx
index 8220a478e2..e3e258fc93 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/previews/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/previews/page.tsx
@@ -1,10 +1,287 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's previews page.
+ * @file page.tsx
+ * @input LabDemos rigs, the lab store
+ * @output The coverage work, each as a working before-and-after
+ * @position /motion/previews
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * The "where to start" list from the brief, minus the presence work that has
+ * its own page. Ordered by user-visible impact per unit of work, which is the
+ * order the brief argues for and the order these should be picked up in.
*/
-export {default} from '../../../../../motion/pages/previews';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Link} from '@astryxdesign/core/Link';
+import {VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {LabPage} from '../PageFrame';
+import {ComparePanes, DemoBody, DemoCard, TokenSlider} from '../LabPrimitives';
+import {
+ CheckTickRig,
+ ChipRig,
+ DisclosureRig,
+ ListReorderRig,
+ RailRig,
+ SkeletonSwapRig,
+ StatCountRig,
+ TabIndicatorRig,
+} from '../LabDemos';
+
+export default function PreviewsPage() {
+ return (
+ <LabPage
+ title="Live previews"
+ intro="The coverage work, each as a working before-and-after. Every control writes a real token, so a value settled here is settled everywhere. Turn the rail up to 4× to judge a curve, then back to 1× to judge whether it is too slow — those are different questions and they need different speeds."
+ decides="Sliding indicators, disclosure convergence, the rail, chips, skeletons, lists.">
+ <Banner
+ status="info"
+ title="Ordered by impact per unit of work"
+ description={
+ <Text>
+ This is the brief&rsquo;s where-to-start list with the presence work
+ removed, since that has{' '}
+ <Link href="/pages/motion-lab/exit-gap/">its own page</Link> and is
+ the one thing here blocked on a policy decision. Everything below is
+ unblocked and can start as soon as the tokens land.
+ </Text>
+ }
+ />
+
+ <DemoCard
+ title="Sliding indicators"
+ question="TabList and SegmentedControl share one decision. A travelling indicator crossing five tabs feels different from one crossing two — judge it on the long jump, not the short one."
+ badges={<Badge variant="error" label="ADD" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — per-item cross-fade',
+ content: <TabIndicatorRig mode="before" />,
+ },
+ {
+ tone: 'after',
+ label: 'Proposed — one indicator travels',
+ content: <TabIndicatorRig mode="after" />,
+ },
+ ]}
+ />
+ <DemoBody>
+ <TokenSlider token="--duration-reveal" label="travel" max={700} />
+ <Text type="supporting" color="secondary">
+ The proposed pane uses <code>--ease-move</code> rather than the
+ entry curve, because the indicator is already on screen: it needs a
+ legible path, not an arrival accent. This is also the strongest
+ candidate for the <code>layout</code> spring, since a travelling
+ indicator is exactly the interruptible case.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="Disclosure bake-off"
+ question="Nine surfaces, three techniques, and the newest component uses the one nobody else does. Settle it before more disclosure surfaces get built."
+ badges={<Badge variant="warning" label="PARTIAL — three techniques" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'neutral',
+ label: 'Grid tracks — CodeBlock, Chat',
+ content: <DisclosureRig technique="grid" title="Grid tracks" />,
+ },
+ {
+ tone: 'neutral',
+ label: 'Height interpolation',
+ content: <DisclosureRig technique="height" title="Height" />,
+ },
+ {
+ tone: 'after',
+ label: 'Height + offset fade — Collapsible',
+ content: <DisclosureRig technique="offset" title="Collapsible" />,
+ },
+ ]}
+ />
+ <DemoBody>
+ <TokenSlider token="--duration-reveal" label="reveal" max={700} />
+ <Text type="supporting" color="secondary">
+ There is probably no single winner. A table row cannot be a grid
+ container, so Table row expansion and Table tree cannot use the
+ grid-track technique whatever the bake-off concludes. The realistic
+ outcome is one default plus a documented exception — which is worth
+ writing down as the decision, rather than discovering it halfway
+ through the convergence work.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="SideNav rail collapse"
+ question="The rail's own width, not just the chevron. width is a layout property, so this is a deliberate criterion-6 exception — does it earn one?"
+ badges={<Badge variant="error" label="ADD" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — only the chevron rotates',
+ content: <RailRig mode="before" />,
+ },
+ {
+ tone: 'after',
+ label: 'Proposed — the rail animates',
+ content: <RailRig mode="after" />,
+ },
+ ]}
+ />
+ <DemoBody>
+ <Text type="supporting" color="secondary">
+ The transform alternative — translate the rail and clip it — keeps
+ the animation on the compositor but leaves the content beside it
+ un-reflowed until the end, which reads worse than the layout cost.
+ Worth prototyping both before granting the exception.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="Skeleton → content"
+ question="The archetypal hard swap. The failure is that it happens at a moment the user cannot predict."
+ badges={<Badge variant="error" label="ADD" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — content hard-swaps',
+ content: <SkeletonSwapRig mode="before" />,
+ },
+ {
+ tone: 'after',
+ label: 'Proposed — crossfade with overlap',
+ content: <SkeletonSwapRig mode="after" />,
+ },
+ ]}
+ />
+ <DemoBody>
+ <TokenSlider token="--duration-state" label="crossfade" max={400} />
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="Chip add and remove"
+ question="Tokenizer, Token and FileInput share this. Removal is the hard half: the chip has to leave while its neighbours close the gap."
+ badges={<Badge variant="error" label="ADD" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — instant',
+ content: <ChipRig mode="before" />,
+ },
+ {
+ tone: 'after',
+ label: 'Proposed — scale in, accelerate away',
+ content: <ChipRig mode="after" />,
+ },
+ ]}
+ />
+ <DemoBody>
+ <TokenSlider token="--duration-enter" label="add" max={500} />
+ <TokenSlider token="--duration-exit" label="remove" max={500} />
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="List add, remove and reorder"
+ question="Reorder is movement the user did not initiate, so it has to be followable. This is the strongest argument for the layout spring."
+ badges={<Badge variant="error" label="ADD" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — instant',
+ content: <ListReorderRig mode="before" />,
+ },
+ {
+ tone: 'after',
+ label: 'Proposed — FLIP on --ease-move',
+ content: <ListReorderRig mode="after" />,
+ },
+ ]}
+ />
+ <DemoBody>
+ <Text type="supporting" color="secondary">
+ FLIP — measure, move, invert, play — is the technique here because
+ the rows are genuinely re-laid-out and only the visual correction is
+ animated. Try it at 4×: a shuffle that is legible at 4× and
+ illegible at 1× means the duration is too short, not that the
+ technique is wrong.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <Grid columns={{minWidth: 420}} gap={4}>
+ <DemoCard
+ title="Checkbox tick"
+ question="A high-frequency surface, so criterion 2 applies: the answer may be that it should be almost nothing."
+ badges={<Badge variant="error" label="ADD" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today',
+ content: <CheckTickRig technique="hard" />,
+ },
+ {
+ tone: 'neutral',
+ label: 'Draw',
+ content: <CheckTickRig technique="draw" />,
+ },
+ {
+ tone: 'after',
+ label: 'Scale',
+ content: <CheckTickRig technique="scale" />,
+ },
+ ]}
+ />
+ </DemoCard>
+
+ <DemoCard
+ title="Stat value change"
+ question="A change of 4 and a change of 4,000 look identical today. Needs a delta threshold, or a jump from 12 to 1,300,000 spins for a second."
+ badges={<Badge variant="error" label="ADD" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — replaces itself',
+ content: <StatCountRig mode="before" />,
+ },
+ {
+ tone: 'after',
+ label: 'Proposed — counts',
+ content: <StatCountRig mode="after" />,
+ },
+ ]}
+ />
+ </DemoCard>
+ </Grid>
+
+ <VStack gap={2}>
+ <Heading level={2}>What is not here</Heading>
+ <Text color="secondary">
+ Around twenty more previews are specified but not built —
+ ContextMenu&rsquo;s pointer-anchored origin, CommandPalette filter
+ motion, TreeList depth, TransferList&rsquo;s cross-container move,
+ Carousel, Calendar month change, Slider keyboard step, Resizable snap.
+ Each one has a written brief saying what it must demonstrate, on{' '}
+ <Link href="/pages/motion-lab/preview-plan/">Preview plan</Link>. The
+ ones above were built first because each settles a decision that
+ blocks other work.
+ </Text>
+ </VStack>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/published/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/published/page.tsx
index 193dcfe4ba..b56225baa7 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/published/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/published/page.tsx
@@ -1,10 +1,281 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's published page.
+ * @file page.tsx
+ * @input GUIDANCE_CONFLICTS and PUBLISHED_SECTIONS
+ * @output The proposal beside what astryx.atmeta.com/docs/motion tells authors
+ * @position /motion/published
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * The exit gap and the delete-don't-degrade behaviour are both documented
+ * guidance, correctly followed. That makes two of the proposals policy
+ * reversals rather than bug fixes, which changes who has to sign them off and
+ * what has to ship in the same stack. Every card here is one conflict; nothing
+ * on the page is written by hand except the reading of it.
+ */
+
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Button} from '@astryxdesign/core/Button';
+import {Card} from '@astryxdesign/core/Card';
+import {Link as AstryxLink} from '@astryxdesign/core/Link';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import type {ReactNode} from 'react';
+import {ComparePanes, DemoCard} from '../LabPrimitives';
+import {LayerRig, LoopRig} from '../LabDemos';
+import {LabPage} from '../PageFrame';
+import {
+ GUIDANCE_CONFLICTS,
+ PUBLISHED_PAGE_URL,
+ PUBLISHED_SECTIONS,
+ type GuidanceConflict,
+} from '../publishedGuidance';
+
+type Severity = GuidanceConflict['severity'];
+
+const SEVERITY: Record<
+ Severity,
+ {
+ readonly variant: 'error' | 'warning' | 'success';
+ readonly question: string;
+ }
+> = {
+ reversal: {
+ variant: 'error',
+ question:
+ 'Two documents give opposite instructions. One of them has to move first.',
+ },
+ extension: {
+ variant: 'warning',
+ question:
+ 'The page is not wrong, it is incomplete. Does the proposal extend it or replace it?',
+ },
+ aligned: {
+ variant: 'success',
+ question:
+ 'No conflict. Can the rubric cite this paragraph instead of re-arguing it?',
+ },
+};
+
+/** `exit-optional` -> `Exit optional`. The data carries no title, so derive one. */
+function titleOf(id: string): string {
+ const words = id.replace(/-/g, ' ');
+ return words.charAt(0).toUpperCase() + words.slice(1);
+}
+
+/**
+ * Only two conflicts can be settled by looking rather than reading, and both
+ * are the reversals. The rest are arguments about wording.
*/
+function demoFor(id: string, tone: 'before' | 'after'): ReactNode {
+ if (id === 'exit-optional') {
+ return tone === 'before' ? (
+ <LayerRig mode="before" label="Tooltip content" triggerLabel="Hover me" />
+ ) : (
+ <LayerRig mode="after" label="Tooltip content" triggerLabel="Hover me" />
+ );
+ }
+ if (id === 'reduced-motion-delete') {
+ return tone === 'before' ? (
+ <LoopRig policy="delete" />
+ ) : (
+ <LoopRig policy="degrade" />
+ );
+ }
+ return null;
+}
+
+function Quote({text, demo}: {text: string; demo: ReactNode}) {
+ return (
+ <VStack gap={3}>
+ <Card padding={3}>
+ <Text>{`\u201C${text}\u201D`}</Text>
+ </Card>
+ {demo}
+ </VStack>
+ );
+}
+
+export default function PublishedGuidancePage() {
+ const reversals = GUIDANCE_CONFLICTS.filter(c => c.severity === 'reversal');
+ const extensions = GUIDANCE_CONFLICTS.filter(c => c.severity === 'extension');
+ const aligned = GUIDANCE_CONFLICTS.filter(c => c.severity === 'aligned');
+ const rewriteSections = new Set(reversals.map(c => c.section));
+ const noted = PUBLISHED_SECTIONS.filter(s => s.stale != null);
+
+ return (
+ <LabPage
+ title="Against the published page"
+ intro="Every proposal in the brief, beside the paragraph of astryx.atmeta.com/docs/motion it lands on. Quotes are verbatim, so this page can be diffed against the live one."
+ badges={<Badge variant="error" label={`${reversals.length} reversals`} />}
+ decides="Which proposals are bug fixes and which are reversals of guidance Astryx publishes today.">
+ <Banner
+ status="error"
+ title={`${reversals.length} of the ${GUIDANCE_CONFLICTS.length} conflicts reverse published guidance`}
+ description={
+ <Text>
+ The brief reads the exit gap as historical accident. It is not: the
+ published Movement Principles tell authors that tooltips, hover
+ cards and dropdown menus may disappear instantly, and Respecting
+ User Preferences tells them to replace animation with instant state
+ changes. Those two proposals are{' '}
+ <strong>policy changes, not bug fixes</strong> — they need a
+ decision and an owner rather than a diff. The doc rewrite has to
+ ship in the same stack as the code, or the rubric starts failing
+ components for doing what the docs still tell the next author to do.
+ </Text>
+ }
+ endContent={
+ <AstryxLink
+ href={PUBLISHED_PAGE_URL}
+ target="_blank"
+ rel="noopener noreferrer">
+ Read the live page
+ </AstryxLink>
+ }
+ />
+
+ <HStack gap={2} wrap="wrap">
+ <Badge variant="error" label={`${reversals.length} reversals`} />
+ <Badge variant="warning" label={`${extensions.length} extensions`} />
+ <Badge variant="success" label={`${aligned.length} aligned`} />
+ <Text type="supporting" color="secondary">
+ Severity is about the document, not the code: a reversal means the
+ published page has to change before the proposal is legitimate.
+ </Text>
+ </HStack>
+
+ {GUIDANCE_CONFLICTS.map(conflict => (
+ <DemoCard
+ key={conflict.id}
+ title={titleOf(conflict.id)}
+ question={SEVERITY[conflict.severity].question}
+ badges={
+ <>
+ <Badge
+ variant={SEVERITY[conflict.severity].variant}
+ label={conflict.severity}
+ />
+ <Badge label={conflict.section} />
+ </>
+ }
+ actions={
+ <Button
+ variant="ghost"
+ size="sm"
+ label="See it in the lab"
+ href={conflict.href}
+ />
+ }
+ controls={
+ <VStack gap={3}>
+ <VStack gap={1}>
+ <Text type="label" weight="semibold">
+ Reading
+ </Text>
+ <Text color="secondary">{conflict.reading}</Text>
+ </VStack>
+ <VStack gap={1}>
+ <Text type="label" weight="semibold">
+ Resolution
+ </Text>
+ <Text color="secondary">{conflict.resolution}</Text>
+ </VStack>
+ </VStack>
+ }>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: `Published today — ${conflict.section}`,
+ content: (
+ <Quote
+ text={conflict.published}
+ demo={demoFor(conflict.id, 'before')}
+ />
+ ),
+ },
+ {
+ tone: 'after',
+ label: 'Proposed in the brief',
+ content: (
+ <Quote
+ text={conflict.proposed}
+ demo={demoFor(conflict.id, 'after')}
+ />
+ ),
+ },
+ ]}
+ />
+ </DemoCard>
+ ))}
+
+ <VStack gap={3}>
+ <Heading level={2}>Scope of the doc rewrite</Heading>
+ <Text color="secondary">
+ {`${noted.length} of the ${PUBLISHED_SECTIONS.length} sections of the live page need something. Two of them are the reversals above and cannot be deferred: the rubric has no authority while the page contradicts it. The rest are additions — the page is accurate about what exists, and silent about how to choose.`}
+ </Text>
+ <Card padding={0}>
+ <Table density="balanced">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Section</TableHeaderCell>
+ <TableHeaderCell>What it says today</TableHeaderCell>
+ <TableHeaderCell>Scope</TableHeaderCell>
+ <TableHeaderCell>Note</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {PUBLISHED_SECTIONS.map(section => {
+ const isRewrite = rewriteSections.has(section.title);
+ return (
+ <TableRow key={section.title}>
+ <TableCell>
+ <Text weight="semibold">{section.title}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {section.summary}
+ </Text>
+ </TableCell>
+ <TableCell>
+ {isRewrite ? (
+ <Badge variant="error" label="Rewrite" />
+ ) : section.stale != null ? (
+ <Badge variant="warning" label="Add to" />
+ ) : (
+ <Badge label="No change" />
+ )}
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {section.stale ?? '\u2014'}
+ </Text>
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ </TableBody>
+ </Table>
+ </Card>
+ </VStack>
-export {default} from '../../../../../motion/pages/published';
+ <Text type="supporting" color="secondary">
+ The rewrite is a deliverable in the brief already, listed last. On this
+ reading it is a gate on the rubric rather than a write-up of work
+ already done, which moves it earlier in the sequence than the timeline
+ has it.
+ </Text>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/motion/publishedGuidance.ts b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/publishedGuidance.ts
similarity index 97%
rename from apps/sandbox/src/motion/publishedGuidance.ts
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/publishedGuidance.ts
index bc1065ce10..91f99264ad 100644
--- a/apps/sandbox/src/motion/publishedGuidance.ts
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/publishedGuidance.ts
@@ -51,7 +51,7 @@ export const GUIDANCE_CONFLICTS: ReadonlyArray<GuidanceConflict> = [
resolution:
'Decide which document is right before writing any code. If the proposal wins, the rewrite of this paragraph ships in the same stack as the layerAnimations change, and the rubric cannot gate anything until it does.',
severity: 'reversal',
- href: '/motion/exit-gap',
+ href: '/pages/motion-lab/exit-gap/',
},
{
id: 'reduced-motion-delete',
@@ -65,7 +65,7 @@ export const GUIDANCE_CONFLICTS: ReadonlyArray<GuidanceConflict> = [
resolution:
'Needs a designer and accessibility sign-off, then a rewrite of this paragraph. The 39-file sweep writes whichever branch is chosen 39 times, so it cannot start first.',
severity: 'reversal',
- href: '/motion/reduced-motion',
+ href: '/pages/motion-lab/reduced-motion/',
},
{
id: 'exit-matches-entrance',
@@ -79,7 +79,7 @@ export const GUIDANCE_CONFLICTS: ReadonlyArray<GuidanceConflict> = [
resolution:
'Extend the paragraph rather than replace it: same path, opposite curve, shorter duration.',
severity: 'extension',
- href: '/motion/tokens',
+ href: '/pages/motion-lab/tokens/',
},
{
id: 'trigger-anchored',
@@ -92,7 +92,7 @@ export const GUIDANCE_CONFLICTS: ReadonlyArray<GuidanceConflict> = [
'The same rule, and the page already carries the exemption the rubric needs. Criterion 8 can cite this paragraph instead of re-arguing it.',
resolution: 'No change needed. Cite the published text in the rubric.',
severity: 'aligned',
- href: '/motion/rubric',
+ href: '/pages/motion-lab/rubric/',
},
{
id: 'frequency',
@@ -106,7 +106,7 @@ export const GUIDANCE_CONFLICTS: ReadonlyArray<GuidanceConflict> = [
resolution:
'No change needed. The rubric formalises what the page already says.',
severity: 'aligned',
- href: '/motion/violations',
+ href: '/pages/motion-lab/violations/',
},
{
id: 'direction',
@@ -119,7 +119,7 @@ export const GUIDANCE_CONFLICTS: ReadonlyArray<GuidanceConflict> = [
resolution:
'Add a directionality criterion, or fold it into criterion 4 (semantic correctness) so the rubric is a superset of the published guidance rather than a divergent list.',
severity: 'extension',
- href: '/motion/rubric',
+ href: '/pages/motion-lab/rubric/',
},
{
id: 'blocking',
@@ -133,7 +133,7 @@ export const GUIDANCE_CONFLICTS: ReadonlyArray<GuidanceConflict> = [
resolution:
'Write the input-during-exit rule into the presence primitive\u2019s contract, and cite this paragraph when doing it.',
severity: 'extension',
- href: '/motion/exit-gap',
+ href: '/pages/motion-lab/exit-gap/',
},
];
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.tsx
index 6253bbf91a..87adceca9f 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
@@ -1,10 +1,515 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's reduced-motion page.
+ * @file page.tsx
+ * @input The generated audit, the published guidance, the lab store
+ * @output Degrade or delete, with the sweep's worklist attached
+ * @position /motion/reduced-motion
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * The page's primary control is the rail's Reduced motion switch, not anything
+ * rendered here. It drives the real policy for every demo in the lab, so the
+ * argument is made by flipping it and watching rather than by reading a
+ * caption about what would happen.
+ */
+
+import * as stylex from '@stylexjs/stylex';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Card} from '@astryxdesign/core/Card';
+import {CodeBlock} from '@astryxdesign/core/CodeBlock';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Link} from '@astryxdesign/core/Link';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import {LabPage} from '../PageFrame';
+import {ComparePanes, DemoBody, DemoCard} from '../LabPrimitives';
+import {LoopRig, TintRig} from '../LabDemos';
+import {useMotionLab, type ReducedMotionMode} from '../MotionLabStore';
+import {
+ AUDIT_COUNTS,
+ HARDCODED_SITES,
+ NO_REDUCED_MOTION,
+} from '../__generated__/motionAudit';
+import {GUIDANCE_CONFLICTS, PUBLISHED_PAGE_URL} from '../publishedGuidance';
+
+const sx = stylex.create({
+ full: {width: '100%'},
+ mono: {fontFamily: 'var(--font-family-code)', fontSize: '12px'},
+ quote: {
+ borderInlineStart: '2px solid var(--color-border)',
+ paddingInlineStart: '12px',
+ maxWidth: '64ch',
+ },
+});
+
+const BRIEF_FIGURE = 39;
+
+const MODE_LABEL: Readonly<Record<ReducedMotionMode, string>> = {
+ off: 'Off',
+ degrade: 'Degrade',
+ delete: 'Delete',
+};
+
+/** The sweep's worklist: every animated file with no reduced-motion branch. */
+const WORKLIST = [
+ ...NO_REDUCED_MOTION.reduce((acc, row) => {
+ const files = acc.get(row.component) ?? [];
+ files.push(row.file);
+ acc.set(row.component, files);
+ return acc;
+ }, new Map<string, string[]>()),
+].sort((a, b) => b[1].length - a[1].length || a[0].localeCompare(b[0]));
+
+const INSTANT_ESCAPES = HARDCODED_SITES.filter(site => site.value === '0.01s');
+
+const POLICIES: ReadonlyArray<{
+ readonly policy: string;
+ readonly survives: string;
+ readonly forIt: string;
+ readonly againstIt: string;
+ readonly status: string;
+}> = [
+ {
+ policy: 'Delete',
+ survives:
+ 'Nothing. Transitions collapse to zero, loops stop, the end state arrives on the same frame as the change.',
+ forIt:
+ 'Safest reading of the accessibility guidance: a user who asked for no motion gets no motion, with no argument about which motion was the harmful kind. Trivially lintable, and it is one line per file.',
+ againstIt:
+ 'Deletes feedback that happens to be implemented as a transition. A hover tint, a focus ring fade and a spinner all disappear together, and the spinner leaves nothing behind that says "working".',
+ status:
+ 'What the published page instructs today, and what most of core does.',
+ },
+ {
+ policy: 'Degrade',
+ survives:
+ 'Opacity and colour. Movement multipliers go to zero; loops stop and are replaced with a determinate state.',
+ forIt:
+ 'Keeps state feedback while removing the vestibular trigger, which is what both of the project\u2019s references recommend. The thing that hurts is movement, not the fact that a colour took 175ms to arrive.',
+ againstIt:
+ 'Needs a judgement per component about which half is movement, so it is not a one-line sweep. Gets it wrong quietly: a fade that survives on a surface that also travels is still motion.',
+ status:
+ 'What rubric criterion 10 proposes. A change of published policy, not a bug fix.',
+ },
+];
+
+const CSS_RULE = `/* Movement is a multiplier, so the policy has one place to land. */
+.surface {
+ --motion-translate: 1;
+ --motion-scale: 1;
+ transform: translateY(calc(8px * var(--motion-translate)))
+ scale(calc(1 - 0.06 * var(--motion-scale)));
+ transition:
+ transform var(--duration-enter) var(--ease-entry),
+ opacity var(--duration-enter) var(--ease-entry),
+ background-color var(--duration-state) var(--ease-state);
+}
+
+/* Degrade: movement goes, opacity and colour stay. Not display: none for
+ motion — the feedback is the point, the travel is the problem. */
+@media (prefers-reduced-motion: reduce) {
+ .surface {
+ --motion-translate: 0;
+ --motion-scale: 0;
+ }
+
+ /* Loops stop. They do not slow down: slower vestibular motion is still
+ vestibular motion, and a 3s spinner reads as a hung interface. */
+ .spinner,
+ .progressIndeterminate {
+ animation: none;
+ }
+}
+
+/* Hover motion is gated on a fine pointer as well. A touch device fires a
+ hover on tap, so an un-gated hover animation runs on every tap. */
+@media (hover: hover) and (pointer: fine) {
+ .row:hover {
+ transform: translateY(calc(-1px * var(--motion-translate)));
+ }
+}
+
+/* An app with its own reduce-motion setting can flip a JS library but cannot
+ flip a media query, so the same rules answer to an attribute too. */
+[data-reduced-motion='reduce'] .surface {
+ --motion-translate: 0;
+ --motion-scale: 0;
+}`;
+
+const HOOK = `/**
+ * The JS half of the same policy. Charts, canvas and any motion library read
+ * this; CSS reads the media query. They have to agree, or a chart animates
+ * while the interface around it does not.
*/
+export function useReducedMotion(): boolean {
+ const [reduced, setReduced] = useState(() =>
+ typeof window === 'undefined'
+ ? false
+ : window.matchMedia('(prefers-reduced-motion: reduce)').matches,
+ );
+
+ useEffect(() => {
+ const query = window.matchMedia('(prefers-reduced-motion: reduce)');
+ const onChange = (event: MediaQueryListEvent) => setReduced(event.matches);
+ query.addEventListener('change', onChange);
+ return () => query.removeEventListener('change', onChange);
+ }, []);
+
+ // The app-level override, so a product setting can force the policy on
+ // without touching the OS. Same attribute the CSS above answers to.
+ const forced = useContext(MotionPreferenceContext);
+ return forced ?? reduced;
+}`;
+
+export default function ReducedMotionPage() {
+ const {reducedMotion} = useMotionLab();
+ const conflict = GUIDANCE_CONFLICTS.find(
+ c => c.id === 'reduced-motion-delete',
+ );
+
+ return (
+ <LabPage
+ title="Reduced motion"
+ intro="Degrade or delete. Everything else in the sweep is blocked on this answer, because the branch gets written once per file and there are 36 of them."
+ badges={
+ <>
+ <Badge variant="error" label="Criterion 10 — Blocker" />
+ <Badge
+ variant="warning"
+ label={`Rail: ${MODE_LABEL[reducedMotion]}`}
+ />
+ </>
+ }
+ decides="Degrade or delete. The decision the 36-file sweep is waiting on.">
+ <Banner
+ status="info"
+ title="Use the Reduced motion switch in the rail above"
+ description={
+ <Text>
+ It is the page&rsquo;s primary control, not a caption: it drives the
+ real policy for every demo in the lab, on this page and every other
+ one. Set it to <strong>Delete</strong>, then{' '}
+ <strong>Degrade</strong>, and watch the same components under each.
+ Right now it is set to <strong>{MODE_LABEL[reducedMotion]}</strong>.
+ </Text>
+ }
+ />
+
+ <VStack gap={3}>
+ <Heading level={2}>The sweep&rsquo;s worklist</Heading>
+ <Text color="secondary">
+ {AUDIT_COUNTS.filesWithoutReducedMotion} of{' '}
+ {AUDIT_COUNTS.animatedFiles} animated files have no{' '}
+ <code>prefers-reduced-motion</code> branch at all — measured against
+ the installed package. The brief says {BRIEF_FIGURE}; the gap is
+ counting method rather than a disagreement worth chasing, but the list
+ below is the one to work from because it names the files.
+ </Text>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Component</TableHeaderCell>
+ <TableHeaderCell>Files</TableHeaderCell>
+ <TableHeaderCell>Paths</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {WORKLIST.map(([component, files]) => (
+ <TableRow key={component}>
+ <TableCell>
+ <Text weight="semibold">{component}</Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {files.length}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {files.join(' · ')}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ <Text type="supporting" color="secondary">
+ {WORKLIST[0]?.[0]} carries {WORKLIST[0]?.[1].length} of them and{' '}
+ {WORKLIST[1]?.[0]} {WORKLIST[1]?.[1].length}, so two components are
+ more than a quarter of the sweep. Both are also the components where a
+ wrong answer is most visible.
+ </Text>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Degrade or delete</Heading>
+ <Card padding={0}>
+ <Table density="balanced">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Policy</TableHeaderCell>
+ <TableHeaderCell>What survives</TableHeaderCell>
+ <TableHeaderCell>For</TableHeaderCell>
+ <TableHeaderCell>Against</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {POLICIES.map(row => (
+ <TableRow key={row.policy}>
+ <TableCell>
+ <VStack gap={1}>
+ <Text weight="semibold">{row.policy}</Text>
+ <Text type="supporting" color="secondary">
+ {row.status}
+ </Text>
+ </VStack>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting">{row.survives}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {row.forIt}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {row.againstIt}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ {conflict != null && (
+ <Card padding={4}>
+ <VStack gap={2}>
+ <HStack gap={2} vAlign="center" wrap="wrap">
+ <Text weight="semibold">
+ This is a change of published policy, not a bug fix
+ </Text>
+ <Badge variant="error" label="Reversal" />
+ </HStack>
+ <VStack gap={1} {...stylex.props(sx.quote)}>
+ <Text type="supporting" color="secondary">
+ &ldquo;{conflict.published}&rdquo; — {conflict.section},
+ published today
+ </Text>
+ </VStack>
+ <Text type="supporting">{conflict.reading}</Text>
+ <Text type="supporting" color="secondary">
+ {conflict.resolution}
+ </Text>
+ <Text type="supporting" color="secondary">
+ <Link href="/pages/motion-lab/published/">
+ The conflicts, side by side
+ </Link>{' '}
+ ·{' '}
+ <Link
+ href={PUBLISHED_PAGE_URL}
+ target="_blank"
+ rel="noopener noreferrer">
+ the published page
+ </Link>
+ </Text>
+ </VStack>
+ </Card>
+ )}
+ </VStack>
+
+ <DemoCard
+ title="The three policies, running"
+ question="A spinner, a pulse and an indeterminate bar under each answer. Which of these still tells you the system is working?">
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — loops slow to 3s',
+ content: <LoopRig policy="today" />,
+ },
+ {
+ tone: 'neutral',
+ label: 'Delete — the published answer',
+ content: <LoopRig policy="delete" />,
+ },
+ {
+ tone: 'after',
+ label: 'Degrade — the proposed answer',
+ content: <LoopRig policy="degrade" />,
+ },
+ ]}
+ />
+ <DemoBody>
+ <Text type="supporting" color="secondary">
+ Slowing a loop is the one answer nobody is arguing for and the one
+ the code does today. Between the other two, the question is not
+ whether the spinner keeps spinning — it does not, either way — but
+ whether anything replaces it.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="Hover the rows, then flip the rail"
+ question="The tint is state feedback that happens to be implemented as a transition. Does the policy take the feedback or only the fade?">
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Hardcoded 150ms',
+ content: <TintRig mode="before" />,
+ },
+ {
+ tone: 'after',
+ label: 'Tokenised --duration-state',
+ content: <TintRig mode="after" />,
+ },
+ ]}
+ />
+ <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
+ movement, and this tint is exactly the feedback degrade exists to
+ preserve — which is why delete is defensible on a hover tint and
+ indefensible on a spinner, where the motion <em>is</em> the message.
+ </Text>
+ <Text type="supporting" color="secondary">
+ The left pane makes the token argument at the same time: it
+ hardcodes 150ms, so it fades identically under every policy. A
+ 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
+ survives. On <strong>Delete</strong> the tint snaps, and the
+ affordance goes with it. That is the whole decision, in one hover.
+ (This behaviour was itself a bug in the lab until the policy was
+ moved out of the stylesheet: the store writes the duration aliases
+ inline, and an inline custom property outranks any selector, so the
+ delete rule looked right and did nothing.)
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <VStack gap={3}>
+ <Heading level={2}>
+ The <code>0.01s</code> finding
+ </Heading>
+ <Text color="secondary">
+ {INSTANT_ESCAPES.length} of the {AUDIT_COUNTS.hardcodedTotal}{' '}
+ hardcoded values are <code>0.01s</code>, and every one is a
+ reduced-motion escape in BottomSheet, DateInput or MobileNav. This is
+ load-bearing, not sloppiness: a zero duration fires no{' '}
+ <code>transitionend</code>, so anything sequencing off that event — an
+ unmount, a focus return, a scroll lock release — never runs. The idiom
+ is a component author working around the platform.
+ </Text>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Site</TableHeaderCell>
+ <TableHeaderCell>Component</TableHeaderCell>
+ <TableHeaderCell>Property</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {INSTANT_ESCAPES.map(site => (
+ <TableRow key={`${site.file}:${site.line}`}>
+ <TableCell>
+ <Text
+ {...stylex.props(
+ sx.mono,
+ )}>{`${site.file}:${site.line}`}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {site.component}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {site.prop}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ <Grid columns={{minWidth: 300}} gap={3}>
+ <Card padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">
+ <code>--duration-instant</code> cannot be assumed to be 0
+ </Text>
+ <Text type="supporting" color="secondary">
+ Ship it as <code>0.01ms</code> and every existing sequencing
+ path keeps working, at a cost no user can perceive. Ship it as{' '}
+ <code>0</code> and these ten sites have to be rewritten to await
+ something else in the same change — which is a different, larger
+ piece of work than the sweep is scoped for.
+ </Text>
+ </VStack>
+ </Card>
+ <Card padding={4}>
+ <VStack gap={1.5}>
+ <Text weight="semibold">
+ Decide it before the sweep, not during
+ </Text>
+ <Text type="supporting" color="secondary">
+ The sweep rewrites these ten lines whichever way the token goes.
+ Deciding halfway through means two idioms in the codebase and a
+ lint rule that cannot tell which one it is looking at.
+ </Text>
+ </VStack>
+ </Card>
+ </Grid>
+ </VStack>
-export {default} from '../../../../../motion/pages/reduced-motion';
+ <VStack gap={3}>
+ <Heading level={2}>The rule, as code</Heading>
+ <Text color="secondary">
+ What a component author copies. Movement is a multiplier so the policy
+ lands in one place; loops stop rather than slow; hover motion is gated
+ on a fine pointer because touch fires a hover on tap; and the
+ attribute branch exists because an app with its own reduce-motion
+ setting can flip a JS library but cannot flip a media query.
+ </Text>
+ <CodeBlock
+ language="css"
+ title="The degrade branch"
+ code={CSS_RULE}
+ hasCopyButton
+ maxHeight={420}
+ />
+ <CodeBlock
+ language="tsx"
+ title="useReducedMotion() — the JS half of the same policy"
+ code={HOOK}
+ hasCopyButton
+ maxHeight={420}
+ />
+ <Text type="supporting" color="secondary">
+ Both halves ship together or the system disagrees with itself: a chart
+ that animates while the interface around it has stopped is worse than
+ either policy applied consistently.
+ </Text>
+ </VStack>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/motion/rubric.ts b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/rubric.ts
similarity index 100%
rename from apps/sandbox/src/motion/rubric.ts
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/rubric.ts
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/rubric/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/rubric/page.tsx
index d33fb9d021..724d955707 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/rubric/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/rubric/page.tsx
@@ -1,10 +1,747 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's rubric page.
+ * @file page.tsx
+ * @input rubric.ts, the generated audit, the published guidance
+ * @output The rubric as a bench: every criterion with a pass and a fail running
+ * @position /motion/rubric
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * A rubric that is only a table gets read once and then argued about from
+ * memory. Every criterion here that can be shown is shown, so "the exit is on
+ * the wrong curve" is something you look at rather than something you take on
+ * trust.
*/
-export {default} from '../../../../../motion/pages/rubric';
+import type {ReactNode} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Card} from '@astryxdesign/core/Card';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Link} from '@astryxdesign/core/Link';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import {LabPage} from '../PageFrame';
+import {
+ BudgetMeter,
+ ComparePanes,
+ DemoBody,
+ DemoCard,
+ Runner,
+ TokenSlider,
+} from '../LabPrimitives';
+import {
+ CheckTickRig,
+ InterruptRig,
+ LayerRig,
+ LoopRig,
+ OriginRig,
+ OutlineMarkerRig,
+ PressRig,
+} from '../LabDemos';
+import {
+ AUDIT_COUNTS,
+ HARDCODED_SITES,
+ NO_REDUCED_MOTION,
+ TRANSFORM_TRANSITIONS,
+} from '../__generated__/motionAudit';
+import {
+ AUTOMATABLE_LABEL,
+ GRANDFATHERING,
+ MISSING_PRINCIPLE,
+ PASS_BAR,
+ RUBRIC_CRITERIA,
+ SEVERITY_LABEL,
+ SEVERITY_RULES,
+ type Automatable,
+ type Criterion,
+ type Severity,
+} from '../rubric';
+
+const sx = stylex.create({
+ full: {width: '100%'},
+ mono: {fontFamily: 'var(--font-family-code)', fontSize: '12px'},
+ verdict: {
+ borderInlineStart: '2px solid var(--color-border)',
+ paddingInlineStart: '10px',
+ },
+ pass: {borderInlineStartColor: 'var(--color-background-success, #3f9a6b)'},
+ fail: {borderInlineStartColor: 'var(--color-background-error, #d3543f)'},
+ quote: {
+ borderInlineStart: '2px solid var(--color-border)',
+ paddingInlineStart: '12px',
+ maxWidth: '64ch',
+ },
+});
+
+const SEVERITY_VARIANT: Readonly<
+ Record<Severity, 'error' | 'warning' | 'neutral'>
+> = {
+ blocker: 'error',
+ 'should-fix': 'warning',
+ polish: 'neutral',
+};
+
+const AUTOMATABLE_VARIANT: Readonly<
+ Record<Automatable, 'success' | 'info' | 'neutral'>
+> = {
+ yes: 'success',
+ partly: 'info',
+ no: 'neutral',
+};
+
+/** Only the criteria that can be watched get a rig; the rest say why not. */
+function demoFor(id: string): ReactNode {
+ switch (id) {
+ case 'frequency':
+ return (
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label:
+ 'Fails — a tick that draws itself, on a control used forty times in a form',
+ content: <CheckTickRig technique="draw" />,
+ },
+ {
+ tone: 'after',
+ label: 'Passes — instant, because this is a 100+/day interaction',
+ content: <CheckTickRig technique="hard" />,
+ },
+ ]}
+ />
+ );
+ case 'semantic':
+ return (
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Fails — exit duration on the entry curve',
+ content: (
+ <Runner
+ durationToken="--duration-exit"
+ easeToken="--ease-entry"
+ />
+ ),
+ },
+ {
+ tone: 'after',
+ label: 'Passes — exit duration on the exit curve',
+ content: (
+ <Runner
+ durationToken="--duration-exit"
+ easeToken="--ease-exit"
+ />
+ ),
+ },
+ ]}
+ />
+ );
+ case 'budget':
+ return (
+ <DemoBody>
+ <Runner durationToken="--duration-enter" easeToken="--ease-entry" />
+ <TokenSlider
+ token="--duration-enter"
+ label="--duration-enter"
+ min={0}
+ max={900}
+ />
+ <BudgetMeter token="--duration-enter" />
+ </DemoBody>
+ );
+ case 'compositor':
+ return (
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Fails — animates top and height',
+ content: <OutlineMarkerRig mode="before" />,
+ },
+ {
+ tone: 'after',
+ label: 'Passes — transform only',
+ content: <OutlineMarkerRig mode="after" />,
+ },
+ ]}
+ />
+ );
+ case 'presence':
+ return (
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Fails the criterion — and follows the published page',
+ content: (
+ <LayerRig
+ mode="before"
+ label="No exit at all"
+ triggerLabel="Hover me"
+ />
+ ),
+ },
+ {
+ tone: 'after',
+ label: 'Passes — exit retraces the entry, faster',
+ content: (
+ <LayerRig
+ mode="after"
+ label="Exits on --duration-exit"
+ triggerLabel="Hover me"
+ />
+ ),
+ },
+ ]}
+ />
+ );
+ case 'origin':
+ return (
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Fails — scale(0)',
+ content: <OriginRig kind="zero" />,
+ },
+ {
+ tone: 'neutral',
+ label: 'Half right — 0.94, wrong origin',
+ content: <OriginRig kind="centre" />,
+ },
+ {
+ tone: 'after',
+ label: 'Passes — anchored to the trigger',
+ content: <OriginRig kind="anchored" />,
+ },
+ ]}
+ />
+ );
+ case 'interruptible':
+ return (
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Fails — a keyframe restarts from zero',
+ content: <InterruptRig mode="before" />,
+ },
+ {
+ tone: 'after',
+ label: 'Passes — a transition retargets',
+ content: <InterruptRig mode="after" />,
+ },
+ ]}
+ />
+ );
+ case 'reduced-motion':
+ return (
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — loops slow to 3s',
+ content: <LoopRig policy="today" />,
+ },
+ {
+ tone: 'neutral',
+ label: 'Delete — what the published page says',
+ content: <LoopRig policy="delete" />,
+ },
+ {
+ tone: 'after',
+ label: 'Degrade — what the criterion says',
+ content: <LoopRig policy="degrade" />,
+ },
+ ]}
+ />
+ );
+ case 'library':
+ return (
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Fails — transition on transform',
+ content: <PressRig technique="transform" />,
+ },
+ {
+ tone: 'after',
+ label: 'Passes — press on the scale property',
+ content: <PressRig technique="scale" />,
+ },
+ ]}
+ />
+ );
+ default:
+ return null;
+ }
+}
+
+function Verdict({
+ tone,
+ label,
+ text,
+}: {
+ tone: 'pass' | 'fail';
+ label: string;
+ text: string;
+}) {
+ return (
+ <VStack
+ gap={0.5}
+ {...stylex.props(sx.verdict, tone === 'pass' ? sx.pass : sx.fail)}>
+ <Text type="supporting" weight="semibold">
+ {label}
+ </Text>
+ <Text type="supporting" color="secondary">
+ {text}
+ </Text>
+ </VStack>
+ );
+}
+
+function CriterionCard({criterion}: {criterion: Criterion}) {
+ const demo = demoFor(criterion.id);
+ return (
+ <DemoCard
+ title={`${criterion.n}. ${criterion.title}`}
+ question={criterion.rule}
+ badges={
+ <>
+ <Badge
+ variant={SEVERITY_VARIANT[criterion.severity]}
+ label={SEVERITY_LABEL[criterion.severity]}
+ />
+ <Badge
+ variant={AUTOMATABLE_VARIANT[criterion.automatable]}
+ label={AUTOMATABLE_LABEL[criterion.automatable]}
+ />
+ {criterion.guidance === 'reversal' && (
+ <Badge variant="error" label="Reverses published guidance" />
+ )}
+ {criterion.guidance === 'aligned' && (
+ <Badge variant="success" label="Already published" />
+ )}
+ </>
+ }>
+ <DemoBody>
+ <Grid columns={{minWidth: 260}} gap={3}>
+ <Verdict tone="pass" label="Passes" text={criterion.pass} />
+ <Verdict tone="fail" label="Fails" text={criterion.fail} />
+ </Grid>
+ <Text type="supporting" color="secondary">
+ <strong>Checked by: </strong>
+ {criterion.check}
+ {criterion.severityNote != null ? ` ${criterion.severityNote}` : ''}
+ </Text>
+ {criterion.evidence != null && (
+ <Text type="supporting" color="secondary">
+ <strong>Measured: </strong>
+ {criterion.evidence}
+ </Text>
+ )}
+ {criterion.guidanceNote != null && (
+ <Text type="supporting" color="secondary">
+ <strong>
+ {criterion.guidance === 'reversal'
+ ? 'Contradicts the published Motion page: '
+ : 'Cites the published Motion page: '}
+ </strong>
+ {criterion.guidanceNote}{' '}
+ <Link href="/pages/motion-lab/published/">See the conflicts</Link>
+ </Text>
+ )}
+ </DemoBody>
+ {demo}
+ </DemoCard>
+ );
+}
+
+/** The reduced-motion worklist, collapsed to components so it fits on a card. */
+const REDUCED_BY_COMPONENT = [
+ ...NO_REDUCED_MOTION.reduce((acc, row) => {
+ acc.set(row.component, (acc.get(row.component) ?? 0) + 1);
+ return acc;
+ }, new Map<string, number>()),
+].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
+
+const MULTI_PROPERTY_TRANSFORMS = TRANSFORM_TRANSITIONS.filter(
+ site => site.decl?.includes(',') === true,
+).length;
+
+const INSTANT_ESCAPES = HARDCODED_SITES.filter(
+ site => site.value === '0.01s',
+).length;
+
+const TABLE_TINTS = HARDCODED_SITES.filter(
+ site => site.value === '150ms' && site.component === 'Table',
+).length;
+
+export default function MotionRubricPage() {
+ const mechanical = RUBRIC_CRITERIA.filter(c => c.automatable === 'yes');
+ const blockers = RUBRIC_CRITERIA.filter(c => c.severity === 'blocker');
+ const reversals = RUBRIC_CRITERIA.filter(c => c.guidance === 'reversal');
+
+ return (
+ <LabPage
+ title="Rubric bench"
+ intro="Twelve criteria, each with a pass and a fail you can watch. Astryx already gates lab-to-core promotion on an accessibility checklist; motion works the same way or it does not work at all — published, graded per component, tracked."
+ badges={
+ <Badge variant="info" label={`${RUBRIC_CRITERIA.length} criteria`} />
+ }
+ decides="Whether each criterion is checkable, and what a pass and a fail look like.">
+ <Banner
+ status="warning"
+ title="The brief says ten graded criteria. Its own table has twelve."
+ description={
+ <Text>
+ Twelve is what the table describes and twelve is what is graded
+ here. Fix the number in Deliverables before publication — a count in
+ a deliverable is the thing that gets quoted back in a review, and
+ nobody recounts the table. Criteria{' '}
+ {reversals.map(c => c.n).join(' and ')} reverse guidance the
+ published Motion page gives today, so the rubric cannot gate on
+ either until that page is rewritten.
+ </Text>
+ }
+ endContent={
+ <Link href="/pages/motion-lab/published/">The conflicts</Link>
+ }
+ />
+
+ <VStack gap={3}>
+ <Heading level={2}>How it grades</Heading>
+ <Text color="secondary">{PASS_BAR}</Text>
+ <Card padding={0}>
+ <Table density="balanced">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Severity</TableHeaderCell>
+ <TableHeaderCell>What it means</TableHeaderCell>
+ <TableHeaderCell>Effect on the gate</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {SEVERITY_RULES.map(row => (
+ <TableRow key={row.severity}>
+ <TableCell>
+ <Badge
+ variant={SEVERITY_VARIANT[row.severity]}
+ label={SEVERITY_LABEL[row.severity]}
+ />
+ </TableCell>
+ <TableCell>
+ <Text type="supporting">{row.meaning}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {row.gate}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ <Text type="supporting" color="secondary">
+ Blockers: {blockers.length} of {RUBRIC_CRITERIA.length}. Mechanical
+ today: {mechanical.length}. A component with two open should-fix items
+ still passes; a third stops it, which is what keeps the second one
+ from becoming permanent.
+ </Text>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>The twelve</Heading>
+ {RUBRIC_CRITERIA.map(criterion => (
+ <CriterionCard key={criterion.id} criterion={criterion} />
+ ))}
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>What the rubric would have caught</Heading>
+ <Text color="secondary">
+ Measured against <code>@astryxdesign/core</code> by the audit script,
+ not read out of the brief. These are the rows a reviewer would have
+ been handed on the day the component landed.
+ </Text>
+
+ <DemoCard
+ title="Criterion 6 — compositor-only"
+ question={`${AUDIT_COUNTS.transformTransitions} transform transitions across ${AUDIT_COUNTS.transformTransitionComponents} components. Every one of them is also a criterion-12 finding.`}>
+ <DemoBody>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Site</TableHeaderCell>
+ <TableHeaderCell>Declaration</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {TRANSFORM_TRANSITIONS.slice(0, 6).map(site => (
+ <TableRow key={`${site.file}:${site.line}`}>
+ <TableCell>
+ <Text
+ {...stylex.props(
+ sx.mono,
+ )}>{`${site.file}:${site.line}`}</Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {site.decl}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ <Text type="supporting" color="secondary">
+ {MULTI_PROPERTY_TRANSFORMS} of these declare{' '}
+ <code>transform</code> inside a longer property list rather than
+ on its own, so a grep for{' '}
+ <code>transitionProperty: &lsquo;transform&rsquo;</code> finds
+ barely half of them. That is worth knowing before anyone scopes
+ criterion 12 from a search —{' '}
+ <Link href="/pages/motion-lab/bugs/">
+ the bugs page has the whole list
+ </Link>
+ , and the count has already moved twice as the scanner improved.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="Criterion 10 — reduced motion"
+ question={`${AUDIT_COUNTS.filesWithoutReducedMotion} of ${AUDIT_COUNTS.animatedFiles} animated files have no reduced-motion branch. This is the sweep.`}>
+ <DemoBody>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Component</TableHeaderCell>
+ <TableHeaderCell>Files with no branch</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {REDUCED_BY_COMPONENT.slice(0, 6).map(
+ ([component, count]) => (
+ <TableRow key={component}>
+ <TableCell>
+ <Text>{component}</Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {count}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ),
+ )}
+ </TableBody>
+ </Table>
+ </Card>
+ <Text type="supporting" color="secondary">
+ Table alone accounts for {REDUCED_BY_COMPONENT[0]?.[1]} of the{' '}
+ {AUDIT_COUNTS.filesWithoutReducedMotion}.{' '}
+ <Link href="/pages/motion-lab/reduced-motion/">
+ The full worklist is on the reduced-motion page
+ </Link>
+ , where it also has to wait on degrade-or-delete: the sweep writes
+ whichever answer wins {AUDIT_COUNTS.filesWithoutReducedMotion}{' '}
+ times.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <DemoCard
+ title="Criterion 3 — token fidelity"
+ question={`${AUDIT_COUNTS.hardcodedTotal} hardcoded values: ${AUDIT_COUNTS.hardcodedDuration} durations, ${AUDIT_COUNTS.hardcodedEasing} curves. The brief budgeted for 28.`}>
+ <DemoBody>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Site</TableHeaderCell>
+ <TableHeaderCell>Property</TableHeaderCell>
+ <TableHeaderCell>Value</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {[
+ 'Table/plugins/columnResize/useTableColumnResize.tsx',
+ 'BottomSheet/BottomSheetPanel.tsx',
+ 'StatusDot/StatusDot.tsx',
+ 'Chat/ChatMessageMetadata.tsx',
+ 'hooks/useKeyboardHint.tsx',
+ 'Button/Button.tsx',
+ ]
+ .map(file =>
+ HARDCODED_SITES.find(site => site.file === file),
+ )
+ .filter(
+ (site): site is (typeof HARDCODED_SITES)[number] =>
+ site != null,
+ )
+ .map(site => (
+ <TableRow key={`${site.file}:${site.line}:${site.prop}`}>
+ <TableCell>
+ <Text
+ {...stylex.props(
+ sx.mono,
+ )}>{`${site.file}:${site.line}`}</Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {site.prop}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)}>{site.value}</Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ <Text type="supporting" color="secondary">
+ Not all of them are carelessness: {INSTANT_ESCAPES} are the{' '}
+ <code>0.01s</code> reduced-motion escape and {TABLE_TINTS} are the
+ same 150ms tint in Table. The rubric would have caught every one
+ at review time, which is the argument for the lint rule rather
+ than the sweep.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Automatable?</Heading>
+ <Text color="secondary">
+ {mechanical.length} of {RUBRIC_CRITERIA.length} are mechanical today —{' '}
+ {mechanical.map(c => c.n).join(', ')}. Five more can be narrowed by
+ lint to a question a reviewer answers in one line. Three are judgement
+ and always will be.
+ </Text>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>#</TableHeaderCell>
+ <TableHeaderCell>Criterion</TableHeaderCell>
+ <TableHeaderCell>Automatable</TableHeaderCell>
+ <TableHeaderCell>What checks it</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {RUBRIC_CRITERIA.map(c => (
+ <TableRow key={c.id}>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {c.n}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text weight="semibold">{c.title}</Text>
+ </TableCell>
+ <TableCell>
+ <Badge
+ variant={AUTOMATABLE_VARIANT[c.automatable]}
+ label={AUTOMATABLE_LABEL[c.automatable]}
+ />
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {c.check}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Grandfathering</Heading>
+ <Text color="secondary">
+ The rubric is worth nothing if it fails 48 animating components on the
+ day it lands, and worth nothing if it never fails anything. This is
+ the split.
+ </Text>
+ <Card padding={0}>
+ <Table density="balanced">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Situation</TableHeaderCell>
+ <TableHeaderCell>Rule</TableHeaderCell>
+ <TableHeaderCell>Why</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {GRANDFATHERING.map(row => (
+ <TableRow key={row.situation}>
+ <TableCell>
+ <Text weight="semibold">{row.situation}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting">{row.rule}</Text>
+ </TableCell>
+ <TableCell>
+ <Text type="supporting" color="secondary">
+ {row.why}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>A principle the rubric drops</Heading>
+ <Card padding={4}>
+ <VStack gap={2}>
+ <HStack gap={2} vAlign="center" wrap="wrap">
+ <Text weight="semibold">{MISSING_PRINCIPLE.title}</Text>
+ <Badge variant="warning" label="Published, ungraded" />
+ </HStack>
+ <VStack gap={1} {...stylex.props(sx.quote)}>
+ <Text type="supporting" color="secondary">
+ &ldquo;{MISSING_PRINCIPLE.published}&rdquo;
+ </Text>
+ </VStack>
+ <Text type="supporting">{MISSING_PRINCIPLE.gap}</Text>
+ <Text type="supporting" color="secondary">
+ {MISSING_PRINCIPLE.measuredAgainst}
+ </Text>
+ <Text type="supporting">
+ <strong>Recommendation: </strong>
+ {MISSING_PRINCIPLE.recommendation}
+ </Text>
+ <Text type="supporting" color="secondary">
+ <Link href="/pages/motion-lab/published/">
+ The published page against the proposal, conflict by conflict
+ </Link>
+ </Text>
+ </VStack>
+ </Card>
+ </VStack>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/motion/sections.ts b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/sections.ts
similarity index 83%
rename from apps/sandbox/src/motion/sections.ts
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/sections.ts
index fe82f32576..7779a067de 100644
--- a/apps/sandbox/src/motion/sections.ts
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/sections.ts
@@ -20,104 +20,104 @@ export type MotionSection = {
export const MOTION_SECTIONS: ReadonlyArray<MotionSection> = [
{
- href: '/motion',
+ href: '/pages/motion-lab/',
title: 'Overview',
group: 'Start',
decides:
'Whether the audit in the brief matches the code, and which decisions are actually blocking.',
},
{
- href: '/motion/published',
+ href: '/pages/motion-lab/published/',
title: 'Against the published page',
group: 'Start',
decides:
'Which proposals are bug fixes and which are reversals of guidance Astryx publishes today.',
},
{
- href: '/motion/tokens',
+ href: '/pages/motion-lab/tokens/',
title: 'Semantic tokens',
group: 'Foundation',
decides:
'Whether six easings and eight durations are the right vocabulary, and what each value should be.',
},
{
- href: '/motion/springs',
+ href: '/pages/motion-lab/springs/',
title: 'Springs',
group: 'Foundation',
decides:
'Whether the four named springs feel right, and whether they belong in the theme contract.',
},
{
- href: '/motion/js-mirror',
+ href: '/pages/motion-lab/js-mirror/',
title: 'JS token mirror',
group: 'Foundation',
decides:
'What the mirror has to expose for charts, canvas and motion libraries.',
},
{
- href: '/motion/export',
+ href: '/pages/motion-lab/export/',
title: 'Export tuning',
group: 'Foundation',
decides:
'Nothing — it emits whatever the rest of the lab has been tuned to.',
},
{
- href: '/motion/exit-gap',
+ href: '/pages/motion-lab/exit-gap/',
title: 'The exit gap',
group: 'Presence',
decides:
'Whether presence surfaces should animate out at all, and what enter and exit cost.',
},
{
- href: '/motion/bugs',
+ href: '/pages/motion-lab/bugs/',
title: 'Small bugs',
group: 'Presence',
decides:
'Which of the structural findings are real once you look at the code.',
},
{
- href: '/motion/violations',
+ href: '/pages/motion-lab/violations/',
title: 'Hardcoded values',
group: 'Enforcement',
decides:
'What each hardcoded site becomes, and whether the swap is visible at all.',
},
{
- href: '/motion/rubric',
+ href: '/pages/motion-lab/rubric/',
title: 'Rubric bench',
group: 'Enforcement',
decides:
'Whether each criterion is checkable, and what a pass and a fail look like.',
},
{
- href: '/motion/reduced-motion',
+ href: '/pages/motion-lab/reduced-motion/',
title: 'Reduced motion',
group: 'Enforcement',
decides: 'Degrade or delete. The decision the 36-file sweep is waiting on.',
},
{
- href: '/motion/previews',
+ href: '/pages/motion-lab/previews/',
title: 'Live previews',
group: 'Coverage',
decides:
'The coverage work: indicators, disclosure, chips, skeletons, lists.',
},
{
- href: '/motion/preview-plan',
+ href: '/pages/motion-lab/preview-plan/',
title: 'Preview plan',
group: 'Coverage',
decides:
'What every remaining preview has to show before it is worth building.',
},
{
- href: '/motion/library',
+ href: '/pages/motion-lab/library/',
title: 'Motion library',
group: 'Compatibility',
decides:
'The three blockers, and whether Button keeps its press transition.',
},
{
- href: '/motion/plan',
+ href: '/pages/motion-lab/plan/',
title: 'Plan & open questions',
group: 'Plan',
decides: 'Sequence, gates, and who has to answer what.',
diff --git a/apps/sandbox/src/motion/spring.ts b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/spring.ts
similarity index 100%
rename from apps/sandbox/src/motion/spring.ts
rename to apps/sandbox/src/app/(sandbox)/pages/motion-lab/spring.ts
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/springs/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/springs/page.tsx
index d962823c7a..798215d0db 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/springs/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/springs/page.tsx
@@ -1,10 +1,468 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's springs page.
+ * @file page.tsx
+ * @input SPRINGS from motionTokens, the spring model, the lab store
+ * @output The four named springs, tunable, beside the CSS pair for the same gesture
+ * @position /motion/springs
+ *
+ * Springs are the only part of the proposal with no CSS representation, so
+ * they live in the JS mirror rather than the token file. That is not a
+ * technicality: a spring is what gesture-driven and interruptible motion
+ * needs, because it carries velocity through an interruption where a keyframe
+ * restarts from zero.
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * The runner and the plot use the lab's CSS module classes rather than local
+ * styles so a spring-driven box and a token-driven <Runner> are pixel
+ * identical — the comparison is only honest if the only difference is timing.
*/
-export {default} from '../../../../../motion/pages/springs';
+import {useCallback, useRef, useState} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Button} from '@astryxdesign/core/Button';
+import {CodeBlock} from '@astryxdesign/core/CodeBlock';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Link} from '@astryxdesign/core/Link';
+import {MetadataList, MetadataListItem} from '@astryxdesign/core/MetadataList';
+import {VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {
+ SegmentedControl,
+ SegmentedControlItem,
+} from '@astryxdesign/core/SegmentedControl';
+import {LabPage} from '../PageFrame';
+import {DemoBody, DemoCard, LabSlider, Runner, useLoop} from '../LabPrimitives';
+import {useMotionLab} from '../MotionLabStore';
+import {SPRINGS} from '../motionTokens';
+import {createSpring, plotPath} from '../spring';
+import styles from '../MotionLab.module.css';
+
+const sx = stylex.create({
+ full: {width: '100%'},
+ mono: {fontFamily: 'var(--font-family-code)'},
+ prose: {maxWidth: '72ch'},
+});
+
+/** Bounce above this stops reading as a crisp library. Rubric criterion 11. */
+const CRISP_BOUNCE_CEILING = 0.3;
+
+const PLOT_WIDTH = 380;
+const PLOT_HEIGHT = 148;
+const PLOT_PAD = 18;
+/** Plot past the nominal duration so the overshoot is visible, not clipped. */
+const PLOT_TAIL = 1.5;
+
+function pct(value: number): string {
+ return `${(value * 100).toFixed(1)}%`;
+}
+
+/**
+ * The spring's position over time. The dashed line is the target: everything
+ * above it is overshoot, and the vertical mark is where the nominal duration
+ * ends — a light spring is still moving there, which is the thing the number
+ * in the readout is measuring.
+ */
+function SpringPlot({duration, bounce}: {duration: number; bounce: number}) {
+ const spring = createSpring(duration, bounce);
+ const span = spring.duration * PLOT_TAIL;
+ const yMin = -0.08;
+ const yMax = Math.max(1.2, spring.overshoot() + 0.1);
+ const toY = (y: number) =>
+ PLOT_HEIGHT -
+ PLOT_PAD -
+ ((y - yMin) / (yMax - yMin)) * (PLOT_HEIGHT - PLOT_PAD * 2);
+ const nominalX = PLOT_PAD + (1 / PLOT_TAIL) * (PLOT_WIDTH - PLOT_PAD * 2);
+
+ return (
+ <svg
+ className={styles.curveCanvas}
+ width={PLOT_WIDTH}
+ height={PLOT_HEIGHT}
+ viewBox={`0 0 ${PLOT_WIDTH} ${PLOT_HEIGHT}`}
+ role="img"
+ aria-label={`Spring position over time, duration ${duration} seconds, bounce ${bounce}`}>
+ <line
+ x1={PLOT_PAD}
+ y1={toY(1)}
+ x2={PLOT_WIDTH - PLOT_PAD}
+ y2={toY(1)}
+ stroke="var(--color-border)"
+ strokeDasharray="3 3"
+ />
+ <line
+ x1={nominalX}
+ y1={PLOT_PAD}
+ x2={nominalX}
+ y2={PLOT_HEIGHT - PLOT_PAD}
+ stroke="var(--color-text-tertiary, #8a8a8a)"
+ strokeDasharray="2 4"
+ />
+ <path
+ d={plotPath(
+ x => spring.sample(x * span),
+ PLOT_WIDTH,
+ PLOT_HEIGHT,
+ PLOT_PAD,
+ yMin,
+ yMax,
+ )}
+ fill="none"
+ stroke="var(--color-brand)"
+ strokeWidth={2}
+ />
+ </svg>
+ );
+}
+
+/**
+ * A box driven by the spring itself rather than by a duration token, which is
+ * why it cannot be the shared <Runner>: the timing comes from the sampled
+ * curve, and only the slow-mo multiplier is shared with the rest of the lab.
+ */
+function SpringRunner({duration, bounce}: {duration: number; bounce: number}) {
+ const {speed, reducedMotion} = useMotionLab();
+ const dotRef = useRef<HTMLSpanElement | null>(null);
+ const trackRef = useRef<HTMLDivElement | null>(null);
+
+ const run = useCallback(() => {
+ const dot = dotRef.current;
+ const track = trackRef.current;
+ if (dot == null || track == null) {
+ return;
+ }
+ for (const animation of dot.getAnimations()) {
+ animation.cancel();
+ }
+ const spring = createSpring(duration, bounce);
+ // Short of the far edge, so an overshooting spring is not clipped by the
+ // track it is travelling in.
+ const distance = Math.max(0, track.clientWidth - 52);
+ // A spring is movement, which is the first thing either reduced-motion
+ // policy removes — so the box arrives rather than travels.
+ const isInstant = reducedMotion !== 'off';
+ dot.animate(
+ [{transform: 'translateX(0)'}, {transform: `translateX(${distance}px)`}],
+ {
+ duration: isInstant ? 1 : Math.max(1, spring.duration * 1000 * speed),
+ easing: isInstant ? 'linear' : spring.linear(),
+ fill: 'both',
+ },
+ );
+ }, [bounce, duration, reducedMotion, speed]);
+
+ useLoop(run, duration * 1000 * speed + 900);
+
+ return (
+ <div ref={trackRef} className={styles.runner}>
+ <span ref={dotRef} className={styles.runnerDot} />
+ </div>
+ );
+}
+
+/**
+ * The same spring, retargeted mid-flight. The box picks up from wherever it
+ * is but from a standstill, because a sampled curve has no velocity to carry.
+ * A real spring integrator does — which is the argument for the JS spring
+ * over the CSS fallback for anything gesture-driven.
+ */
+function InterruptDemo({duration, bounce}: {duration: number; bounce: number}) {
+ const {speed, reducedMotion} = useMotionLab();
+ const [isOut, setOut] = useState(false);
+ const dotRef = useRef<HTMLSpanElement | null>(null);
+ const trackRef = useRef<HTMLDivElement | null>(null);
+
+ const toggle = useCallback(() => {
+ const dot = dotRef.current;
+ const track = trackRef.current;
+ if (dot == null || track == null) {
+ return;
+ }
+ const next = !isOut;
+ setOut(next);
+ const spring = createSpring(duration, bounce);
+ const distance = Math.max(0, track.clientWidth - 52);
+ // The running animation does not commit its value, so the position has to
+ // be read off the box before it is cancelled.
+ const matrix = new DOMMatrixReadOnly(
+ window.getComputedStyle(dot).transform,
+ );
+ for (const animation of dot.getAnimations()) {
+ animation.cancel();
+ }
+ const isInstant = reducedMotion !== 'off';
+ dot.animate(
+ [
+ {transform: `translateX(${matrix.m41}px)`},
+ {transform: `translateX(${next ? distance : 0}px)`},
+ ],
+ {
+ duration: isInstant ? 1 : Math.max(1, spring.duration * 1000 * speed),
+ easing: isInstant ? 'linear' : spring.linear(),
+ fill: 'both',
+ },
+ );
+ }, [bounce, duration, isOut, reducedMotion, speed]);
+
+ return (
+ <VStack gap={2} {...stylex.props(sx.full)}>
+ <div ref={trackRef} className={styles.runner}>
+ <span ref={dotRef} className={styles.runnerDot} />
+ </div>
+ <Button
+ size="sm"
+ variant="secondary"
+ label="Send it back — press twice, fast"
+ onClick={toggle}
+ />
+ </VStack>
+ );
+}
+
+function SpringCard({
+ name,
+ use,
+ cssCounterpart,
+}: {
+ name: string;
+ use: string;
+ cssCounterpart: readonly [string, string];
+}) {
+ const {springs, setSpring} = useMotionLab();
+ const tuned = springs[name];
+ const spring = createSpring(tuned.duration, tuned.bounce);
+ const isBouncy = tuned.bounce > CRISP_BOUNCE_CEILING;
+
+ return (
+ <DemoCard
+ title={name}
+ question={use}
+ badges={
+ isBouncy ? (
+ <Badge
+ variant="warning"
+ label={`bounce ${tuned.bounce.toFixed(2)} — past crisp`}
+ />
+ ) : (
+ <Badge
+ label={`${Math.round(tuned.duration * 1000)}ms · bounce ${tuned.bounce.toFixed(2)}`}
+ />
+ )
+ }>
+ <DemoBody>
+ <SpringPlot duration={tuned.duration} bounce={tuned.bounce} />
+ <VStack gap={1} {...stylex.props(sx.full)}>
+ <Text type="supporting" color="secondary">
+ spring — <code>{name}</code>
+ </Text>
+ <SpringRunner duration={tuned.duration} bounce={tuned.bounce} />
+ <Text type="supporting" color="secondary">
+ CSS counterpart — <code>{cssCounterpart[0]}</code> +{' '}
+ <code>{cssCounterpart[1]}</code>
+ </Text>
+ <Runner
+ durationToken={cssCounterpart[0]}
+ easeToken={cssCounterpart[1]}
+ />
+ </VStack>
+ <LabSlider
+ label="Duration"
+ value={tuned.duration}
+ min={0.1}
+ max={1.2}
+ step={0.05}
+ format={v => `${v.toFixed(2)}s`}
+ onChange={v => setSpring(name, {duration: v, bounce: tuned.bounce})}
+ />
+ <LabSlider
+ label="Bounce"
+ value={tuned.bounce}
+ min={0}
+ max={0.6}
+ step={0.05}
+ format={v => v.toFixed(2)}
+ onChange={v => setSpring(name, {duration: tuned.duration, bounce: v})}
+ />
+ <MetadataList columns={2} label={{position: 'top'}}>
+ <MetadataListItem label="Duration">
+ <Text {...stylex.props(sx.mono)}>
+ {spring.duration.toFixed(2)}s
+ </Text>
+ </MetadataListItem>
+ <MetadataListItem label="Bounce">
+ <Text {...stylex.props(sx.mono)}>{spring.bounce.toFixed(2)}</Text>
+ </MetadataListItem>
+ <MetadataListItem label="Overshoot">
+ <Text {...stylex.props(sx.mono)}>
+ {pct(spring.overshoot() - 1)}
+ </Text>
+ </MetadataListItem>
+ <MetadataListItem label="At nominal duration">
+ <Text {...stylex.props(sx.mono)}>{pct(spring.settle())}</Text>
+ </MetadataListItem>
+ <MetadataListItem label="Stiffness">
+ <Text {...stylex.props(sx.mono)}>{spring.stiffness}</Text>
+ </MetadataListItem>
+ <MetadataListItem label="Damping">
+ <Text {...stylex.props(sx.mono)}>{spring.damping}</Text>
+ </MetadataListItem>
+ </MetadataList>
+ </DemoBody>
+ </DemoCard>
+ );
+}
+
+export default function MotionSpringsPage() {
+ const {springs} = useMotionLab();
+ const [escapeHatch, setEscapeHatch] = useState<string>(SPRINGS[0].name);
+ const hatch = springs[escapeHatch];
+ const hatchSpring = createSpring(hatch.duration, hatch.bounce);
+ const bouncy = SPRINGS.filter(
+ s => springs[s.name].bounce > CRISP_BOUNCE_CEILING,
+ );
+
+ return (
+ <LabPage
+ title="Springs"
+ intro="A spring is described by duration and bounce, not by a curve, and it has no CSS representation at all — which is why the proposal keeps springs in the JS mirror rather than the token file. What they buy is interruption: a spring carries velocity through a change of target, where a keyframe restarts from zero. That is the whole case for having them, and it only pays off in gesture-driven and interruptible motion."
+ decides="Whether the four named springs feel right, and whether they belong in the theme contract."
+ badges={<Badge variant="info" label="JS mirror only — no CSS form" />}>
+ <Banner
+ status={bouncy.length > 0 ? 'warning' : 'info'}
+ title={
+ bouncy.length > 0
+ ? `${bouncy.length} spring(s) tuned past bounce 0.3`
+ : 'Bounce belongs in 0.1–0.3 for a crisp library'
+ }
+ description={
+ <Text>
+ Rubric criterion 11 is that visible bounce is for drag-to-dismiss
+ and playful moments; a dashboard stays crisp. Every slider below
+ runs to 0.6 on purpose. At bounce {CRISP_BOUNCE_CEILING} the box
+ passes its target by{' '}
+ {pct(createSpring(0.4, CRISP_BOUNCE_CEILING).overshoot() - 1)} and
+ settles back; at 0.6 it passes by{' '}
+ {pct(createSpring(0.4, 0.6).overshoot() - 1)} and reads as a toy.
+ Overshoot depends only on bounce, not on duration, so this is the
+ one number worth arguing about — and it is easier to agree on by
+ looking than by reading it.
+ </Text>
+ }
+ />
+
+ <Grid columns={{minWidth: 420}} gap={4}>
+ {SPRINGS.map(spec => (
+ <SpringCard
+ key={spec.name}
+ name={spec.name}
+ use={spec.use}
+ cssCounterpart={spec.cssCounterpart}
+ />
+ ))}
+ </Grid>
+
+ <DemoCard
+ title="What the preview actually is"
+ question="An approximation, and it is worth knowing where it stops being one."
+ badges={<Badge label="honest about the model" />}>
+ <DemoBody>
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ Motion describes a spring as duration and bounce. This lab
+ reproduces that as a damped harmonic oscillator — bounce maps to the
+ damping ratio, duration to the settle time — and then samples the
+ curve into a CSS <code>linear()</code> easing so a plain transition
+ can play it. Close enough to judge feel, and to argue about whether
+ 0.2 belongs in a crisp library.
+ </Text>
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ The sampled curve is also the escape hatch: a component that cannot
+ take a JS dependency can still run the spring shape from CSS. What
+ it cannot do is interruption. Press the button below twice in quick
+ succession — the box retargets from wherever it is, but from a
+ standstill, because a curve has no velocity to carry. A real spring
+ integrator does. So the fallback is for shape, and gesture work
+ wants the JS spring.
+ </Text>
+ <InterruptDemo duration={hatch.duration} bounce={hatch.bounce} />
+ <SegmentedControl
+ label="Which spring to emit"
+ size="sm"
+ value={escapeHatch}
+ onChange={value => setEscapeHatch(value as string)}>
+ {SPRINGS.map(spec => (
+ <SegmentedControlItem
+ key={spec.name}
+ value={spec.name}
+ label={spec.name}
+ />
+ ))}
+ </SegmentedControl>
+ <CodeBlock
+ language="css"
+ title={`${escapeHatch} — CSS fallback, sampled from the spring`}
+ hasCopyButton
+ isWrapped
+ maxHeight={220}
+ code={`/* No JS dependency. Shape only: an interruption restarts from rest. */
+.thing {
+ transition-property: transform;
+ transition-duration: ${Math.round(hatchSpring.duration * 1000)}ms;
+ transition-timing-function: ${hatchSpring.linear(16)};
+}`}
+ />
+ <Text type="supporting" color="secondary">
+ Sampled at 16 points here so it is readable; the mirror emits 64.
+ Overshoot {pct(hatchSpring.overshoot() - 1)}, which is the part a
+ cubic-bezier cannot express without going out of its 0–1 box.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <VStack gap={3}>
+ <Heading level={2}>
+ Open question: should springs be theme-tunable?
+ </Heading>
+ <Text color="secondary" {...stylex.props(sx.prose)}>
+ A theme already retunes the whole duration scale from three numbers —
+ a snappy theme sets{' '}
+ <code>{'{fast: 100, medium: 250, ratio: 0.75}'}</code> and every
+ primitive moves with it. Springs have no such axis, so today they are
+ the same everywhere no matter what the theme says. If one theme is
+ meant to feel bouncier than another, springs belong in the theme
+ contract alongside the duration scale — and adding them after the
+ contract ships is a breaking change to it. This wants deciding before
+ the token work lands, not after.
+ </Text>
+ <CodeBlock
+ language="ts"
+ title="packages/core/src/theme/expandMotionScale.ts — the axis today, and the question"
+ hasCopyButton
+ code={`export interface MotionScaleConfig {
+ fast: number; // 175 — micro-interactions
+ medium: number; // 410 — entrance and exit
+ slow?: number; // 975 — continuous
+ ratio: number; // 0.75 — min = base × ratio, max = base ÷ ratio
+ easing?: string; // overrides --ease-standard
+
+ // Proposed, and the decision this page is asking for. Optional is not the
+ // same as cheap: once themes ship without it, a theme author who tunes
+ // duration and finds springs unmoved has been told the contract covers
+ // motion when it covers only half of it.
+ spring?: Record<'press' | 'swap' | 'panel' | 'layout', {duration: number; bounce: number}>;
+}`}
+ />
+ <Text type="supporting" color="secondary">
+ Springs are defined natively in the mirror rather than parsed out of
+ CSS, since they have no CSS form to parse. See{' '}
+ <Link href="/pages/motion-lab/js-mirror/">JS token mirror</Link> for
+ the emitted shape and{' '}
+ <Link href="/pages/motion-lab/export/">Export tuning</Link> for what
+ ships.
+ </Text>
+ </VStack>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/tokens/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/tokens/page.tsx
index cc62778f9e..7f57842dfb 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/tokens/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/tokens/page.tsx
@@ -1,10 +1,441 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's tokens page.
+ * @file page.tsx
+ * @input motionTokens, the lab store, Core components
+ * @output The semantic token proposal, tunable
+ * @position /motion/tokens
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * The page the rest of the lab depends on: every control here writes a real
+ * custom property, so a curve settled on this page is the curve every demo in
+ * every other section is already using.
*/
-export {default} from '../../../../../motion/pages/tokens';
+import * as stylex from '@stylexjs/stylex';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Card} from '@astryxdesign/core/Card';
+import {CodeBlock} from '@astryxdesign/core/CodeBlock';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Link} from '@astryxdesign/core/Link';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import {LabPage} from '../PageFrame';
+import {
+ BudgetMeter,
+ ComparePanes,
+ CurveEditor,
+ DemoBody,
+ DemoCard,
+ Runner,
+ TokenSlider,
+ isNamedCurve,
+} from '../LabPrimitives';
+import {useMotionLab} from '../MotionLabStore';
+import {
+ CURRENT_EASE,
+ PRIMITIVE_DURATIONS,
+ SEMANTIC_DURATIONS,
+ SEMANTIC_EASES,
+ STAGGERS,
+} from '../motionTokens';
+import {HARDCODED_SITES} from '../__generated__/motionAudit';
+
+const sx = stylex.create({
+ full: {width: '100%'},
+ mono: {fontFamily: 'var(--font-family-code)'},
+ jobRow: {maxWidth: '46ch'},
+});
+
+const CURVE_PRESETS = [
+ ['ease-out', 'cubic-bezier(0, 0, 0.58, 1)'],
+ ['iOS', 'cubic-bezier(0.32, 0.72, 0, 1)'],
+ ['expo-out', 'cubic-bezier(0.16, 1, 0.3, 1)'],
+] as const;
+
+/** The duration each curve is best judged at — a linear curve needs a long run. */
+function previewDuration(easeName: string): string {
+ if (easeName === '--ease-linear') {
+ return '--duration-continuous';
+ }
+ if (easeName === '--ease-drawer') {
+ return '--duration-overlay';
+ }
+ if (easeName === '--ease-move') {
+ return '--duration-reveal';
+ }
+ return '--duration-enter';
+}
+
+/** Which curve reads best against a given duration, for the duration cards. */
+function pairedEase(durationName: string): string {
+ switch (durationName) {
+ case '--duration-exit':
+ return '--ease-exit';
+ case '--duration-continuous':
+ return '--ease-linear';
+ case '--duration-reveal':
+ return '--ease-move';
+ case '--duration-overlay':
+ return '--ease-drawer';
+ default:
+ return '--ease-entry';
+ }
+}
+
+export default function MotionTokensPage() {
+ const {rawToken, setToken} = useMotionLab();
+ const exitCurveSite = HARDCODED_SITES.find(
+ s => s.component === 'BottomSheet' && s.value.startsWith('cubic-bezier'),
+ );
+
+ return (
+ <LabPage
+ title="Semantic motion tokens"
+ intro="The current scale names sizes. An author choosing between --duration-fast-max and --duration-medium-min is guessing, because neither name says what it is for. The proposal keeps the primitive scale exactly as it is and adds a semantic layer on top, the way colour already works."
+ decides="Whether six easings and eight durations are the right vocabulary, and what each value should be."
+ badges={
+ <Badge variant="info" label="every control writes a real token" />
+ }>
+ <Banner
+ status="info"
+ title="One curve is doing three jobs"
+ description={
+ <Text>
+ Core ships exactly one easing token,{' '}
+ <code>
+ {CURRENT_EASE.name}: {CURRENT_EASE.value}
+ </code>
+ , and it covers entry, exit and state at once. The codebase has
+ already discovered this and worked around it locally — with a
+ comment measuring why.
+ {exitCurveSite != null && (
+ <>
+ {' '}
+ <code>
+ {exitCurveSite.file}:{exitCurveSite.line}
+ </code>{' '}
+ authors <code>{exitCurveSite.value}</code> by hand for the
+ sheet&rsquo;s exit.
+ </>
+ )}
+ </Text>
+ }
+ />
+
+ <DemoCard
+ title="The same three jobs, one curve and six"
+ question="Watch the exit lane. On the standard curve a leaving surface spends its travel immediately and then coasts, which is right for an arrival and wrong for a departure."
+ badges={<Badge variant="neutral" label="run at 4× to judge" />}>
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — --ease-standard for all three',
+ content: (
+ <VStack gap={2} {...stylex.props(sx.full)}>
+ {(
+ [
+ ['Arriving', '--duration-enter'],
+ ['Leaving', '--duration-exit'],
+ ['Moving', '--duration-reveal'],
+ ] as const
+ ).map(([label, duration]) => (
+ <VStack key={label} gap={1} {...stylex.props(sx.full)}>
+ <Text type="supporting" color="secondary">
+ {label}
+ </Text>
+ <Runner
+ durationToken={duration}
+ easeToken="--ease-standard-today"
+ />
+ </VStack>
+ ))}
+ </VStack>
+ ),
+ },
+ {
+ tone: 'after',
+ label: 'Proposed — the curve names the job',
+ content: (
+ <VStack gap={2} {...stylex.props(sx.full)}>
+ {(
+ [
+ ['Arriving', '--duration-enter', '--ease-entry'],
+ ['Leaving', '--duration-exit', '--ease-exit'],
+ ['Moving', '--duration-reveal', '--ease-move'],
+ ] as const
+ ).map(([label, duration, ease]) => (
+ <VStack key={label} gap={1} {...stylex.props(sx.full)}>
+ <Text type="supporting" color="secondary">
+ {label} — <code>{ease}</code>
+ </Text>
+ <Runner durationToken={duration} easeToken={ease} />
+ </VStack>
+ ))}
+ </VStack>
+ ),
+ },
+ ]}
+ />
+ <DemoBody>
+ <Text type="supporting" color="secondary">
+ The sheet needed its own curve because the standard one, measured on
+ device, “put the sheet half off-screen in 59ms of a 410ms close and
+ 90% off in 163ms — the travel is over before the eye has followed
+ it”. That comment, already in the codebase, is the specification for{' '}
+ <code>--ease-exit</code>. Promoting it is not a new idea; it is the
+ second time someone has needed it.
+ </Text>
+ </DemoBody>
+ </DemoCard>
+
+ <VStack gap={3}>
+ <Heading level={2}>Easing</Heading>
+ <Text color="secondary">
+ Drag a control point and every demo in the lab moves with it. Arrow
+ keys nudge; hold shift for a bigger step.
+ </Text>
+ <Grid columns={{minWidth: 420}} gap={4}>
+ {SEMANTIC_EASES.map(ease => {
+ const duration = previewDuration(ease.name);
+ const value = rawToken(ease.name);
+ return (
+ <DemoCard
+ key={ease.name}
+ title={ease.name}
+ question={ease.job}
+ badges={
+ isNamedCurve(value) ? (
+ <Badge label="CSS keyword — nothing to tune" />
+ ) : undefined
+ }>
+ <DemoBody>
+ {!isNamedCurve(value) && (
+ <CurveEditor
+ value={value}
+ onChange={next => setToken(ease.name, next)}
+ presets={[['reset', ease.value], ...CURVE_PRESETS]}
+ />
+ )}
+ <VStack gap={1} {...stylex.props(sx.full)}>
+ <Text type="supporting" color="secondary">
+ today — <code>--ease-standard</code>
+ </Text>
+ <Runner
+ durationToken={duration}
+ easeToken="--ease-standard-today"
+ />
+ <Text type="supporting" color="secondary">
+ proposed — <code>{ease.name}</code>
+ </Text>
+ <Runner durationToken={duration} easeToken={ease.name} />
+ </VStack>
+ <Text
+ type="supporting"
+ color="secondary"
+ {...stylex.props(sx.jobRow)}>
+ {ease.rationale}
+ </Text>
+ {ease.evidence != null && (
+ <Text type="supporting" color="secondary">
+ Already in the code: <code>{ease.evidence}</code>
+ </Text>
+ )}
+ </DemoBody>
+ </DemoCard>
+ );
+ })}
+ </Grid>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Duration</Heading>
+ <Text color="secondary">
+ Aliases onto the existing primitives, so a theme retunes them for free
+ through the motion scale it already has.
+ </Text>
+ <Grid columns={{minWidth: 380}} gap={4}>
+ {SEMANTIC_DURATIONS.map(duration => (
+ <DemoCard
+ key={duration.name}
+ title={duration.name}
+ question={duration.job}
+ badges={
+ <Badge
+ label={
+ duration.primitive == null
+ ? 'new'
+ : duration.primitive.replace('--duration-', '')
+ }
+ />
+ }>
+ <DemoBody>
+ {duration.ms > 0 && (
+ <>
+ <Runner
+ durationToken={duration.name}
+ easeToken={pairedEase(duration.name)}
+ />
+ <TokenSlider token={duration.name} max={900} />
+ <BudgetMeter token={duration.name} />
+ {duration.budget != null && (
+ <Text type="supporting" color="secondary">
+ Reference budget {duration.budget[0]}–
+ {duration.budget[1]}ms.
+ </Text>
+ )}
+ </>
+ )}
+ {duration.note != null && (
+ <Text
+ type="supporting"
+ color="secondary"
+ {...stylex.props(sx.jobRow)}>
+ {duration.note}
+ </Text>
+ )}
+ </DemoBody>
+ </DemoCard>
+ ))}
+ </Grid>
+ </VStack>
+
+ <Banner
+ status="warning"
+ title="The slow band is simultaneously unused and too short"
+ description={
+ <Text>
+ Interface motion should stay under 300ms unless it is an overlay, so{' '}
+ <code>--duration-medium-max</code> (550ms) and everything above it
+ has no interface use. Meanwhile the components that genuinely need a
+ long loop bypass the scale entirely, because it stops at 1300ms:
+ StatusDot runs 2s and Chat 1.5s, both hardcoded. Either extend the
+ band or say plainly that ambient motion is a separate concern from
+ interface motion — but the two loops cannot be swept onto tokens
+ until one of those happens.
+ </Text>
+ }
+ />
+
+ <DemoCard
+ title="Stagger"
+ question="Group entrances want 30–80ms between items. Longer feels slow, and stagger must never block interaction — the last item has to be reachable before it has finished arriving.">
+ <DemoBody>
+ {STAGGERS.map(([name, , job]) => (
+ <VStack key={name} gap={1} {...stylex.props(sx.full)}>
+ <HStack gap={2} vAlign="center">
+ <Text {...stylex.props(sx.mono)}>{name}</Text>
+ <Text type="supporting" color="secondary">
+ {job}
+ </Text>
+ </HStack>
+ <TokenSlider token={name} max={160} step={5} />
+ </VStack>
+ ))}
+ </DemoBody>
+ </DemoCard>
+
+ <VStack gap={3}>
+ <Heading level={2}>The primitive scale, unchanged</Heading>
+ <Text color="secondary">
+ Theme-generated and working. Nothing here moves — the semantic layer
+ sits on top, which is what keeps the change non-breaking.
+ </Text>
+ <Card padding={0}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Primitive</TableHeaderCell>
+ <TableHeaderCell>Value</TableHeaderCell>
+ <TableHeaderCell>Semantic alias</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {PRIMITIVE_DURATIONS.map(([name, ms]) => {
+ const aliases = SEMANTIC_DURATIONS.filter(
+ d => d.primitive === name,
+ );
+ return (
+ <TableRow key={name}>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)}>{name}</Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {ms}ms
+ </Text>
+ </TableCell>
+ <TableCell>
+ {aliases.length > 0 ? (
+ <HStack gap={1} wrap="wrap">
+ {aliases.map(a => (
+ <Badge
+ key={a.name}
+ variant="success"
+ label={a.name}
+ />
+ ))}
+ </HStack>
+ ) : (
+ <Text color="secondary">—</Text>
+ )}
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ </TableBody>
+ </Table>
+ </Card>
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Where this lands</Heading>
+ <Text color="secondary">
+ Not a <code>:root</code> block — core defines its tokens through
+ StyleX, so the proposal is an addition to two existing objects.
+ </Text>
+ <CodeBlock
+ language="ts"
+ title="@astryxdesign/core/src/theme/tokens.stylex.ts"
+ hasCopyButton
+ code={`export const easeDefaults = {
+ '--ease-standard': 'cubic-bezier(0.24, 1, 0.4, 1)', // kept, deprecated in docs
+ '--ease-entry': ${JSON.stringify(rawToken('--ease-entry'))},
+ '--ease-exit': ${JSON.stringify(rawToken('--ease-exit'))},
+ '--ease-move': ${JSON.stringify(rawToken('--ease-move'))},
+ '--ease-state': ${JSON.stringify(rawToken('--ease-state'))},
+ '--ease-linear': ${JSON.stringify(rawToken('--ease-linear'))},
+ '--ease-drawer': ${JSON.stringify(rawToken('--ease-drawer'))},
+} as const;
+
+export const durationDefaults = {
+ // the nine primitives stay exactly as they are
+ ...
+ // semantic layer, aliased so a theme retunes both at once
+${SEMANTIC_DURATIONS.map(
+ d =>
+ ` '${d.name}': ${JSON.stringify(rawToken(d.name))},${
+ d.primitive != null ? ` // ${d.primitive}` : ''
+ }`,
+).join('\n')}
+} as const;`}
+ />
+ <Text type="supporting" color="secondary">
+ The export page emits this with whatever you have tuned. See{' '}
+ <Link href="/pages/motion-lab/export/">Export tuning</Link>.
+ </Text>
+ </VStack>
+ </LabPage>
+ );
+}
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.tsx
index ffdf2b0c4a..06d056d10e 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
@@ -1,10 +1,510 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
+'use client';
+
/**
- * Route shim for the Motion Lab's violations page.
+ * @file page.tsx
+ * @input The generated audit, the lab store
+ * @output Every hardcoded duration and curve, with what it becomes
+ * @position /motion/violations
*
- * The lab's pages live together under src/motion/pages so the section
- * reads as one thing; these files only place them on routes.
+ * The brief says 28; the measured number is higher, and the difference is not
+ * carelessness: a third of them are one deliberate reduced-motion idiom. The
+ * page is organised around that, because a sweep planned for 28 careless
+ * values and a sweep that contains a policy question are different pieces of
+ * work. Counts come from the generated audit, never from prose.
*/
-export {default} from '../../../../../motion/pages/violations';
+import {useMemo, useState} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import {Badge} from '@astryxdesign/core/Badge';
+import {Banner} from '@astryxdesign/core/Banner';
+import {Card} from '@astryxdesign/core/Card';
+import {Grid} from '@astryxdesign/core/Grid';
+import {Link} from '@astryxdesign/core/Link';
+import {
+ SegmentedControl,
+ SegmentedControlItem,
+} from '@astryxdesign/core/SegmentedControl';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow,
+} from '@astryxdesign/core/Table';
+import {TextInput} from '@astryxdesign/core/TextInput';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+import {Heading, Text} from '@astryxdesign/core/Text';
+import {LabPage} from '../PageFrame';
+import {ComparePanes, DemoBody, DemoCard, TokenSlider} from '../LabPrimitives';
+import {LoopRig, TintRig} from '../LabDemos';
+import {
+ AUDIT_COUNTS,
+ HARDCODED_BY_COMPONENT,
+ HARDCODED_SITES,
+ LITERAL_VALUES,
+ type HardcodedSite,
+} from '../__generated__/motionAudit';
+
+const sx = stylex.create({
+ full: {width: '100%'},
+ mono: {fontFamily: 'var(--font-family-code)', fontSize: '12px'},
+ bad: {color: 'var(--color-text-error, #d3543f)'},
+ good: {color: 'var(--color-text-success, #2f7d52)'},
+ search: {maxWidth: '280px', width: '100%'},
+ scroll: {maxHeight: '560px', overflow: 'auto', width: '100%'},
+ statValue: {fontSize: '24px', fontWeight: 650, letterSpacing: '-0.02em'},
+});
+
+/**
+ * What each literal should become. Grouped by the shape of the decision rather
+ * than by component, because the sweep is only mechanical for two of these
+ * four groups — the other two need an answer first.
+ */
+type Family = {
+ readonly id: string;
+ readonly title: string;
+ readonly blurb: string;
+ readonly token: string;
+ readonly matches: (site: HardcodedSite) => boolean;
+ readonly mechanical: boolean;
+ readonly blockedBy?: string;
+};
+
+const FAMILIES: ReadonlyArray<Family> = [
+ {
+ id: 'instant',
+ title: 'Reduced-motion escapes',
+ blurb:
+ 'Every one of these is the same idiom: collapse a transition to nothing when the user has asked for less motion. It is not sloppiness, and it is not safe to sweep blind — a zero duration fires no transitionend, so anything sequencing off that event breaks. The 0.01s spelling exists to keep the event.',
+ token: '--duration-instant',
+ matches: s => s.ms != null && s.ms <= 10,
+ mechanical: false,
+ blockedBy:
+ 'Decide whether --duration-instant is 0 or 0.01ms before sweeping any of these.',
+ },
+ {
+ id: 'table',
+ title: 'Table interaction tint',
+ blurb:
+ 'Ten sites across columnResize, groupedRows, rowExpansion, stickyColumns and tree: seven 150ms durations and three bare `ease` curves, several of them the two halves of one `transition` shorthand. This resolves an open question in the brief — its "nine hardcoded values in Table" and its "six hardcoded 150ms values in Table tree" are the same set counted twice, not fifteen sites. 150ms and the token\u2019s 175ms are near-indistinguishable at 1×, so what this family buys is the lint rule, not a visual change.',
+ token: '--duration-state',
+ matches: s => s.component === 'Table',
+ mechanical: true,
+ },
+ {
+ id: 'loops',
+ title: 'Ambient loops',
+ blurb:
+ 'StatusDot at 2s and Chat at 1.5s, both outside a scale that stops at 1300ms. They did not bypass the tokens by accident — there is no token that reaches. This group cannot be swept until the slow band is extended or ambient motion is declared a separate concern.',
+ token: '--duration-continuous (does not reach)',
+ matches: s => s.ms != null && s.ms >= 1000,
+ mechanical: false,
+ blockedBy: 'Needs the ambient-band decision.',
+ },
+ {
+ id: 'curves',
+ title: 'Curves authored by hand',
+ blurb:
+ 'Mostly linear, and mostly correct: a progress bar and a scroll-driven wheel should be linear. The exception is the sheet exit, which authors a full cubic-bezier with a comment measuring why the standard curve fails. That comment is the specification for --ease-exit.',
+ token: '--ease-linear / --ease-exit / --ease-state',
+ matches: s => s.kind === 'easing',
+ mechanical: true,
+ },
+];
+
+function familyOf(site: HardcodedSite): Family | undefined {
+ return FAMILIES.find(f => f.matches(site));
+}
+
+function tokenFor(site: HardcodedSite): string {
+ if (site.kind === 'easing') {
+ if (site.value === 'linear') {
+ return '--ease-linear';
+ }
+ if (site.value.startsWith('cubic-bezier')) {
+ return '--ease-exit';
+ }
+ return '--ease-state';
+ }
+ if (site.ms == null) {
+ return '--duration-state';
+ }
+ if (site.ms <= 10) {
+ return '--duration-instant';
+ }
+ if (site.ms >= 1000) {
+ return 'no token reaches';
+ }
+ if (site.ms <= 160) {
+ return '--duration-state';
+ }
+ return '--duration-enter';
+}
+
+function countIn(familyId: string): number {
+ return HARDCODED_SITES.filter(s => familyOf(s)?.id === familyId).length;
+}
+
+export default function ViolationsPage() {
+ const [query, setQuery] = useState('');
+ const [kind, setKind] = useState<'all' | 'duration' | 'easing'>('all');
+
+ const rows = useMemo(
+ () =>
+ HARDCODED_SITES.filter(site => {
+ if (kind !== 'all' && site.kind !== kind) {
+ return false;
+ }
+ if (query.trim() === '') {
+ return true;
+ }
+ const q = query.toLowerCase();
+ return (
+ site.component.toLowerCase().includes(q) ||
+ site.file.toLowerCase().includes(q) ||
+ site.value.toLowerCase().includes(q) ||
+ site.prop.toLowerCase().includes(q)
+ );
+ }),
+ [kind, query],
+ );
+
+ return (
+ <LabPage
+ title="Hardcoded durations and curves"
+ intro="The token linter polices type, spacing, radius and colour. It has no entry for duration or easing, which is a complete explanation for every site below. Adding those entries turns rubric criterion 3 from a review question into a build failure."
+ decides="What each hardcoded site becomes, and whether the swap is visible at all."
+ badges={
+ <Badge
+ variant="error"
+ label={`${AUDIT_COUNTS.hardcodedTotal} measured`}
+ />
+ }>
+ <Banner
+ status="warning"
+ title={`The brief says 28. The measured number is ${AUDIT_COUNTS.hardcodedTotal}.`}
+ description={
+ <Text>
+ Higher, not lower — so the sweep is bigger than budgeted. More
+ importantly, the extra is not more of the same: {countIn('instant')}{' '}
+ of them are one reduced-motion idiom that needs a decision before it
+ can be touched, and {countIn('loops')} are ambient loops that no
+ token currently reaches. Two of the four families below are
+ mechanical; the other two are blocked on answers, and together they
+ are {countIn('instant') + countIn('loops')} of the{' '}
+ {AUDIT_COUNTS.hardcodedTotal}.
+ </Text>
+ }
+ />
+
+ <Grid columns={{minWidth: 220}} gap={3}>
+ {[
+ [
+ AUDIT_COUNTS.hardcodedTotal,
+ 'Hardcoded sites',
+ 'measured against [email protected]',
+ ],
+ [AUDIT_COUNTS.hardcodedDuration, 'Durations and delays', ''],
+ [AUDIT_COUNTS.hardcodedEasing, 'Curves', ''],
+ [
+ AUDIT_COUNTS.durationWithoutCurve,
+ 'Durations with no curve',
+ 'silently taking the CSS default',
+ ],
+ ].map(([value, label, detail]) => (
+ <Card key={String(label)} padding={4}>
+ <VStack gap={0.5}>
+ <span {...stylex.props(sx.statValue)}>{value}</span>
+ <Text type="supporting">{label}</Text>
+ {detail !== '' && (
+ <Text type="supporting" color="secondary">
+ {detail}
+ </Text>
+ )}
+ </VStack>
+ </Card>
+ ))}
+ </Grid>
+
+ <VStack gap={3}>
+ <Heading level={2}>Four families, two of them blocked</Heading>
+ {FAMILIES.map(family => {
+ const count = HARDCODED_SITES.filter(
+ s => familyOf(s)?.id === family.id,
+ ).length;
+ return (
+ <DemoCard
+ key={family.id}
+ title={family.title}
+ question={family.blurb}
+ badges={
+ <HStack gap={1}>
+ <Badge label={`${count} sites`} />
+ <Badge
+ variant={family.mechanical ? 'success' : 'warning'}
+ label={family.mechanical ? 'mechanical' : 'blocked'}
+ />
+ </HStack>
+ }>
+ {family.id === 'table' && (
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — 150ms, default curve',
+ content: <TintRig mode="before" />,
+ },
+ {
+ tone: 'after',
+ label: 'Proposed — --duration-state, --ease-state',
+ content: <TintRig mode="after" />,
+ },
+ ]}
+ />
+ )}
+ {family.id === 'loops' && (
+ <ComparePanes
+ panes={[
+ {
+ tone: 'before',
+ label: 'Today — hardcoded, outside the scale',
+ content: <LoopRig policy="today" />,
+ },
+ {
+ tone: 'neutral',
+ label: 'Stopped',
+ content: <LoopRig policy="degrade" />,
+ },
+ ]}
+ />
+ )}
+ <DemoBody>
+ {family.id === 'table' && (
+ <>
+ <TokenSlider
+ token="--duration-state"
+ label="state"
+ max={400}
+ />
+ <Text type="supporting" color="secondary">
+ Put the rail on 4× or 8× if you want to see the difference
+ between 150 and 175 at all. That it is hard to see at 1×
+ is the honest finding, and it is the argument for treating
+ this family as a lint fix rather than a design change.
+ </Text>
+ </>
+ )}
+ {family.blockedBy != null && (
+ <Text type="supporting" {...stylex.props(sx.bad)}>
+ Blocked: {family.blockedBy}
+ </Text>
+ )}
+ <HStack gap={2} wrap="wrap">
+ {HARDCODED_SITES.filter(s => familyOf(s)?.id === family.id)
+ .slice(0, 6)
+ .map((s, i) => (
+ <Text
+ key={`${s.file}:${s.line}:${i}`}
+ {...stylex.props(sx.mono)}
+ color="secondary">
+ {s.file}:{s.line}
+ </Text>
+ ))}
+ {count > 6 && (
+ <Text type="supporting" color="secondary">
+ +{count - 6} more in the table below
+ </Text>
+ )}
+ </HStack>
+ </DemoBody>
+ </DemoCard>
+ );
+ })}
+ </VStack>
+
+ <VStack gap={3}>
+ <Heading level={2}>Every site</Heading>
+ <HStack gap={2} vAlign="center" wrap="wrap">
+ <div {...stylex.props(sx.search)}>
+ <TextInput
+ label="Filter sites"
+ isLabelHidden
+ placeholder="Filter by component, file or value…"
+ value={query}
+ onChange={setQuery}
+ />
+ </div>
+ <SegmentedControl
+ label="Kind"
+ size="sm"
+ value={kind}
+ onChange={value => setKind(value as 'all' | 'duration' | 'easing')}>
+ <SegmentedControlItem value="all" label="All" />
+ <SegmentedControlItem value="duration" label="Durations" />
+ <SegmentedControlItem value="easing" label="Curves" />
+ </SegmentedControl>
+ <Text type="supporting" color="secondary">
+ {rows.length} of {HARDCODED_SITES.length}
+ </Text>
+ </HStack>
+ <Card padding={0}>
+ <div {...stylex.props(sx.scroll)}>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Component</TableHeaderCell>
+ <TableHeaderCell>Site</TableHeaderCell>
+ <TableHeaderCell>Property</TableHeaderCell>
+ <TableHeaderCell>Today</TableHeaderCell>
+ <TableHeaderCell>Becomes</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {/* Two sites can share file, line, value and property when one
+ declaration carries a duration and a curve, so the index is
+ part of the identity. */}
+ {rows.map((site, i) => (
+ <TableRow
+ key={`${site.file}:${site.line}:${site.prop}:${site.value}:${i}`}>
+ <TableCell>
+ <Text weight="semibold">{site.component}</Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {site.file}:{site.line}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)} color="secondary">
+ {site.prop}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono, sx.bad)}>
+ {site.value}
+ </Text>
+ </TableCell>
+ <TableCell>
+ <Text {...stylex.props(sx.mono, sx.good)}>
+ {tokenFor(site)}
+ </Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </div>
+ </Card>
+ </VStack>
+
+ <Grid columns={{minWidth: 320}} gap={3}>
+ <Card padding={4}>
+ <VStack gap={2}>
+ <Heading level={3}>Literals in use</Heading>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Value</TableHeaderCell>
+ <TableHeaderCell>Sites</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {LITERAL_VALUES.map(([value, count]) => (
+ <TableRow key={value}>
+ <TableCell>
+ <Text {...stylex.props(sx.mono)}>{value}</Text>
+ </TableCell>
+ <TableCell>
+ <Text>{count}</Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </VStack>
+ </Card>
+ <Card padding={4}>
+ <VStack gap={2}>
+ <Heading level={3}>By component</Heading>
+ <Table density="compact">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Component</TableHeaderCell>
+ <TableHeaderCell>Sites</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {HARDCODED_BY_COMPONENT.map(([name, count]) => (
+ <TableRow key={name}>
+ <TableCell>
+ <Text>{name}</Text>
+ </TableCell>
+ <TableCell>
+ <Text>{count}</Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </VStack>
+ </Card>
+ </Grid>
+
+ <VStack gap={3}>
+ <Heading level={2}>Sweep order</Heading>
+ <Card padding={0}>
+ <Table density="balanced">
+ <TableHeader>
+ <TableRow>
+ <TableHeaderCell>Step</TableHeaderCell>
+ <TableHeaderCell>Why this order</TableHeaderCell>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {[
+ [
+ '1. Land the semantic tokens as aliases',
+ 'Nothing to migrate to until they exist, and aliasing means nothing shifts perceptually while the sweep runs.',
+ ],
+ [
+ '2. Add the lint rules in warn mode',
+ 'Produces the real inventory continuously, so this page stops being a snapshot.',
+ ],
+ [
+ '3. Answer the two blocked families',
+ 'Whether --duration-instant is 0 or 0.01ms, and whether the slow band grows an ambient tier.',
+ ],
+ [
+ '4. Sweep',
+ 'Mechanical once the tokens and the answers both exist.',
+ ],
+ [
+ '5. Flip lint to error',
+ 'Only once the count is zero, or the remainder is explicitly allowlisted.',
+ ],
+ ].map(([step, why]) => (
+ <TableRow key={step}>
+ <TableCell>
+ <Text weight="semibold">{step}</Text>
+ </TableCell>
+ <TableCell>
+ <Text color="secondary">{why}</Text>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ </Card>
+ <Text type="supporting" color="secondary">
+ The rule stub is on{' '}
+ <Link href="/pages/motion-lab/export/">Export tuning</Link>. The
+ reduced-motion decision that blocks family one is on{' '}
+ <Link href="/pages/motion-lab/reduced-motion/">Reduced motion</Link>.
+ </Text>
+ </VStack>
+ </LabPage>
+ );
+}
diff --git a/apps/sandbox/src/app/SandboxNav.tsx b/apps/sandbox/src/app/SandboxNav.tsx
index 7a099c4c29..97925fd315 100644
--- a/apps/sandbox/src/app/SandboxNav.tsx
+++ b/apps/sandbox/src/app/SandboxNav.tsx
@@ -9,6 +9,7 @@
'use client';
+import {useEffect, useRef, useState} from 'react';
import * as stylex from '@stylexjs/stylex';
import {usePathname} from 'next/navigation';
import Link from 'next/link';
@@ -136,13 +137,34 @@ function SandboxHeader() {
);
}
+/**
+ * Tools that carry their own page navigation. Entering one collapses this rail
+ * so the two nav levels are not competing for the same edge of the screen; it
+ * is a one-shot on entry rather than a lock, so expanding it back inside the
+ * tool works and sticks.
+ */
+const SELF_NAVIGATING_TOOLS = ['/pages/motion-lab'];
+
export function SandboxNav() {
const pathname = usePathname();
+ const [isCollapsed, setIsCollapsed] = useState(false);
+ const wasInTool = useRef(false);
+
+ const isInTool = SELF_NAVIGATING_TOOLS.some(p => pathname.startsWith(p));
+
+ useEffect(() => {
+ // Only on the transition, so a manual expand inside the tool is not undone
+ // on the next route change within it.
+ if (isInTool !== wasInTool.current) {
+ setIsCollapsed(isInTool);
+ wasInTool.current = isInTool;
+ }
+ }, [isInTool]);
return (
<SideNav
header={<SandboxHeader />}
- collapsible
+ collapsible={{isCollapsed, onCollapsedChange: setIsCollapsed}}
resizable={{
defaultWidth: 300,
minWidth: 220,
diff --git a/apps/sandbox/src/motion/MotionLabShell.tsx b/apps/sandbox/src/motion/MotionLabShell.tsx
deleted file mode 100644
index e1b462d2c6..0000000000
--- a/apps/sandbox/src/motion/MotionLabShell.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file MotionLabShell.tsx
- * @input Motion Lab store, control rail
- * @output The scope element every lab page renders inside
- * @position Motion Lab chrome; used by app/motion/layout.tsx
- *
- * The scope element is where the tuned custom properties land. Keeping them
- * here rather than on `:root` means the lab can retune `--ease-standard` to
- * argue about it without the docsite's own nav starting to move differently.
- */
-
-import {VStack} from '@astryxdesign/core/Layout';
-import {useEffect, useRef, type ReactNode} from 'react';
-import {useMotionLab} from './MotionLabStore';
-import {MotionControlRail} from './MotionControlRail';
-import styles from './MotionLab.module.css';
-
-export function MotionLabShell({children}: {children: ReactNode}) {
- const {registerScope, reducedMotion} = useMotionLab();
- const ref = useRef<HTMLDivElement | null>(null);
-
- useEffect(() => {
- registerScope(ref.current);
- return () => registerScope(null);
- }, [registerScope]);
-
- return (
- <div ref={ref} className={styles.scope} data-reduced-motion={reducedMotion}>
- <VStack gap={0}>
- <MotionControlRail />
- {children}
- </VStack>
- </div>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/bugs.tsx b/apps/sandbox/src/motion/pages/bugs.tsx
deleted file mode 100644
index 137c8f8326..0000000000
--- a/apps/sandbox/src/motion/pages/bugs.tsx
+++ /dev/null
@@ -1,756 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input The generated audit, the installed core source, the lab store
- * @output Which structural findings survive contact with the code
- * @position /motion/bugs
- *
- * Of the four structural findings, one is real and underplayed, one is a
- * misreading of three components, one is correct code the scanner flags, and
- * one cannot be verified in this app at all. Every claim here is checked
- * against the installed package and cited file:line, including the places
- * where the generated audit was itself wrong.
- */
-
-import {useCallback, useEffect, useRef, useState} from 'react';
-import * as stylex from '@stylexjs/stylex';
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Card} from '@astryxdesign/core/Card';
-import {CodeBlock} from '@astryxdesign/core/CodeBlock';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Switch} from '@astryxdesign/core/Switch';
-import {HStack, VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import {LabPage} from '../PageFrame';
-import {
- ComparePanes,
- DemoBody,
- DemoCard,
- LabSlider,
- Runner,
- useLoop,
-} from '../LabPrimitives';
-import {useMotionLab} from '../MotionLabStore';
-import {
- AUDIT_COUNTS,
- DURATION_WITHOUT_CURVE,
- NOOP_TRANSITIONS,
- TIMEOUT_LITERALS,
- TRANSFORM_TRANSITIONS,
- TRANSITION_ALL,
-} from '../__generated__/motionAudit';
-import styles from '../MotionLab.module.css';
-
-const sx = stylex.create({
- full: {width: '100%'},
- mono: {fontFamily: 'var(--font-family-code)', fontSize: '12px'},
- rows: {width: '100%'},
- readout: {
- fontFamily: 'var(--font-family-code)',
- fontSize: '13px',
- },
- drawerBack: {padding: '14px', maxWidth: '34%'},
-});
-
-/** The rotation rule the brief reads as dead, verbatim from the package. */
-const SELECTOR_SOURCE = `// Rotation lives on the chevron glyph itself (passed through \`xstyle\`), not
-// on the layout wrapper above, so the icon's \`selector-indicator-icon\` theme
-// target and the open/closed transform sit on one element — a theme can
-// restyle the mark and its rotation through a single selector. The wrapper
-// keeps only layout. The status branch renders a different icon, so it never
-// picks these up and needs no transition opt-out.
-triggerIconRotation: {
- transitionProperty: 'transform',
- transitionDuration: durationVars['--duration-fast'],
- transitionTimingFunction: easeVars['--ease-standard'],
- transformOrigin: 'center',
-},
-triggerIconOpen: {
- transform: 'rotate(180deg)',
-},`;
-
-const LIGHTBOX_SOURCE = `image: {
- maxWidth: '100%',
- maxHeight: '100%',
- objectFit: 'contain',
- pointerEvents: 'none',
- transitionProperty: 'transform',
- transitionDuration: {
- default: '200ms',
- '@media (prefers-reduced-motion: reduce)': '0ms',
- },
- transitionTimingFunction: 'ease-out',
-},
-imageDragging: {
- transitionProperty: 'none',
-},
-
-// ...applied only while the pointer is down, Lightbox.tsx:691
-isDragging && styles.imageDragging,`;
-
-const TIMER_FIX = `// What the brief describes: a literal that has to be kept in sync by hand.
-setTimeout(() => setMounted(false), 250);
-
-// What removes the class of bug: the element says when it is done.
-const panel = panelRef.current;
-if (panel == null) {
- setMounted(false);
- return;
-}
-Promise.allSettled(panel.getAnimations().map(a => a.finished)).then(() =>
- setMounted(false),
-);
-
-// The transitionend form, for a single known property. Note the guard: a
-// bubbling transitionend from a child would unmount the panel early, and a
-// zero duration fires nothing at all — which is why --duration-instant
-// cannot simply be 0.
-panel.addEventListener('transitionend', event => {
- if (event.target === panel && event.propertyName === 'transform') {
- setMounted(false);
- }
-});`;
-
-const INSTANT_DWC = DURATION_WITHOUT_CURVE.filter(
- site => site.decl?.includes('0.01s') === true,
-);
-const SUBSTANTIVE_DWC = DURATION_WITHOUT_CURVE.filter(
- site => site.decl?.includes('0.01s') !== true,
-);
-const SUBSTANTIVE_DWC_COMPONENTS = [
- ...new Set(SUBSTANTIVE_DWC.map(site => site.component)),
-].sort();
-
-/** transform declared inside a longer property list, which a grep never finds. */
-const MULTI_PROPERTY_TRANSFORMS = TRANSFORM_TRANSITIONS.filter(
- site => site.decl?.includes(',') === true,
-);
-const SINGLE_PROPERTY_TRANSFORMS =
- TRANSFORM_TRANSITIONS.length - MULTI_PROPERTY_TRANSFORMS.length;
-/** ...and the ones that also animate a layout property, which is criterion 6. */
-const LAYOUT_MIXED_TRANSFORMS = MULTI_PROPERTY_TRANSFORMS.filter(site =>
- /width|height|top|left|margin|padding|inset/.test(site.decl ?? ''),
-);
-
-const LINT_MAP: ReadonlyArray<{
- readonly finding: string;
- readonly rule: string;
- readonly status: string;
-}> = [
- {
- finding: 'A duration with no declared curve',
- rule: 'require-timing-function — a transitionDuration in a rule with no transitionTimingFunction and no shorthand.',
- status: `${AUDIT_COUNTS.durationWithoutCurve} sites today, ${SUBSTANTIVE_DWC.length} of them substantive.`,
- },
- {
- finding: 'A transitionProperty with no duration',
- rule: "no-noop-transition — same shape, inverted. Must exempt transitionProperty: 'none', which is a deliberate opt-out.",
- status: `${AUDIT_COUNTS.noopTransitions} site today, and it is the exemption case.`,
- },
- {
- finding: 'transition: all',
- rule: 'no-transition-all — a property list containing all.',
- status: `${TRANSITION_ALL.length} today. Pure regression guard.`,
- },
- {
- finding: 'A hardcoded duration, delay or curve',
- rule: 'motion-tokens-only — any time literal or bezier literal outside the token file.',
- status: `${AUDIT_COUNTS.hardcodedTotal} today. Needs an allowlist for the reduced-motion escape.`,
- },
- {
- finding: 'A timer literal standing in for a transition',
- rule: 'no-animation-timeout — a setTimeout whose literal matches a duration token value, inside a component that transitions.',
- status: `${TIMEOUT_LITERALS.length} literal timer in core, and it is unrelated to motion.`,
- },
- {
- finding: 'A CSS transition on transform',
- rule: 'no-transform-transition — criterion 12, the motion-library blocker.',
- status: `${AUDIT_COUNTS.transformTransitions} sites across ${AUDIT_COUNTS.transformTransitionComponents} components — criterion 12's entire caseload.`,
- },
-];
-
-/** Rows carrying the no-op rule, beside rows carrying a real one. */
-function Rows({variant}: {variant: 'noop' | 'tint'}) {
- return (
- <VStack gap={1} {...stylex.props(sx.rows)}>
- {['Row one', 'Row two', 'Row three'].map(row => (
- // The CSS module owns both rules: the point of the pane is the
- // declaration itself, so it has to be the real one.
- <div
- key={row}
- className={variant === 'noop' ? styles.noopRow : styles.tintRow}>
- <Text type="supporting">{row}</Text>
- </div>
- ))}
- </VStack>
- );
-}
-
-/**
- * The unmount timer racing the slide. Both sliders are live and both tracks
- * run in real time, because the finding is a relationship between two numbers
- * rather than either number on its own.
- */
-function DrawerCutDemo() {
- const {speed} = useMotionLab();
- const [slideMs, setSlideMs] = useState(410);
- const [timerMs, setTimerMs] = useState(250);
- const [derived, setDerived] = useState(false);
- const [open, setOpen] = useState(true);
- const [cut, setCut] = useState(false);
-
- const slideFill = useRef<HTMLSpanElement | null>(null);
- const timerFill = useRef<HTMLSpanElement | null>(null);
- const raf = useRef<number | null>(null);
- const timers = useRef<Array<number>>([]);
-
- const effectiveTimer = derived ? slideMs : timerMs;
- const slideRun = slideMs * speed;
- const timerRun = effectiveTimer * speed;
- const completed = Math.min(100, (effectiveTimer / slideMs) * 100);
-
- const clear = useCallback(() => {
- for (const id of timers.current) {
- window.clearTimeout(id);
- }
- timers.current = [];
- if (raf.current != null) {
- cancelAnimationFrame(raf.current);
- raf.current = null;
- }
- }, []);
-
- const play = useCallback(() => {
- clear();
- setCut(false);
- setOpen(true);
- if (slideFill.current != null) {
- slideFill.current.style.width = '0%';
- }
- if (timerFill.current != null) {
- timerFill.current.style.width = '0%';
- }
- timers.current.push(
- window.setTimeout(() => {
- setOpen(false);
- const start = performance.now();
- const span = Math.max(slideRun, timerRun);
- const step = (now: number) => {
- const elapsed = now - start;
- if (slideFill.current != null) {
- slideFill.current.style.width = `${Math.min(100, (elapsed / slideRun) * 100)}%`;
- }
- if (timerFill.current != null) {
- timerFill.current.style.width = `${Math.min(100, (elapsed / timerRun) * 100)}%`;
- }
- if (elapsed < span) {
- raf.current = requestAnimationFrame(step);
- }
- };
- raf.current = requestAnimationFrame(step);
- timers.current.push(window.setTimeout(() => setCut(true), timerRun));
- }, 700),
- );
- }, [clear, slideRun, timerRun]);
-
- useEffect(() => clear, [clear]);
- useLoop(play, Math.max(2600, slideRun + timerRun + 1400));
-
- return (
- <VStack gap={3} {...stylex.props(sx.full)}>
- <div className={`${styles.stage} ${styles.stageBlock}`}>
- <VStack gap={1} {...stylex.props(sx.drawerBack)}>
- <Text type="supporting" color="secondary">
- Page behind
- </Text>
- </VStack>
- {/* The transition, the visibility hand-off and the cut are all in the
- CSS module: a style object cannot express the [data-open] pair. */}
- <div
- data-open={open}
- style={{['--drawer-slide' as string]: `${slideRun}ms`}}
- className={
- cut ? `${styles.drawer} ${styles.drawerCut}` : styles.drawer
- }>
- <VStack gap={1}>
- <Text weight="semibold">Drawer</Text>
- <Text type="supporting" color="secondary">
- Slides on --ease-drawer. Removed by a timer that does not know
- about it.
- </Text>
- </VStack>
- </div>
- </div>
-
- <Grid columns={{minWidth: 260}} gap={3}>
- <VStack gap={1}>
- <Text type="supporting" weight="semibold">
- Slide — {slideMs}ms
- </Text>
- <span className={styles.track}>
- <span
- ref={slideFill}
- className={`${styles.trackFill} ${styles.trackSlide}`}
- />
- </span>
- </VStack>
- <VStack gap={1}>
- <Text type="supporting" weight="semibold">
- Unmount timer — {effectiveTimer}ms
- </Text>
- <span className={styles.track}>
- <span
- ref={timerFill}
- className={`${styles.trackFill} ${styles.trackTimer}`}
- />
- </span>
- </VStack>
- </Grid>
-
- <Text {...stylex.props(sx.readout)}>
- {completed >= 100
- ? 'The panel survives its whole exit — 100% of the slide runs.'
- : `The panel is removed at ${Math.round(completed)}% of its travel. ${Math.round(
- 100 - completed,
- )}% of the exit never runs.`}
- </Text>
-
- <LabSlider
- label="Slide duration"
- value={slideMs}
- min={150}
- max={800}
- step={10}
- format={v => `${v}ms`}
- onChange={setSlideMs}
- />
- <LabSlider
- label="Unmount timer"
- value={timerMs}
- min={50}
- max={800}
- step={10}
- format={v => `${v}ms`}
- onChange={setTimerMs}
- />
- <Switch
- label="Derive the timer from the transition"
- description="What the fix does: the panel unmounts when its own animation finishes, so the two numbers cannot drift apart."
- value={derived}
- onChange={setDerived}
- />
- </VStack>
- );
-}
-
-export default function MotionBugsPage() {
- const noop = NOOP_TRANSITIONS[0];
-
- return (
- <LabPage
- title="Small bugs"
- intro="Four structural findings in the brief. One is real and underplayed, one is a misreading of three components, one is correct code the scanner flags, and one cannot be verified in this app at all."
- badges={<Badge variant="warning" label="1 of 4 survives as written" />}
- decides="Which of the structural findings are real once you look at the code.">
- <Banner
- status="warning"
- title="The three dead no-op transitions are not there"
- description={
- <Text>
- The brief lists three dead no-op transitions in Selector,
- ComplexSelector and MultiSelector. All three rules exist, and all
- three carry a tokenised duration
- <em> and </em> a tokenised curve. The audit finds exactly one no-op
- in the whole package —{' '}
- <code>
- {noop?.file}:{noop?.line}
- </code>{' '}
- — and it is a deliberate{' '}
- <code>transitionProperty: &lsquo;none&rsquo;</code> that turns a
- transition off during a drag. Correct code, flagged by a scanner.
- </Text>
- }
- />
-
- <DemoCard
- title="The three that are not dead"
- question="Selector, ComplexSelector and MultiSelector all declare the same rotation rule. Is anything missing from it?"
- badges={<Badge variant="success" label="No finding" />}>
- <DemoBody>
- <CodeBlock
- language="tsx"
- title="Selector/Selector.tsx:201-214 — identical at ComplexSelector.tsx:154-166 and MultiSelector.tsx:178-191"
- code={SELECTOR_SOURCE}
- hasCopyButton
- maxHeight={340}
- />
- <Text type="supporting">
- Property, duration and curve, all three tokenised, paired with{' '}
- <code>triggerIconOpen</code> which supplies the transform. There is
- nothing dead here.
- </Text>
- <Text type="supporting" color="secondary">
- The misreading is easy to make and the source explains it: the
- rotation was moved off the layout wrapper and onto the chevron
- glyph, which receives it through <code>xstyle</code>. Read the
- wrapper and you see a component that rotates something with no
- transition anywhere near it. Worth re-checking before it becomes a
- milestone line item — it is currently costed as three fixes that do
- not exist.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="The one real no-op is correct"
- question={`${noop?.file}:${noop?.line} — a transitionProperty with no duration. Bug, or opt-out?`}
- badges={<Badge variant="success" label="Working as intended" />}>
- <DemoBody>
- <CodeBlock
- language="tsx"
- title="Lightbox/Lightbox.tsx:180-194, applied at :691"
- code={LIGHTBOX_SOURCE}
- hasCopyButton
- maxHeight={380}
- />
- <Text type="supporting">
- The zoomed image transitions <code>transform</code> over 200ms so a
- zoom step glides. While the pointer is down,{' '}
- <code>imageDragging</code> replaces that with{' '}
- <code>transitionProperty: &lsquo;none&rsquo;</code>, so the image
- tracks the pointer 1:1 instead of easing 200ms behind it. Removing
- it would make dragging feel like dragging through syrup.
- </Text>
- <Text type="supporting" color="secondary">
- The audit is right that the shape is a no-op and wrong that it is a
- defect. The lint rule needs the exemption written in from the start:{' '}
- <code>none</code> is the only value of{' '}
- <code>transitionProperty</code> that legitimately appears without a
- duration.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="Why the shape is still worth linting"
- question="Both panes declare a transition. Only one of them animates. Which is which, at a glance in review?"
- actions={<Badge variant="neutral" label="Hover the rows" />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label:
- 'transitionProperty, no duration — reads like motion, does nothing',
- content: <Rows variant="noop" />,
- },
- {
- tone: 'after',
- label: 'The same rule with a duration and a curve',
- content: <Rows variant="tint" />,
- },
- ]}
- />
- <DemoBody>
- <Text type="supporting" color="secondary">
- This is the argument for the rule even though the package has one
- instance and it is exempt: the failure is invisible in review. A
- reviewer sees the word <code>transition</code> and moves on, and the
- component ships with a state change that snaps.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title={`${AUDIT_COUNTS.durationWithoutCurve} durations with no declared curve`}
- question="A duration with no timing function silently gets the CSS default, which is ease — not --ease-standard. How different are they?"
- badges={
- <Badge variant="warning" label="The largest structural finding" />
- }>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'ease — what these sites actually run',
- content: (
- <Runner
- durationToken="--duration-reveal"
- easeToken="--ease-state"
- />
- ),
- },
- {
- tone: 'after',
- label: '--ease-standard — the curve core ships',
- content: (
- <Runner
- durationToken="--duration-reveal"
- easeToken="--ease-standard-today"
- />
- ),
- },
- ]}
- />
- <DemoBody>
- <Text type="supporting">
- <code>ease</code> is <code>cubic-bezier(0.25, 0.1, 0.25, 1)</code> —
- a gentle symmetrical curve. <code>--ease-standard</code> is{' '}
- <code>cubic-bezier(0.24, 1, 0.4, 1)</code>, which leaves immediately
- and decelerates hard. Every site below is running the first one
- while its neighbours run the second, and nobody wrote that decision
- down.
- </Text>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Site</TableHeaderCell>
- <TableHeaderCell>Declaration</TableHeaderCell>
- <TableHeaderCell>Reading</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {DURATION_WITHOUT_CURVE.map(site => {
- const instant = site.decl?.includes('0.01s') === true;
- return (
- <TableRow key={`${site.file}:${site.line}`}>
- <TableCell>
- <Text
- {...stylex.props(
- sx.mono,
- )}>{`${site.file}:${site.line}`}</Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {site.decl}
- </Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {instant
- ? 'Reduced-motion escape — the curve is irrelevant at 10ms'
- : 'Substantive: a real duration silently taking the CSS default'}
- </Text>
- </TableCell>
- </TableRow>
- );
- })}
- </TableBody>
- </Table>
- </Card>
- <Text type="supporting">
- {SUBSTANTIVE_DWC.length} of the {AUDIT_COUNTS.durationWithoutCurve}{' '}
- are substantive — a real duration silently taking <code>ease</code>{' '}
- — across {SUBSTANTIVE_DWC_COMPONENTS.join(', ')}. Only{' '}
- {INSTANT_DWC.length} is the <code>0.01s</code> escape, where having
- no curve is the right answer. The brief underplays this finding, and
- the figure has already moved twice as the scanner improved: read it
- out of the audit rather than quoting it.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="The drawer exit, cut short"
- question="Slide 410ms, unmount at 250ms. Drag either slider: at what point does an exit stop being an exit?"
- badges={<Badge variant="error" label="Confirmed in lab" />}>
- <DemoBody>
- <Text type="supporting">
- <strong>The brief is right, to the millisecond.</strong>{' '}
- <code>lab/Drawer/Drawer.tsx:459</code> hardcodes a <code>250</code>
- ms close timer, while <code>:157</code> and <code>:219</code> set
- the panel and scrim transitions to <code>--duration-medium</code> —
- 410ms. The dialog is closed at 61% of its own travel, so the last
- 160ms of the slide never renders.
- </Text>
- <Text type="supporting" color="secondary">
- The reduced-motion branch beside it is the tell: the same expression
- picks <code>10</code>ms when the user asks for less motion, which
- means someone thought carefully about the timer and still had to
- restate the duration by hand. Nothing in either package derives a
- timer from its transition; MobileNav is the only component that even
- tries, and it does it by reading <code>getComputedStyle</code>. That
- is the argument for the JS token mirror in one file.
- </Text>
- </DemoBody>
- <DemoBody>
- <DrawerCutDemo />
- </DemoBody>
- <DemoBody>
- <CodeBlock
- language="tsx"
- title="The class of bug, and the two ways out of it"
- code={TIMER_FIX}
- hasCopyButton
- maxHeight={420}
- />
- <Text type="supporting" color="secondary">
- The bug is not the number 250. It is that two numbers have to agree
- and only one of them is a token: retune{' '}
- <code>--duration-overlay</code> and the timer keeps its old value,
- so the cut appears in a diff that never touched the drawer.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="transition: all"
- question={`${TRANSITION_ALL.length} sites. Is a rule with nothing to fix worth writing?`}
- badges={
- <Badge variant="success" label={`${TRANSITION_ALL.length} today`} />
- }>
- <DemoBody>
- <Text type="supporting">
- Yes, and it is the cheapest rule in the set.{' '}
- <code>transition: all</code> animates every property that ever
- changes, including layout properties nobody intended to animate, and
- it arrives in a codebase one careless line at a time. Core is clean
- today; the rule keeps it clean and costs one regex.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <VStack gap={3}>
- <Heading level={2}>
- The count moved twice, and the brief was right
- </Heading>
- <Text color="secondary">
- Every structural number on this page is a scanner output, so what the
- scanner can see decides what gets scheduled. This section started as a
- grep run against a generated count that looked too small; the
- generator has since been fixed twice, and criterion 12&rsquo;s
- caseload went from something smaller than the brief&rsquo;s estimate
- to something larger than it.
- </Text>
- <Grid columns={{minWidth: 300}} gap={3}>
- <Card padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">A scanner sees shape, not intent</Text>
- <Text type="supporting" color="secondary">
- The one no-op it reports is the Lightbox drag opt-out above:
- correct code with the shape of a defect. Every rule the lint
- gains has to carry its exemptions from the start, or the first
- thing it produces is work that ends in &ldquo;working as
- intended&rdquo;.
- </Text>
- </VStack>
- </Card>
- <Card padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">A grep sees less than a scanner</Text>
- <Text type="supporting" color="secondary">
- {SINGLE_PROPERTY_TRANSFORMS} of the{' '}
- {TRANSFORM_TRANSITIONS.length} transform transitions declare{' '}
- <code>transform</code> on its own.{' '}
- {MULTI_PROPERTY_TRANSFORMS.length} declare it inside a longer
- property list, where a search for{' '}
- <code>transitionProperty: &lsquo;transform&rsquo;</code> never
- finds them — which is how one repository yields three different
- counts depending on who counted.
- </Text>
- </VStack>
- </Card>
- </Grid>
- <Text color="secondary">
- The multi-property declarations are the interesting half: criterion 12
- findings like the rest, and {LAYOUT_MIXED_TRANSFORMS.length} of them
- criterion 6 findings as well, because they animate a layout property
- in the same breath as a compositor one.
- </Text>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Site</TableHeaderCell>
- <TableHeaderCell>Declaration</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {MULTI_PROPERTY_TRANSFORMS.map(site => (
- <TableRow key={`${site.file}:${site.line}`}>
- <TableCell>
- <Text
- {...stylex.props(
- sx.mono,
- )}>{`${site.file}:${site.line}`}</Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {site.decl}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- <HStack gap={2} wrap="wrap">
- <Badge
- variant="success"
- label={`Audit, fixed: ${AUDIT_COUNTS.transformTransitions} sites / ${AUDIT_COUNTS.transformTransitionComponents} components`}
- />
- <Badge variant="neutral" label="Brief: 20+ components" />
- </HStack>
- <Text type="supporting" color="secondary">
- This page found the discrepancy by grepping when the generated number
- looked too small, and the generator has since been fixed twice: once
- so a value that wraps onto its own line is still read, and once so a
- rule containing nested per-state objects is still scanned. Both bugs
- hid matches, and both made the brief look wrong when it was right. The
- lasting fix is a parser rather than a regex — a StyleX rule is a
- TypeScript object literal and can be read as one — but the habit
- matters more than the tool: when a generated count disagrees with
- someone who has read the code, check the generator first.
- </Text>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>What would have caught each of these</Heading>
- <Card padding={0}>
- <Table density="balanced">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Finding</TableHeaderCell>
- <TableHeaderCell>Lint rule</TableHeaderCell>
- <TableHeaderCell>Caseload today</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {LINT_MAP.map(row => (
- <TableRow key={row.finding}>
- <TableCell>
- <Text weight="semibold">{row.finding}</Text>
- </TableCell>
- <TableCell>
- <Text type="supporting">{row.rule}</Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {row.status}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- <Text type="supporting" color="secondary">
- Five of the six are mechanical. The sixth — a timer standing in for a
- transition — is the only one that needs a heuristic, and it is the
- only one of the six that describes a bug a user would notice.
- </Text>
- </VStack>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/exit-gap.tsx b/apps/sandbox/src/motion/pages/exit-gap.tsx
deleted file mode 100644
index efe252f864..0000000000
--- a/apps/sandbox/src/motion/pages/exit-gap.tsx
+++ /dev/null
@@ -1,329 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input LabDemos rigs, published guidance, the lab store
- * @output The exit-gap argument, with both documents on screen
- * @position /motion/exit-gap
- *
- * The brief calls this the single highest-leverage fix in the audit. It is
- * also the one place where the thing being called a defect is the published
- * guidance, so the page leads with that rather than burying it.
- */
-
-import * as stylex from '@stylexjs/stylex';
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Card} from '@astryxdesign/core/Card';
-import {CodeBlock} from '@astryxdesign/core/CodeBlock';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Link} from '@astryxdesign/core/Link';
-import {HStack, VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {LabPage} from '../PageFrame';
-import {ComparePanes, DemoBody, DemoCard, TokenSlider} from '../LabPrimitives';
-import {DialogRig, LayerRig, NativePopoverProbe} from '../LabDemos';
-import {GUIDANCE_CONFLICTS} from '../publishedGuidance';
-
-const sx = stylex.create({
- full: {width: '100%'},
- quote: {
- borderInlineStart: '2px solid var(--color-border)',
- paddingInlineStart: '12px',
- maxWidth: '62ch',
- },
-});
-
-/** The eleven, as the brief lists them, plus the dialog family. */
-const LAYER_CONSUMERS = [
- 'Tooltip',
- 'HoverCard',
- 'Popover',
- 'DropdownMenu',
- 'ContextMenu',
- 'Selector',
- 'ComplexSelector',
- 'PowerSearch',
- 'Typeahead',
- 'MoreMenu',
- 'Breadcrumbs overflow',
-];
-
-const RIGS = [
- {
- title: 'Tooltip',
- subtitle: 'useLayer · highest-frequency surface in the system',
- triggerLabel: 'Hover me',
- trigger: 'hover' as const,
- origin: 'top center',
- question:
- 'The published page names tooltips specifically as a surface that may vanish. Does the exit earn its 175ms here, on something seen hundreds of times a day?',
- },
- {
- title: 'HoverCard',
- subtitle: 'useLayer · the most visible instance of the gap',
- triggerLabel: 'Hover a name',
- trigger: 'hover' as const,
- origin: 'top left',
- question:
- 'A larger surface travelling the same distance. Judge the scale-from value here rather than on Tooltip — 0.96 reads differently at size.',
- },
- {
- title: 'Popover',
- subtitle: 'useLayer',
- triggerLabel: 'Click me',
- trigger: 'click' as const,
- origin: 'top left',
- question:
- 'Click twice quickly. The exit has to retarget rather than restart, or rapid dismissal looks broken.',
- },
- {
- title: 'DropdownMenu',
- subtitle: 'useLayer · submenus too',
- triggerLabel: 'Open menu',
- trigger: 'click' as const,
- origin: 'top left',
- question:
- 'A menu snapping shut is the case people notice. Does the exit help, or does it just delay the next click?',
- },
-];
-
-export default function ExitGapPage() {
- const conflict = GUIDANCE_CONFLICTS.find(c => c.id === 'exit-optional');
- const blocking = GUIDANCE_CONFLICTS.find(c => c.id === 'blocking');
-
- return (
- <LabPage
- title="The exit gap"
- intro="Eleven components animate in and vanish out — every surface built on useLayer, plus Dialog, AlertDialog and CommandPalette. One change to layerAnimations and useLayer would give all eleven a dismissal animation, which is why the brief calls it the highest-leverage fix in the audit."
- decides="Whether presence surfaces should animate out at all, and what enter and exit cost."
- badges={
- <Badge variant="warning" label="conflicts with the published page" />
- }>
- {conflict != null && (
- <Banner
- status="warning"
- title="This is not drift — it is the published guidance, correctly followed"
- description={
- <VStack gap={2}>
- <Text {...stylex.props(sx.quote)}>
- <em>&ldquo;{conflict.published}&rdquo;</em>
- </Text>
- <Text>
- {conflict.reading} Before any of this is scheduled, decide which
- document is right. If the proposal wins, the rewrite of that
- paragraph ships in the same stack as the{' '}
- <code>layerAnimations</code> change — otherwise the rubric
- starts failing components for doing exactly what the docs still
- instruct.
- </Text>
- </VStack>
- }
- endContent={<Link href="/motion/published">All conflicts</Link>}
- />
- )}
-
- <DemoCard
- title="Tune the presence budget"
- question="These two values drive every pane on this page, and every layer demo in the lab.">
- <DemoBody>
- <TokenSlider token="--duration-enter" label="enter" max={600} />
- <TokenSlider token="--duration-exit" label="exit" max={600} />
- <TokenSlider token="--duration-overlay" label="overlay" max={900} />
- <Text type="supporting" color="secondary">
- Exit is deliberately shorter than enter, because old content should
- leave faster than new content arrives. Drag them equal and a
- dismissal starts to feel sticky.
- </Text>
- </DemoBody>
- </DemoCard>
-
- {RIGS.map(rig => (
- <DemoCard
- key={rig.title}
- title={rig.title}
- question={rig.question}
- badges={<Badge label={rig.subtitle} />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — animates in, vanishes out',
- content: (
- <LayerRig
- mode="before"
- label={rig.title}
- triggerLabel={rig.triggerLabel}
- trigger={rig.trigger}
- origin={rig.origin}
- />
- ),
- },
- {
- tone: 'after',
- label: 'Proposed — the exit retraces the entry',
- content: (
- <LayerRig
- mode="after"
- label={rig.title}
- triggerLabel={rig.triggerLabel}
- trigger={rig.trigger}
- origin={rig.origin}
- />
- ),
- },
- ]}
- />
- </DemoCard>
- ))}
-
- <DemoCard
- title="Dialog, AlertDialog, CommandPalette"
- question="Two separate bugs in one surface: the panel has no exit, and the backdrop has no transition at all. Watch the focus ring on the trigger."
- badges={<Badge variant="error" label="focus races the exit" />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label:
- 'Today — no exit, scrim hard-cuts, focus returns immediately',
- content: <DialogRig mode="before" />,
- },
- {
- tone: 'after',
- label: 'Proposed — panel and scrim both exit, focus waits',
- content: <DialogRig mode="after" />,
- },
- ]}
- />
- <DemoBody>
- <Text type="supporting" color="secondary">
- In the left pane the focus ring lights the instant the dialog
- closes, while the dialog is still on screen. With a real exit
- animation that means focus moves — and the page may scroll —
- mid-animation. The brief lists this as a risk; here it is a thing
- you can watch, and it has to be settled before the Dialog work
- starts rather than after.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="The technique, running natively in this browser"
- question="Is the platform enough, or does the shared primitive need a JS fallback? This card answers it for real — nothing here is simulated.">
- <DemoBody>
- <NativePopoverProbe />
- </DemoBody>
- </DemoCard>
-
- <VStack gap={3}>
- <Heading level={2}>What one change buys</Heading>
- <Card padding={4}>
- <VStack gap={2}>
- <Text>
- Every component below is a <code>useLayer</code> consumer, so all
- of them inherit a dismissal animation from a single definition.
- That is the leverage — and it is also the risk, because it is one
- change to the code path that owns dismissal.
- </Text>
- <HStack gap={1} wrap="wrap">
- {LAYER_CONSUMERS.map(name => (
- <Badge key={name} label={name} />
- ))}
- </HStack>
- </VStack>
- </Card>
- <CodeBlock
- language="css"
- title="layerAnimations — one definition, eleven consumers"
- hasCopyButton
- code={`.layer {
- opacity: 0;
- transform: scale(0.96) translateY(-4px);
- transform-origin: var(--layer-origin);
- transition:
- opacity var(--duration-exit) var(--ease-exit),
- transform var(--duration-exit) var(--ease-exit),
- display var(--duration-exit) allow-discrete,
- overlay var(--duration-exit) allow-discrete;
-}
-
-.layer:popover-open {
- opacity: 1;
- transform: scale(1) translateY(0);
- transition:
- opacity var(--duration-enter) var(--ease-entry),
- transform var(--duration-enter) var(--ease-entry),
- display var(--duration-enter) allow-discrete,
- overlay var(--duration-enter) allow-discrete;
-}
-
-@starting-style {
- .layer:popover-open { opacity: 0; transform: scale(0.96) translateY(-4px); }
-}`}
- />
- <CodeBlock
- language="tsx"
- title="useLayer — await the exit instead of hiding synchronously"
- hasCopyButton
- code={`- setOpen(false); // element gone this frame
-+ setClosing(true); // stops accepting input immediately
-+ await Promise.all(
-+ el.getAnimations().map(a => a.finished),
-+ );
-+ setOpen(false); // focus return happens here`}
- />
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>What this work has to be careful about</Heading>
- <Grid columns={{minWidth: 300}} gap={3}>
- <Card padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">Dismissal is load-bearing</Text>
- <Text type="supporting" color="secondary">
- Layer dismissal has its own invariants test for good reason.
- Keeping an element alive through its exit doubles the state
- matrix for focus return, outside-press and escape handling — and
- every one of those has to be tested against an element that is
- visible but already closing.
- </Text>
- </VStack>
- </Card>
- {blocking != null && (
- <Card padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">
- The published page already warns about this
- </Text>
- <Text type="supporting" color="secondary">
- &ldquo;{blocking.published}&rdquo; The answer has to be that
- the surface stops accepting input the moment dismissal starts,
- not when the animation ends. Write that into the
- primitive&rsquo;s contract rather than leaving it to each
- consumer.
- </Text>
- </VStack>
- </Card>
- )}
- <Card padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">
- Motion is already fighting the automated gates
- </Text>
- <Text type="supporting" color="secondary">
- Two fixes landed this month to stop animation interfering with
- the accessibility audit and the visual-regression capture. More
- motion means more of this, and there is no documented policy for
- it. The lab&rsquo;s reduced-motion switch doubles as the freeze
- mode a capture needs.
- </Text>
- </VStack>
- </Card>
- </Grid>
- </VStack>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/export.tsx b/apps/sandbox/src/motion/pages/export.tsx
deleted file mode 100644
index 230d399268..0000000000
--- a/apps/sandbox/src/motion/pages/export.tsx
+++ /dev/null
@@ -1,526 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input Everything the lab has been tuned to this session
- * @output The two artefacts the foundation milestone ships, plus the lint rule
- * @position /motion/export
- *
- * The only page that decides nothing. It emits: the token block in the shape
- * the proposal actually lands in — an addition to two objects core already
- * defines through StyleX, not a `:root` block, because `:root` is not how this
- * codebase defines tokens — the JS mirror, and the lint entries that would
- * keep both honest.
- */
-
-import * as stylex from '@stylexjs/stylex';
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Card} from '@astryxdesign/core/Card';
-import {CodeBlock} from '@astryxdesign/core/CodeBlock';
-import {EmptyState} from '@astryxdesign/core/EmptyState';
-import {Link} from '@astryxdesign/core/Link';
-import {VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import {LabPage} from '../PageFrame';
-import {parseMs, useMotionLab} from '../MotionLabStore';
-import {
- ALL_TUNABLE_TOKENS,
- CURRENT_EASE,
- DEFAULT_TOKEN_VALUES,
- PRIMITIVE_DURATIONS,
- SEMANTIC_DURATIONS,
- SEMANTIC_EASES,
- SPRINGS,
- STAGGERS,
-} from '../motionTokens';
-import {isNamedCurve, parseBezier} from '../spring';
-import {AUDIT_COUNTS, LITERAL_VALUES} from '../__generated__/motionAudit';
-
-const sx = stylex.create({
- mono: {fontFamily: 'var(--font-family-code)'},
- prose: {maxWidth: '72ch'},
-});
-
-const PRIMITIVE_MS = new Map(PRIMITIVE_DURATIONS);
-
-/** The brief's budget for the sweep, against the measured total. */
-const BRIEF_HARDCODED_BUDGET = 28;
-
-type CodeLine = {readonly text: string; readonly added?: boolean};
-
-function render(lines: ReadonlyArray<CodeLine>): {
- code: string;
- highlightLines: number[];
-} {
- return {
- code: lines.map(line => line.text).join('\n'),
- highlightLines: lines
- .map((line, i) => (line.added === true ? i + 1 : 0))
- .filter(n => n > 0),
- };
-}
-
-/**
- * The token block. Semantic durations emit as `var(--primitive)` — the pattern
- * `typeScaleDefaults` already uses for type — so a theme retunes both layers at
- * once. A value tuned away from its primitive cannot alias, and says so.
- */
-function tokenBlockLines(
- rawToken: (token: string) => string,
-): ReadonlyArray<CodeLine> {
- const durationLines = SEMANTIC_DURATIONS.map(duration => {
- const ms = parseMs(rawToken(duration.name));
- const primitiveMs =
- duration.primitive != null
- ? PRIMITIVE_MS.get(duration.primitive)
- : undefined;
- if (primitiveMs != null && primitiveMs === ms) {
- return {
- text: ` '${duration.name}': 'var(${duration.primitive})',`,
- added: true,
- };
- }
- const drift =
- primitiveMs != null
- ? ` // tuned off ${duration.primitive} (${primitiveMs}ms) — move the primitive or accept the fork`
- : ' // no primitive: the reduced-motion escape';
- return {text: ` '${duration.name}': '${ms}ms',${drift}`, added: true};
- });
-
- return [
- {text: '// @astryxdesign/core/src/theme/tokens.stylex.ts'},
- {
- text: '// Additions only. The nine primitives and --ease-standard do not move.',
- },
- {text: ''},
- {text: 'export const easeDefaults = {'},
- {
- text: ` '${CURRENT_EASE.name}': '${CURRENT_EASE.value}', // kept; deprecated in docs, not in code`,
- },
- ...SEMANTIC_EASES.map(ease => ({
- text: ` '${ease.name}': '${rawToken(ease.name)}',`,
- added: true,
- })),
- {text: '} as const;'},
- {text: ''},
- {text: 'export const easeVars = stylex.defineVars(easeDefaults);'},
- {text: ''},
- {text: 'export const durationDefaults = {'},
- ...PRIMITIVE_DURATIONS.map(([name, ms]) => ({
- text: ` '${name}': '${ms}ms',`,
- })),
- {text: ''},
- {
- text: ' // Semantic layer. Aliased, so the motion scale a theme sets still owns',
- },
- {text: ' // these — the same shape typeScaleDefaults uses for type.'},
- ...durationLines,
- {text: '} as const;'},
- {text: ''},
- {text: 'export const durationVars = stylex.defineVars(durationDefaults);'},
- {text: ''},
- {
- text: '// Stagger is a delay between siblings, not a duration, so it gets its own',
- },
- {text: '// group rather than widening DurationVarName.'},
- {text: 'export const staggerDefaults = {', added: true},
- ...STAGGERS.map(([name]) => ({
- text: ` '${name}': '${parseMs(rawToken(name))}ms',`,
- added: true,
- })),
- {text: '} as const;', added: true},
- {text: '', added: true},
- {
- text: 'export const staggerVars = stylex.defineVars(staggerDefaults);',
- added: true,
- },
- ];
-}
-
-/** Seconds and numbers — the shape Motion, WAAPI and canvas take. */
-function emitMirror(
- rawToken: (token: string) => string,
- springs: Readonly<Record<string, {duration: number; bounce: number}>>,
-): string {
- const short = (name: string) =>
- name.replace(/^--(duration|ease|stagger)-/, '');
- const seconds = (name: string) =>
- Number((parseMs(rawToken(name)) / 1000).toFixed(3));
- const curve = (name: string) => {
- const value = rawToken(name);
- return isNamedCurve(value)
- ? JSON.stringify(value)
- : `[${parseBezier(value).join(', ')}]`;
- };
-
- return `// @generated from the Astryx theme by scripts/generate-motion-mirror.mjs.
-// Values are resolved through resolveThemeTokens, so a theme that retunes the
-// motion scale retunes this file too.
-
-export const duration = {
-${SEMANTIC_DURATIONS.map(d => ` ${short(d.name)}: ${seconds(d.name)},`).join('\n')}
-} as const;
-
-export const ease = {
-${SEMANTIC_EASES.map(e => ` ${short(e.name)}: ${curve(e.name)},`).join('\n')}
-} as const;
-
-export const stagger = {
-${STAGGERS.map(([name]) => ` ${short(name)}: ${seconds(name)},`).join('\n')}
-} as const;
-
-/** No CSS form, so authored here rather than mirrored. */
-export const spring = {
-${SPRINGS.map(
- s =>
- ` ${s.name}: {duration: ${springs[s.name].duration}, bounce: ${springs[s.name].bounce}},`,
-).join('\n')}
-} as const;`;
-}
-
-const LINT_CODE = `// internal/eslint-plugin-xds/index.js — rule: xds/no-hardcoded-styles
-//
-// STYLE_PROPERTIES already covers type, spacing, radius and colour. It has no
-// motion entry, which is why ${AUDIT_COUNTS.hardcodedTotal} hardcoded duration and easing values
-// pass lint today. Six additions, in the shape the map already uses:
-
-const STYLE_PROPERTIES = {
- // ...fontSize, padding, borderRadius, color — unchanged
-
- transitionDuration: {
- pattern: /^['"]?[\\d.]+m?s['"]?$/,
- tokenVar: 'durationVars',
- message: 'Use a duration token: var(--duration-*)',
- examples: ["durationVars['--duration-enter']"],
- },
- animationDuration: {
- pattern: /^['"]?[\\d.]+m?s['"]?$/,
- tokenVar: 'durationVars',
- message: 'Use a duration token: var(--duration-*)',
- examples: ["durationVars['--duration-continuous']"],
- },
- transitionDelay: {
- pattern: /^['"]?[\\d.]+m?s['"]?$/,
- tokenVar: 'staggerVars',
- message: 'Use var(--stagger-*) for a group offset, var(--duration-*) otherwise',
- examples: ["staggerVars['--stagger-base']"],
- },
- animationDelay: {
- pattern: /^['"]?[\\d.]+m?s['"]?$/,
- tokenVar: 'staggerVars',
- message: 'Use var(--stagger-*) for a group offset, var(--duration-*) otherwise',
- examples: ["staggerVars['--stagger-tight']"],
- },
- transitionTimingFunction: {
- pattern: /^['"]?(cubic-bezier\\([^)]*\\)|linear|ease(-in|-out|-in-out)?|steps\\([^)]*\\))['"]?$/,
- tokenVar: 'easeVars',
- message: 'Use an easing token: var(--ease-*)',
- examples: ["easeVars['--ease-entry']", "easeVars['--ease-exit']"],
- },
- animationTimingFunction: {
- pattern: /^['"]?(cubic-bezier\\([^)]*\\)|linear|ease(-in|-out|-in-out)?|steps\\([^)]*\\))['"]?$/,
- tokenVar: 'easeVars',
- message: 'Use an easing token: var(--ease-*)',
- examples: ["easeVars['--ease-linear']"],
- },
-};
-
-// One carve-out is needed. SKIP_VALUES lets '0', 'none' and 'auto' through for
-// every property, which is right for padding and wrong for motion: it is what
-// hides transitionProperty: 'none'. The structural rules below need to see it.`;
-
-const STRUCTURAL_CODE = `// A second visitor, because these are properties of the style object rather
-// than of one value — the existing rule only ever looks at a single literal.
-
-'motion/require-duration-with-property': {
- // transitionProperty with no duration in the same object inherits 0s and
- // animates nothing. Catches: ${AUDIT_COUNTS.noopTransitions} today.
-},
-'motion/require-curve-with-duration': {
- // A duration with no timing function silently gets the CSS default (ease),
- // which is a decision nobody made. Catches: ${AUDIT_COUNTS.durationWithoutCurve} today.
-},
-'motion/no-transition-all': {
- // transitionProperty: 'all' animates layout and paint properties nobody
- // intended. Catches: ${AUDIT_COUNTS.transitionAll} today — a ratchet, not a cleanup.
-},`;
-
-const LINT_RULES: ReadonlyArray<{
- readonly rule: string;
- readonly allows: string;
- readonly catches: string;
- readonly kind: string;
-}> = [
- {
- rule: 'transitionDuration / animationDuration',
- allows: 'var(--duration-*)',
- catches: `${AUDIT_COUNTS.hardcodedDuration} hardcoded durations`,
- kind: 'value',
- },
- {
- rule: 'transitionDelay / animationDelay',
- allows: 'var(--stagger-*), var(--duration-*)',
- catches: 'included in the count above',
- kind: 'value',
- },
- {
- rule: 'transitionTimingFunction / animationTimingFunction',
- allows: 'var(--ease-*)',
- catches: `${AUDIT_COUNTS.hardcodedEasing} hardcoded curves`,
- kind: 'value',
- },
- {
- rule: 'motion/require-duration-with-property',
- allows: 'a duration beside every transitionProperty',
- catches: `${AUDIT_COUNTS.noopTransitions} no-op transition`,
- kind: 'structural',
- },
- {
- rule: 'motion/require-curve-with-duration',
- allows: 'a curve beside every duration',
- catches: `${AUDIT_COUNTS.durationWithoutCurve} durations with no declared curve`,
- kind: 'structural',
- },
- {
- rule: 'motion/no-transition-all',
- allows: 'named properties only',
- catches: `${AUDIT_COUNTS.transitionAll} today — prevents regressions`,
- kind: 'structural',
- },
-];
-
-export default function MotionExportPage() {
- const {rawToken, springs, dirtyTokens} = useMotionLab();
- const {code: tokenCode, highlightLines} = render(tokenBlockLines(rawToken));
-
- const tokenDiff = ALL_TUNABLE_TOKENS.filter(
- name => rawToken(name) !== DEFAULT_TOKEN_VALUES[name],
- ).map(name => ({
- name,
- proposed: DEFAULT_TOKEN_VALUES[name],
- tuned: rawToken(name),
- }));
-
- const springDiff = SPRINGS.flatMap(spec => {
- const tuned = springs[spec.name];
- const rows: Array<{name: string; proposed: string; tuned: string}> = [];
- if (tuned.duration !== spec.duration) {
- rows.push({
- name: `spring.${spec.name}.duration`,
- proposed: `${spec.duration}s`,
- tuned: `${tuned.duration}s`,
- });
- }
- if (tuned.bounce !== spec.bounce) {
- rows.push({
- name: `spring.${spec.name}.bounce`,
- proposed: String(spec.bounce),
- tuned: String(tuned.bounce),
- });
- }
- return rows;
- });
-
- const changes = [...tokenDiff, ...springDiff];
- const instantCount =
- LITERAL_VALUES.find(([value]) => value === '0.01s')?.[1] ?? 0;
-
- return (
- <LabPage
- title="Export tuning"
- intro="Everything tuned in this session, as the two artefacts the foundation milestone ships: the token block and the JS mirror. Plus the lint entries that stop the next one from arriving."
- decides="Nothing — it emits whatever the rest of the lab has been tuned to."
- badges={
- <Badge
- variant={changes.length > 0 ? 'warning' : 'neutral'}
- label={
- changes.length > 0
- ? `${changes.length} changed`
- : 'proposal defaults'
- }
- />
- }>
- <VStack gap={3}>
- <Heading level={2}>What moved</Heading>
- {changes.length === 0 ? (
- <Card padding={4}>
- <EmptyState
- title="Nothing has been tuned this session"
- description="Every value below is the proposal exactly as authored. Change a curve on the tokens page or a spring on the springs page and the differences appear here."
- />
- </Card>
- ) : (
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Token</TableHeaderCell>
- <TableHeaderCell>Proposal</TableHeaderCell>
- <TableHeaderCell>Tuned</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {changes.map(row => (
- <TableRow key={row.name}>
- <TableCell>
- <Text {...stylex.props(sx.mono)}>{row.name}</Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {row.proposed}
- </Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} weight="semibold">
- {row.tuned}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- )}
- {dirtyTokens.length > 0 && (
- <Text type="supporting" color="secondary">
- The rail counts {dirtyTokens.length} tuned token(s); springs are
- counted separately because they are not custom properties.
- </Text>
- )}
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>The token block</Heading>
- <Text color="secondary" {...stylex.props(sx.prose)}>
- Highlighted lines are the addition. Core defines tokens through{' '}
- <code>stylex.defineVars</code>, so this is a diff against two existing
- objects rather than a <code>:root</code> block — <code>:root</code>{' '}
- would bypass the theme system entirely and could not be retuned by a
- theme. Semantic durations emit as <code>var(--primitive)</code>, which
- is the shape <code>typeScaleDefaults</code> already uses for type, so
- a theme that moves the motion scale moves these with it.
- </Text>
- <CodeBlock
- language="ts"
- title="@astryxdesign/core/src/theme/tokens.stylex.ts"
- hasCopyButton
- hasLineNumbers
- highlightLines={highlightLines}
- code={tokenCode}
- />
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>The JS mirror</Heading>
- <Text color="secondary" {...stylex.props(sx.prose)}>
- Same values, in the shape a JS animation takes. Generated from the
- theme in the same build step that emits the CSS — see{' '}
- <Link href="/motion/js-mirror">JS token mirror</Link> for why it
- cannot be a handwritten constants file.
- </Text>
- <CodeBlock
- language="ts"
- title="@astryxdesign/core/motion — generated"
- hasCopyButton
- code={emitMirror(rawToken, springs)}
- />
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>The lint rule</Heading>
- <Text color="secondary" {...stylex.props(sx.prose)}>
- The token linter already polices type, spacing, radius and colour, and
- simply has no entry for duration or easing. That is the whole reason{' '}
- {AUDIT_COUNTS.hardcodedTotal} values are hardcoded: nothing ever told
- anyone not to. Six property entries drop straight into the existing
- pattern map — three rules once the duration, delay and timing-function
- pairs are grouped. The other three are structural: they are properties
- of the whole style object, and the current rule only ever looks at one
- literal at a time.
- </Text>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Rule</TableHeaderCell>
- <TableHeaderCell>Allows</TableHeaderCell>
- <TableHeaderCell>Measured catch</TableHeaderCell>
- <TableHeaderCell>Kind</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {LINT_RULES.map(rule => (
- <TableRow key={rule.rule}>
- <TableCell>
- <Text {...stylex.props(sx.mono)}>{rule.rule}</Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {rule.allows}
- </Text>
- </TableCell>
- <TableCell>
- <Text>{rule.catches}</Text>
- </TableCell>
- <TableCell>
- <Badge
- variant={rule.kind === 'structural' ? 'info' : 'neutral'}
- label={rule.kind}
- />
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- <CodeBlock
- language="js"
- title="internal/eslint-plugin-xds/index.js — value entries"
- hasCopyButton
- isWrapped
- code={LINT_CODE}
- />
- <CodeBlock
- language="js"
- title="The structural companions"
- hasCopyButton
- code={STRUCTURAL_CODE}
- />
- </VStack>
-
- <Banner
- status="warning"
- title={`The sweep is ${AUDIT_COUNTS.hardcodedTotal} sites, not ${BRIEF_HARDCODED_BUDGET}`}
- description={
- <Text>
- The brief budgets {BRIEF_HARDCODED_BUDGET} hardcoded values; the
- audit measures {AUDIT_COUNTS.hardcodedTotal} (
- {AUDIT_COUNTS.hardcodedDuration} durations,{' '}
- {AUDIT_COUNTS.hardcodedEasing} curves). Roughly a quarter of them —{' '}
- {instantCount} of {AUDIT_COUNTS.hardcodedTotal},{' '}
- {Math.round((instantCount / AUDIT_COUNTS.hardcodedTotal) * 100)}% —
- are the <code>0.01s</code> reduced-motion idiom in BottomSheet,
- DateInput and MobileNav, and those cannot be swept until{' '}
- <code>--duration-instant</code> is settled at 0 or 0.01ms: a zero
- duration fires no <code>transitionend</code>, and code sequences off
- that event. Turning the rule on before that decision lands means{' '}
- {instantCount} suppressions in the first diff. See{' '}
- <Link href="/motion/reduced-motion">Reduced motion</Link> and{' '}
- <Link href="/motion/violations">Hardcoded values</Link>.
- </Text>
- }
- />
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/js-mirror.tsx b/apps/sandbox/src/motion/pages/js-mirror.tsx
deleted file mode 100644
index 6a0345bf12..0000000000
--- a/apps/sandbox/src/motion/pages/js-mirror.tsx
+++ /dev/null
@@ -1,545 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input The generated audit, the lab store, the token data
- * @output The case for a JS mirror, and the module it would emit
- * @position /motion/js-mirror
- *
- * A CSS custom property is readable by exactly one consumer: CSS. Every
- * animation library, the Web Animations API, and anything drawing to a canvas
- * takes numbers. Motion wants seconds as a number and easing as four numbers;
- * it cannot resolve `var(--duration-fast)`. The mirror exists so that the
- * value in the stylesheet and the value in the chart are the same value.
- *
- * The chart demo draws to a real canvas rather than faking one with divs,
- * because the whole argument is that canvas sits outside the token system.
- */
-
-import {useCallback, useEffect, useRef} from 'react';
-import * as stylex from '@stylexjs/stylex';
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Card} from '@astryxdesign/core/Card';
-import {CodeBlock} from '@astryxdesign/core/CodeBlock';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Link} from '@astryxdesign/core/Link';
-import {VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import {LabPage} from '../PageFrame';
-import {ComparePanes, DemoBody, DemoCard, useLoop} from '../LabPrimitives';
-import {parseMs, useMotionLab} from '../MotionLabStore';
-import {
- SEMANTIC_DURATIONS,
- SEMANTIC_EASES,
- SPRINGS,
- STAGGERS,
-} from '../motionTokens';
-import {bezierAt, isNamedCurve, parseBezier} from '../spring';
-import {AUDIT_COUNTS, TIMEOUT_LITERALS} from '../__generated__/motionAudit';
-
-const sx = stylex.create({
- full: {width: '100%'},
- prose: {maxWidth: '72ch'},
- mono: {fontFamily: 'var(--font-family-code)'},
- canvas: {
- display: 'block',
- width: '100%',
- height: '132px',
- // Canvas has no access to a custom property, so the demo parks the one
- // colour it needs on the element and reads it back with getComputedStyle.
- color: 'var(--color-brand)',
- },
-});
-
-const CHART_HEIGHT = 132;
-
-/** Fixed data, so both panes cycle the same values and the eye can compare. */
-const DATASETS: ReadonlyArray<ReadonlyArray<number>> = [
- [0.42, 0.66, 0.28, 0.81, 0.55, 0.35, 0.72],
- [0.68, 0.31, 0.74, 0.44, 0.86, 0.52, 0.29],
- [0.24, 0.58, 0.9, 0.36, 0.61, 0.79, 0.47],
-];
-
-/** `--duration-*` in seconds, `--ease-*` as points, the shape a library takes. */
-function emitMirror(
- rawToken: (token: string) => string,
- springs: Readonly<Record<string, {duration: number; bounce: number}>>,
-): string {
- const short = (name: string) =>
- name.replace(/^--(duration|ease|stagger)-/, '');
- const seconds = (name: string) =>
- Number((parseMs(rawToken(name)) / 1000).toFixed(3));
- const curve = (name: string) => {
- const value = rawToken(name);
- return isNamedCurve(value)
- ? JSON.stringify(value)
- : `[${parseBezier(value).join(', ')}]`;
- };
-
- return `// @generated from the Astryx theme by scripts/generate-motion-mirror.mjs.
-// Seconds and numbers, because that is what animation libraries, the Web
-// Animations API and canvas take. Regenerate when the theme changes.
-
-/** Seconds. Motion, WAAPI and canvas all want a number here. */
-export const duration = {
-${SEMANTIC_DURATIONS.map(d => ` ${short(d.name)}: ${seconds(d.name)},`).join('\n')}
-} as const;
-
-/** Four control points, or the CSS keyword when the curve is a keyword. */
-export const ease = {
-${SEMANTIC_EASES.map(e => ` ${short(e.name)}: ${curve(e.name)},`).join('\n')}
-} as const;
-
-/** Seconds between items in a group entrance. */
-export const stagger = {
-${STAGGERS.map(([name]) => ` ${short(name)}: ${seconds(name)},`).join('\n')}
-} as const;
-
-/** No CSS form at all, so these are defined here rather than mirrored. */
-export const spring = {
-${SPRINGS.map(
- s =>
- ` ${s.name}: {duration: ${springs[s.name].duration}, bounce: ${springs[s.name].bounce}},`,
-).join('\n')}
-} as const;`;
-}
-
-const BEFORE_CODE = `// MobileNav/MobileNav.tsx:294-311
-function resolveCloseDelay(dialog: HTMLDialogElement): number {
- const cap = window.matchMedia('(prefers-reduced-motion: reduce)').matches
- ? 0
- : MAX_CLOSE_DELAY_MS;
-
- const hold = parseShortestDurationMs(
- window.getComputedStyle(dialog).transitionDuration,
- );
-
- // The hold is unreadable — an unresolved var()
- // outside a real browser.
- if (hold === null) {
- return cap;
- }
-
- return hold <= 0 ? 0 : Math.min(cap, hold * CLOSE_WITHIN_HOLD);
-}
-
-// plus parseShortestDurationMs at :265 — 25 lines
-// that exist only to turn "0.41s, 0.12s" back into
-// a number, exported so it can be unit tested.`;
-
-const AFTER_CODE = `import {duration} from '@astryxdesign/core/motion';
-
-function resolveCloseDelay(prefersReducedMotion: boolean): number {
- const cap = prefersReducedMotion ? 0 : MAX_CLOSE_DELAY_MS;
- // The same value the stylesheet uses, theme-resolved,
- // and readable in jsdom.
- const hold = duration.overlay * 1000;
- return Math.min(cap, hold * CLOSE_WITHIN_HOLD);
-}`;
-
-const STYLEX_GAP_CODE = `import {durationVars, easeVars} from '@astryxdesign/core/theme/tokens.stylex';
-
-durationVars['--duration-medium']; // "var(--x1kg2b7)" — a reference
-easeVars['--ease-standard']; // "var(--x9f0d3a)" — same
-
-// Correct in StyleX:
-stylex.create({panel: {transitionDuration: durationVars['--duration-medium']}});
-
-// Useless anywhere else:
-animate(el, {opacity: 1}, {duration: durationVars['--duration-medium']}); // NaN
-ctx.globalAlpha = progress(durationVars['--duration-medium']); // NaN`;
-
-/**
- * A bar chart redrawn on a loop. Before replaces the data outright, which is
- * what every chart in the system does today; after interpolates it with the
- * same token the CSS uses, reached through the mirror.
- */
-function ChartPane({mode}: {mode: 'before' | 'after'}) {
- const {rawToken, reducedMotion, scaledMs} = useMotionLab();
- const canvasRef = useRef<HTMLCanvasElement | null>(null);
- const currentRef = useRef<ReadonlyArray<number>>(DATASETS[0]);
- const stepRef = useRef(1);
- const frameRef = useRef(0);
-
- const draw = useCallback((values: ReadonlyArray<number>) => {
- const canvas = canvasRef.current;
- if (canvas == null) {
- return;
- }
- const ratio = window.devicePixelRatio || 1;
- const width = canvas.clientWidth || 280;
- const pixelWidth = Math.round(width * ratio);
- const pixelHeight = Math.round(CHART_HEIGHT * ratio);
- if (canvas.width !== pixelWidth || canvas.height !== pixelHeight) {
- canvas.width = pixelWidth;
- canvas.height = pixelHeight;
- }
- const ctx = canvas.getContext('2d');
- if (ctx == null) {
- return;
- }
- ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
- ctx.clearRect(0, 0, width, CHART_HEIGHT);
- ctx.fillStyle = window.getComputedStyle(canvas).color;
- const gap = 8;
- const barWidth = (width - gap * (values.length - 1)) / values.length;
- values.forEach((value, i) => {
- const height = Math.max(2, value * (CHART_HEIGHT - 6));
- ctx.fillRect(
- i * (barWidth + gap),
- CHART_HEIGHT - height,
- barWidth,
- height,
- );
- });
- }, []);
-
- const advance = useCallback(() => {
- const next = DATASETS[stepRef.current % DATASETS.length];
- stepRef.current += 1;
- const from = currentRef.current;
-
- // Under either reduced-motion policy the after pane collapses into the
- // before pane, which is what reduced motion costs a chart: the data still
- // changes, the eye just has to find it again.
- if (mode === 'before' || reducedMotion !== 'off') {
- currentRef.current = next;
- draw(next);
- return;
- }
-
- const ms = Math.max(1, scaledMs('--duration-reveal'));
- const curve = parseBezier(rawToken('--ease-move'));
- const startedAt = performance.now();
- window.cancelAnimationFrame(frameRef.current);
- const step = (now: number) => {
- const k = Math.min(1, (now - startedAt) / ms);
- const eased = bezierAt(curve, k);
- draw(next.map((target, i) => from[i] + (target - from[i]) * eased));
- if (k < 1) {
- frameRef.current = window.requestAnimationFrame(step);
- } else {
- currentRef.current = next;
- }
- };
- frameRef.current = window.requestAnimationFrame(step);
- }, [draw, mode, rawToken, reducedMotion, scaledMs]);
-
- useLoop(advance, scaledMs('--duration-reveal') + 1300);
-
- useEffect(() => () => window.cancelAnimationFrame(frameRef.current), []);
-
- return (
- <canvas
- ref={canvasRef}
- role="img"
- aria-label={
- mode === 'before'
- ? 'Bar chart whose values change instantly'
- : 'Bar chart whose values interpolate over the reveal duration'
- }
- {...stylex.props(sx.canvas)}
- />
- );
-}
-
-export default function MotionJsMirrorPage() {
- const {rawToken, springs, scaledMs} = useMotionLab();
- const typeahead = TIMEOUT_LITERALS[0];
-
- return (
- <LabPage
- title="JS token mirror"
- intro="CSS custom properties are unreadable to every animation library, to the Web Animations API, and to canvas and chart code. Motion takes seconds as a number and easing as a four-number array; it cannot resolve var(--duration-fast). The mirror emits the same values the stylesheets use, in the shape those consumers already expect."
- decides="What the mirror has to expose for charts, canvas and motion libraries."
- badges={<Badge variant="info" label="emitted live from this session" />}>
- <DemoCard
- title="The read that should not have to exist"
- question={`${AUDIT_COUNTS.getComputedStyleReads} getComputedStyle reads across core. Two of them read motion values back out of CSS because there is no other way to get them.`}
- badges={
- <Badge variant="warning" label="MobileNav/MobileNav.tsx:303" />
- }>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — parse the number back out of the stylesheet',
- content: (
- <CodeBlock
- language="ts"
- code={BEFORE_CODE}
- maxHeight={340}
- isWrapped
- hasCopyButton={false}
- />
- ),
- },
- {
- tone: 'after',
- label: 'With the mirror',
- content: (
- <CodeBlock
- language="ts"
- code={AFTER_CODE}
- maxHeight={340}
- isWrapped
- hasCopyButton={false}
- />
- ),
- },
- ]}
- />
- <DemoBody>
- <Text color="secondary" {...stylex.props(sx.prose)}>
- MobileNav is doing the right thing for the right reason. Its own
- comment says so: the hold is <code>--duration-medium</code>,{' '}
- <q>
- which themes rewrite — the shipped y2k theme sets it to exactly
- 250ms — so read the hold in effect rather than assuming it
- </q>
- . Getting that value costs a computed-style read, a 25-line time
- parser exported for its own unit test (
- <code>MobileNav/MobileNav.tsx:265</code>), and a null branch for the
- case where the read comes back as an unresolved <code>var()</code>{' '}
- outside a real browser. That is exactly right, and exactly what
- nobody should have to write by hand.
- </Text>
- <Text color="secondary" {...stylex.props(sx.prose)}>
- The opposite failure — a hardcoded unmount timer drifting away from
- the transition it is supposed to outlast — is the one the brief
- warns about, and the audit does not find it.{' '}
- <code>TIMEOUT_LITERALS</code> holds exactly{' '}
- {TIMEOUT_LITERALS.length} entry:{' '}
- <code>
- {typeahead.file}:{typeahead.line}
- </code>{' '}
- ({typeahead.ms}ms), and it is a typeahead buffer reset, not motion
- at all. So core is currently on the safe side of that trade and
- paying for it in ceremony. The mirror does not fix a bug here; it
- removes the ceremony, and it makes the same number available to code
- that has no stylesheet to read.
- </Text>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Read</TableHeaderCell>
- <TableHeaderCell>What it wants</TableHeaderCell>
- <TableHeaderCell>Mirror replaces it?</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- <TableRow>
- <TableCell>
- <Text {...stylex.props(sx.mono)}>
- MobileNav/MobileNav.tsx:303
- </Text>
- </TableCell>
- <TableCell>
- <Text color="secondary">
- <code>transitionDuration</code>, to time the dialog close
- inside the hold
- </Text>
- </TableCell>
- <TableCell>
- <Badge variant="success" label="yes" />
- </TableCell>
- </TableRow>
- <TableRow>
- <TableCell>
- <Text {...stylex.props(sx.mono)}>
- BottomSheet/BottomSheetPanel.tsx:326
- </Text>
- </TableCell>
- <TableCell>
- <Text color="secondary">
- <code>transitionProperty</code>,{' '}
- <code>transitionDuration</code> and{' '}
- <code>transitionDelay</code>, to know whether a{' '}
- <code>transitionend</code> will arrive
- </Text>
- </TableCell>
- <TableCell>
- <Badge variant="warning" label="partly" />
- </TableCell>
- </TableRow>
- <TableRow>
- <TableCell>
- <Text {...stylex.props(sx.mono)}>
- the other {AUDIT_COUNTS.getComputedStyleReads - 2}
- </Text>
- </TableCell>
- <TableCell>
- <Text color="secondary">
- direction, writing mode, padding, border radius, scroll
- margin — layout, not motion
- </Text>
- </TableCell>
- <TableCell>
- <Badge label="not its job" />
- </TableCell>
- </TableRow>
- </TableBody>
- </Table>
- </Card>
- <Text type="supporting" color="secondary">
- Worth saying plainly: {AUDIT_COUNTS.getComputedStyleReads} is the
- whole computed-style caseload, not the motion one. The motion
- argument rests on two sites and on everything that cannot read a
- stylesheet at all — which is the next card.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="Charts are outside the token system entirely"
- question="Canvas cannot resolve a custom property. Chart, Radial, Sankey and Schedule therefore animate on whatever numbers their author typed, or they do not animate."
- badges={<Badge variant="neutral" label="live, on a loop" />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — data replaces itself',
- content: (
- <VStack gap={2} {...stylex.props(sx.full)}>
- <ChartPane mode="before" />
- <Text type="supporting" color="secondary">
- No token is reachable from here, so the honest default is no
- animation at all. The chart jumps and the eye loses which
- bar was which.
- </Text>
- </VStack>
- ),
- },
- {
- tone: 'after',
- label: 'With the mirror — interpolated on the reveal token',
- content: (
- <VStack gap={2} {...stylex.props(sx.full)}>
- <ChartPane mode="after" />
- <Text type="supporting" color="secondary">
- <code>scaledMs(&apos;--duration-reveal&apos;)</code> and{' '}
- <code>
- bezierAt(parseBezier(rawToken(&apos;--ease-move&apos;)),
- k)
- </code>{' '}
- — the same duration and the same curve the CSS uses, applied
- per frame.
- </Text>
- </VStack>
- ),
- },
- ]}
- />
- <DemoBody>
- <Text type="supporting" color="secondary">
- Currently {Math.round(scaledMs('--duration-reveal'))}ms at the
- rail&rsquo;s speed, on <code>{rawToken('--ease-move')}</code>.
- Change either on the tokens page and both this chart and every CSS
- demo in the lab move together — which is the whole claim: one value,
- two consumers.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <VStack gap={3}>
- <Heading level={2}>The module, as it stands right now</Heading>
- <Text color="secondary" {...stylex.props(sx.prose)}>
- Emitted from whatever this session has tuned, including springs from
- the springs page. Copy it and it is a working module.
- </Text>
- <CodeBlock
- language="ts"
- title="@astryxdesign/core/motion — generated"
- hasCopyButton
- maxHeight={760}
- code={emitMirror(rawToken, springs)}
- />
- </VStack>
-
- <Grid columns={{minWidth: 460}} gap={4}>
- <DemoCard
- title="Why the defaults are not hardcoded in JS"
- question="Because a theme retunes the whole scale, and a constants file would quietly stop agreeing with the stylesheet.">
- <DemoBody>
- <Text color="secondary" {...stylex.props(sx.prose)}>
- A theme sets three numbers —{' '}
- <code>{'{fast, medium, ratio}'}</code> — and{' '}
- <code>expandMotionScale</code> derives the whole duration scale
- from them; the shipped y2k theme lands{' '}
- <code>--duration-medium</code> on 250ms rather than 410ms. A
- mirror written as literals would be right for the default theme
- and wrong for every other one, which is the failure mode MobileNav
- is already defending against by reading the computed value.
- </Text>
- <Text color="secondary" {...stylex.props(sx.prose)}>
- So the mirror parses the same token values the stylesheets use,
- through the resolver core already has:{' '}
- <code>resolveThemeTokens(theme, {'{mode}'})</code> returns
- concrete strings with <code>var()</code> references already
- followed, and needs no React context and no browser. Springs are
- the exception and are defined in the mirror natively, because they
- have no CSS form to parse.
- </Text>
- <CodeBlock
- language="ts"
- title="How the emitter gets its numbers"
- isWrapped
- code={`import {resolveThemeTokens} from '@astryxdesign/core/theme/tokens';
-
-const tokens = resolveThemeTokens(theme, {mode: 'light'});
-duration.overlay = parseMs(tokens['--duration-overlay']) / 1000;
-ease.move = parseBezier(tokens['--ease-move']);
-// spring.* has no token to read — it is authored here.`}
- />
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="StyleX vars are not the mirror"
- question="Core already exports durationVars and easeVars. They are the right thing for StyleX and useless everywhere else.">
- <DemoBody>
- <CodeBlock
- language="ts"
- code={STYLEX_GAP_CODE}
- isWrapped
- maxHeight={300}
- />
- <Text color="secondary" {...stylex.props(sx.prose)}>
- <code>stylex.defineVars</code> hands back opaque{' '}
- <code>var(...)</code> strings. That is the correct contract for a
- stylesheet and it is precisely the gap: the value never becomes a
- number on the JS side. The mirror is the second half of the same
- token, not a competing source of truth.
- </Text>
- </DemoBody>
- </DemoCard>
- </Grid>
-
- <Banner
- status="info"
- title="What the mirror does not solve"
- description={
- <Text>
- A second artefact is a second thing to keep in sync. It only stays
- honest if it is generated from the theme in the same build step that
- emits the CSS, and if the lint rule treats a hardcoded number in JS
- the same way it treats one in a stylesheet. Both of those are on{' '}
- <Link href="/motion/export">Export tuning</Link>.
- </Text>
- }
- />
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/library.tsx b/apps/sandbox/src/motion/pages/library.tsx
deleted file mode 100644
index fabc8dce59..0000000000
--- a/apps/sandbox/src/motion/pages/library.tsx
+++ /dev/null
@@ -1,232 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input libraryCompat.ts and the generated audit
- * @output The three blockers between Astryx and motion.dev, in order
- * @position /motion/library
- *
- * The recommendation is to stay CSS-first and become explicitly compatible.
- * Nothing on this page argues for taking the dependency; it argues about what
- * a consumer who takes it themselves runs into, which is a different and much
- * cheaper list than the brief assumed.
- */
-
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Card} from '@astryxdesign/core/Card';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Link as AstryxLink} from '@astryxdesign/core/Link';
-import {HStack, VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import {
- AUDIT_COUNTS,
- TRANSFORM_TRANSITIONS,
-} from '../__generated__/motionAudit';
-import {ComparePanes, DemoBody, DemoCard} from '../LabPrimitives';
-import {PressRig} from '../LabDemos';
-import {LabPage} from '../PageFrame';
-import {
- ALREADY_RIGHT,
- BLOCKERS,
- CHEAP_WINS,
- MOTION_BUNDLE_KB,
- buttonFindings,
-} from '../libraryCompat';
-
-function Detail({label, children}: {label: string; children: string}) {
- return (
- <VStack gap={1}>
- <Text type="label" weight="semibold">
- {label}
- </Text>
- <Text color="secondary">{children}</Text>
- </VStack>
- );
-}
-
-export default function MotionLibraryPage() {
- const button = buttonFindings();
- const transformComponents = new Set(
- TRANSFORM_TRANSITIONS.map(site => site.component),
- );
-
- return (
- <LabPage
- title="Motion library compatibility"
- intro="What a team that installs motion.dev runs into today, and the smallest set of changes that makes Astryx compose with it. Three blockers, in the order they bite."
- badges={<Badge variant="info" label="CSS-first" />}
- decides="The three blockers, and whether Button keeps its press transition.">
- <Banner
- status="info"
- title="Stay CSS-first and become explicitly compatible"
- description={
- <Text>
- {`Astryx should not ship Motion: ~${MOTION_BUNDLE_KB}KB and a runtime on every consumer, to fix nothing the CSS path is failing at. But a consumer who installs it themselves should find that Astryx composes cleanly, and today three things stop that. Two of the three are already on the roadmap under other names.`}
- </Text>
- }
- />
-
- {BLOCKERS.map((blocker, index) => (
- <DemoCard
- key={blocker.id}
- title={`${index + 1}. ${blocker.title}`}
- question={blocker.symptom}
- badges={<Badge variant="error" label={blocker.severity} />}>
- {blocker.id === 'transform-transitions' ? (
- <VStack gap={0}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'transition: transform — today',
- content: <PressRig technique="transform" />,
- },
- {
- tone: 'neutral',
- label: 'transition: scale — the middle path',
- content: <PressRig technique="scale" />,
- },
- {
- tone: 'after',
- label: 'no transition — what the brief proposes',
- content: <PressRig technique="none" />,
- },
- ]}
- />
- <DemoBody>
- <Detail label="Cause">{blocker.cause}</Detail>
- <Detail label="Fix">{blocker.fix}</Detail>
- <Banner
- status="warning"
- title={`Measured: ${AUDIT_COUNTS.transformTransitions} sites across ${AUDIT_COUNTS.transformTransitionComponents} components — the brief's "20+" was right`}
- description={
- <Text>
- {button.transformSites.length > 0
- ? `Button is in the list, at ${button.transformSites
- .map(site => `${site.file}:${site.line}`)
- .join(
- ', ',
- )}: it declares transform in its transition property list and takes scale(0.98) on :active. The brief calls it the worst case because it is the most-wrapped component, and the measurement agrees. Two earlier versions of the audit script reported far fewer sites and no Button at all — a wrapped value and a nested StyleX rule each hid matches. The brief was closer than the tool twice.`
- : 'Button is absent from the measured data, which contradicts the brief. Re-check the scanner before acting on this.'}
- </Text>
- }
- />
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Component</TableHeaderCell>
- <TableHeaderCell>Site</TableHeaderCell>
- <TableHeaderCell>Declaration</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {TRANSFORM_TRANSITIONS.map(site => (
- <TableRow key={`${site.file}:${site.line}`}>
- <TableCell>
- <Text weight="semibold">{site.component}</Text>
- </TableCell>
- <TableCell>
- <Text type="code">{`${site.file}:${site.line}`}</Text>
- </TableCell>
- <TableCell>
- <Text type="code" color="secondary">
- {site.decl ?? '\u2014'}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- <Text type="supporting" color="secondary">
- {`${transformComponents.size} components, and the shape of the list is chevrons and menus rather than roots: ${[...transformComponents].join(', ')}. A consumer animating a chevron is rare; a consumer animating a Button is not, which is why the brief's framing mattered and why the correction changes the priority.`}
- </Text>
- <Detail label="Cost">{blocker.cost}</Detail>
- </DemoBody>
- </VStack>
- ) : (
- <DemoBody>
- <Detail label="Cause">{blocker.cause}</Detail>
- <Detail label="Fix">{blocker.fix}</Detail>
- <Detail label="Cost">{blocker.cost}</Detail>
- {blocker.id === 'overlay-exit' && (
- <Text type="supporting" color="secondary">
- Same mechanism as the CSS exit gap:{' '}
- <AstryxLink href="/motion/exit-gap">
- see it fail natively
- </AstryxLink>
- . One fix closes both, and doing them apart means solving
- top-layer retention twice.
- </Text>
- )}
- </DemoBody>
- )}
- </DemoCard>
- ))}
-
- <VStack gap={3}>
- <Heading level={2}>Cheap wins</Heading>
- <Text color="secondary">
- What moves Astryx from &ldquo;wrappable with caveats&rdquo; to
- Motion-friendly for everything except overlay exits. None of these
- needs the composition decision.
- </Text>
- <Grid columns={{minWidth: 280}} gap={3}>
- {CHEAP_WINS.map(win => (
- <Card key={win.id} padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">{win.title}</Text>
- <Text type="supporting" color="secondary">
- {win.detail}
- </Text>
- {win.evidence != null && <Badge label={win.evidence} />}
- </VStack>
- </Card>
- ))}
- </Grid>
- <Text type="supporting" color="secondary">
- The ref gap is the one number on this page the lab cannot check: the
- audit reads the built package&rsquo;s styles, not its prop types, so
- the brief&rsquo;s &ldquo;eight overlay components&rdquo; is unverified
- here.
- </Text>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>What already works</Heading>
- <Text color="secondary">
- Astryx is structurally better placed for this than most CSS-first
- systems, and the part that usually needs a rewrite is the part that is
- already right.
- </Text>
- <Grid columns={{minWidth: 260}} gap={3}>
- {ALREADY_RIGHT.map(item => (
- <Card key={item.title} padding={4}>
- <VStack gap={1.5}>
- <HStack gap={1.5} vAlign="center">
- <Badge variant="success" label="ok" />
- <Text weight="semibold">{item.title}</Text>
- </HStack>
- <Text type="supporting" color="secondary">
- {item.detail}
- </Text>
- </VStack>
- </Card>
- ))}
- </Grid>
- </VStack>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/overview.tsx b/apps/sandbox/src/motion/pages/overview.tsx
deleted file mode 100644
index 2d93dfde87..0000000000
--- a/apps/sandbox/src/motion/pages/overview.tsx
+++ /dev/null
@@ -1,356 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input Generated audit, brief figures, section registry
- * @output The Motion Lab overview
- * @position /motion
- *
- * Opens on the disagreement between the brief and the code rather than on the
- * brief's numbers, because that is the first thing anyone acting on this needs
- * to know: the audit was written against a reading of the repo, and the repo
- * says something slightly different in several places.
- */
-
-import * as stylex from '@stylexjs/stylex';
-import Link from 'next/link';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Badge} from '@astryxdesign/core/Badge';
-import {Card} from '@astryxdesign/core/Card';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Link as AstryxLink} from '@astryxdesign/core/Link';
-import {HStack, VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import {AUDIT_COUNTS, CORE_VERSION} from '../__generated__/motionAudit';
-import {GUIDANCE_CONFLICTS, PUBLISHED_PAGE_URL} from '../publishedGuidance';
-import {MOTION_SECTIONS} from '../sections';
-import {LabPage} from '../PageFrame';
-
-const sx = stylex.create({
- stat: {padding: '14px'},
- statValue: {
- fontSize: '26px',
- fontWeight: 650,
- letterSpacing: '-0.02em',
- lineHeight: 1.1,
- },
- bad: {color: 'var(--color-text-error, #d3543f)'},
- warn: {color: 'var(--color-text-warning, #b3760a)'},
- full: {width: '100%'},
- cardLink: {textDecoration: 'none', color: 'inherit', display: 'block'},
-});
-
-/**
- * The brief's figures beside the measured ones. Rows only appear here when
- * they differ — a table of agreements would bury the four that matter.
- */
-const RECONCILIATION: ReadonlyArray<{
- readonly measure: string;
- readonly brief: string;
- readonly measured: string;
- readonly reading: string;
-}> = [
- {
- measure: 'Component directories',
- brief: '107 (90 core, 17 lab)',
- measured: `${AUDIT_COUNTS.componentDirs} (${AUDIT_COUNTS.coreComponentDirs} core, ${AUDIT_COUNTS.labComponentDirs} lab)`,
- reading:
- 'Lab matches exactly. Core is higher than the brief\u2019s 90 — the split it quotes is close but not current.',
- },
- {
- measure: 'Animate something',
- brief: '63',
- measured: String(AUDIT_COUNTS.animatingComponents),
- reading:
- 'Counted as component directories with at least one transition, animation or keyframe. The brief counted across core and lab together.',
- },
- {
- measure: 'Hardcoded duration / easing',
- brief: '28',
- measured: String(AUDIT_COUNTS.hardcodedTotal),
- reading:
- 'Higher, not lower. The brief undercounts: the sweep is bigger than budgeted, and about a quarter of it is a reduced-motion idiom rather than carelessness.',
- },
- {
- measure: 'Files animating with no reduced-motion branch',
- brief: '39',
- measured: String(AUDIT_COUNTS.filesWithoutReducedMotion),
- reading:
- 'Close. The gap is counting method, not a disagreement worth chasing.',
- },
- {
- measure: 'Dead no-op transitions',
- brief: '3, in Selector / ComplexSelector / MultiSelector',
- measured: `${AUDIT_COUNTS.noopTransitions}, in Lightbox`,
- reading:
- 'The brief\u2019s three do not exist as described. The one real instance is a deliberate transitionProperty: none. Worth re-checking before it becomes a milestone line item.',
- },
- {
- measure: 'CSS transition on transform',
- brief: '20+ components',
- measured: `${AUDIT_COUNTS.transformTransitions} sites, ${AUDIT_COUNTS.transformTransitionComponents} components`,
- reading:
- 'The brief is right, and this row is a caution about the tool rather than the doc: two earlier versions of the audit script reported 13 across 9, because a wrapped value and a nested StyleX rule each hid matches. Trust a generated number only as far as its generator has been tested.',
- },
-];
-
-function Stat({
- value,
- label,
- detail,
- tone,
-}: {
- value: string | number;
- label: string;
- detail?: string;
- tone?: 'bad' | 'warn';
-}) {
- return (
- <Card padding={0} {...stylex.props(sx.full)}>
- <VStack gap={0.5} {...stylex.props(sx.stat)}>
- <span
- {...stylex.props(
- sx.statValue,
- tone === 'bad' && sx.bad,
- tone === 'warn' && sx.warn,
- )}>
- {value}
- </span>
- <Text type="supporting">{label}</Text>
- {detail != null && (
- <Text type="supporting" color="secondary">
- {detail}
- </Text>
- )}
- </VStack>
- </Card>
- );
-}
-
-export default function MotionOverviewPage() {
- const reversals = GUIDANCE_CONFLICTS.filter(c => c.severity === 'reversal');
-
- return (
- <LabPage
- title="Motion Lab"
- intro="A bench for the H2 2026 motion proposals. Every proposal is here as a working before-and-after with its values exposed as controls, so the decisions get made by looking rather than by arguing about numbers in a document."
- badges={<Badge variant="info" label={`core@${CORE_VERSION}`} />}
- decides="Whether the audit in the brief matches the code, and which decisions are actually blocking.">
- <Banner
- status="warning"
- title={`${reversals.length} of the proposals reverse guidance Astryx publishes today`}
- description={
- <Text>
- The published Motion page tells authors that tooltips, hover cards
- and dropdown menus <em>may</em> disappear instantly, and that
- reduced motion means replacing animation with instant state changes.
- The eleven-component exit gap is not drift — it is that paragraph,
- correctly followed. Read the conflicts before planning any of this
- work.
- </Text>
- }
- endContent={
- <AstryxLink href="/motion/published">See the conflicts</AstryxLink>
- }
- />
-
- <VStack gap={3}>
- <Heading level={2}>Measured against the installed package</Heading>
- <Text color="secondary">
- Generated by <code>scripts/generate-motion-audit.mjs</code> from{' '}
- <code>packages/core/src</code> and <code>packages/lab/src</code> at
- core@
- {CORE_VERSION}, so these move when the packages do. Every finding
- carries the package it is in.
- </Text>
- <Grid columns={{minWidth: 210}} gap={3}>
- <Stat
- value={AUDIT_COUNTS.componentDirs}
- label="Component directories"
- detail={`${AUDIT_COUNTS.animatingComponents} animate, ${AUDIT_COUNTS.staticComponents} do not`}
- />
- <Stat
- value={1}
- label="Easing tokens"
- detail="--ease-standard, for every job"
- tone="bad"
- />
- <Stat
- value={9}
- label="Duration tokens"
- detail="named by size, not by job"
- />
- <Stat
- value={AUDIT_COUNTS.hardcodedTotal}
- label="Hardcoded duration / easing"
- detail={`${AUDIT_COUNTS.hardcodedDuration} durations, ${AUDIT_COUNTS.hardcodedEasing} curves`}
- tone="bad"
- />
- <Stat
- value={AUDIT_COUNTS.filesWithoutReducedMotion}
- label="Animated files with no reduced-motion branch"
- detail={`of ${AUDIT_COUNTS.animatedFiles} animated files`}
- tone="bad"
- />
- <Stat
- value={AUDIT_COUNTS.durationWithoutCurve}
- label="Durations with no declared curve"
- detail="silently getting the CSS default"
- tone="warn"
- />
- <Stat
- value={AUDIT_COUNTS.transformTransitions}
- label="Transitions on transform"
- detail={`across ${AUDIT_COUNTS.transformTransitionComponents} components`}
- tone="warn"
- />
- <Stat
- value={AUDIT_COUNTS.getComputedStyleReads}
- label="getComputedStyle reads"
- detail="the JS mirror's caseload"
- />
- </Grid>
- </VStack>
-
- <Banner
- status="info"
- title="How the counting works, and where it misleads"
- description={
- <Text>
- The audit attributes motion to the component directory the file sits
- in. Astryx composes heavily, so a surface can animate without a
- single transition in its own folder — Tooltip, HoverCard, Popover,
- Typeahead and the rest inherit theirs from <code>Layer/</code>,
- AlertDialog from <code>Dialog/</code>, IconButton and ToggleButton
- from <code>Button/</code>, FieldStatus from{' '}
- <code>hooks/containerReveal.stylex.ts</code>. Read the per-component
- numbers as &ldquo;where the motion is authored&rdquo;, not
- &ldquo;which components move&rdquo;. The same trap is waiting for
- the rubric: a per-component score has to follow composition, or it
- will fail a component for a curve it does not own.
- </Text>
- }
- />
-
- <VStack gap={3}>
- <Heading level={2}>Where the brief and the code disagree</Heading>
- <Text color="secondary">
- Only the rows that differ. Everything else in the audit checked out.
- </Text>
- <Card padding={0}>
- <Table density="balanced">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Measure</TableHeaderCell>
- <TableHeaderCell>Brief</TableHeaderCell>
- <TableHeaderCell>Measured</TableHeaderCell>
- <TableHeaderCell>Reading</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {RECONCILIATION.map(row => (
- <TableRow key={row.measure}>
- <TableCell>
- <Text weight="semibold">{row.measure}</Text>
- </TableCell>
- <TableCell>
- <Text color="secondary">{row.brief}</Text>
- </TableCell>
- <TableCell>
- <Text>{row.measured}</Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {row.reading}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>How to use the bench</Heading>
- <Grid columns={{minWidth: 280}} gap={3}>
- <Card padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">The rail applies everywhere</Text>
- <Text type="supporting" color="secondary">
- Slow-mo stretches every duration without moving the token, so
- you can judge a 175ms curve at 8&times; and still export 175ms.
- Reduced motion drives the real policy switch. Show hides one
- half of every comparison.
- </Text>
- </VStack>
- </Card>
- <Card padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">Every slider writes a real token</Text>
- <Text type="supporting" color="secondary">
- Tune a value anywhere and every demo in the section updates,
- because they all read the same custom property. When it feels
- right, the export page emits the token block and the JS mirror.
- </Text>
- </VStack>
- </Card>
- <Card padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">Numbers are generated, prose is not</Text>
- <Text type="supporting" color="secondary">
- Counts and file:line citations come from the audit script.
- Judgements about what they mean are written, and are the part
- worth arguing with.
- </Text>
- </VStack>
- </Card>
- </Grid>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Sections</Heading>
- <Grid columns={{minWidth: 300}} gap={3}>
- {MOTION_SECTIONS.filter(s => s.href !== '/motion').map(section => (
- <Link
- key={section.href}
- href={section.href}
- {...stylex.props(sx.cardLink)}>
- <Card padding={4} {...stylex.props(sx.full)}>
- <VStack gap={1}>
- <HStack gap={1.5} vAlign="center">
- <Text weight="semibold">{section.title}</Text>
- <Badge label={section.group} />
- </HStack>
- <Text type="supporting" color="secondary">
- {section.decides}
- </Text>
- </VStack>
- </Card>
- </Link>
- ))}
- </Grid>
- </VStack>
-
- <Text type="supporting" color="secondary">
- Published guidance:{' '}
- <AstryxLink
- href={PUBLISHED_PAGE_URL}
- target="_blank"
- rel="noopener noreferrer">
- astryx.atmeta.com/docs/motion
- </AstryxLink>
- </Text>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/plan.tsx b/apps/sandbox/src/motion/pages/plan.tsx
deleted file mode 100644
index 692fd2d29d..0000000000
--- a/apps/sandbox/src/motion/pages/plan.tsx
+++ /dev/null
@@ -1,279 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input openQuestions.ts
- * @output The sequence, what gates each stage, and who has to answer what
- * @position /motion/plan
- *
- * The ordering here is a dependency graph, not a schedule. Most of its edges
- * are decisions: nine of them are still open, and four of those sit above the
- * first stage that would write code.
- */
-
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Card} from '@astryxdesign/core/Card';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Link as AstryxLink} from '@astryxdesign/core/Link';
-import {HStack, VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import {AUDIT_COUNTS} from '../__generated__/motionAudit';
-import {DemoBody, DemoCard} from '../LabPrimitives';
-import {LabPage} from '../PageFrame';
-import {
- BRIEF_DEFECTS,
- COMMITMENTS,
- OPEN_QUESTIONS,
- RISKS,
- STAGES,
- type OpenQuestion,
-} from '../openQuestions';
-
-const URGENCY_VARIANT: Record<
- OpenQuestion['urgency'],
- 'error' | 'warning' | 'neutral'
-> = {
- 'decide first': 'error',
- 'decide before the sweep': 'warning',
- 'decide before publishing': 'warning',
- 'can run late': 'neutral',
-};
-
-export default function MotionPlanPage() {
- const blocking = OPEN_QUESTIONS.filter(q => q.urgency === 'decide first');
- const committed = COMMITMENTS.filter(c => c.level === 'committed');
- const stretch = COMMITMENTS.filter(c => c.level === 'stretch');
-
- return (
- <LabPage
- title="Plan & open questions"
- intro="A dependency order for the work, the decisions that gate each stage, and the ones nobody has made yet. Sizes are relative; there are no dates, because the brief has none either."
- badges={
- <Badge
- variant="warning"
- label={`${OPEN_QUESTIONS.length} open questions`}
- />
- }
- decides="Sequence, gates, and who has to answer what.">
- <Banner
- status="warning"
- title={`${blocking.length} decisions sit above the first line of code`}
- description={
- <Text>
- Springs in the theme contract and the mobile-token vocabulary both
- change the shape of the token contract, and both are breaking
- changes if they arrive after Foundation ships. Everything else can
- be decided while work runs — these two cannot.
- </Text>
- }
- />
-
- <VStack gap={3}>
- <Heading level={2}>Sequence</Heading>
- <Text color="secondary">
- Each stage lists what blocks it. A stage whose gate is still open does
- not start early; it starts twice.
- </Text>
- {STAGES.map(stage => (
- <DemoCard
- key={stage.id}
- title={`${stage.index}. ${stage.name}`}
- question={stage.goal}
- badges={<Badge label={stage.size} />}>
- <DemoBody>
- <VStack gap={1}>
- {stage.work.map((item, i) => (
- <Text key={item} color="secondary">
- {`${i + 1}. ${item}`}
- </Text>
- ))}
- </VStack>
- {stage.blockedBy.length > 0 ? (
- <VStack gap={1.5}>
- {stage.blockedBy.map(gate => (
- <HStack key={gate} gap={2} vAlign="center" wrap="wrap">
- <Badge variant="error" label="gate" />
- <Text type="supporting" color="secondary">
- {gate}
- </Text>
- </HStack>
- ))}
- </VStack>
- ) : (
- <HStack gap={2} vAlign="center">
- <Badge variant="success" label="unblocked" />
- <Text type="supporting" color="secondary">
- Nothing blocks this. It is the only stage that can start
- today.
- </Text>
- </HStack>
- )}
- </DemoBody>
- </DemoCard>
- ))}
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Scope discipline</Heading>
- <Banner
- status="error"
- title="Do not combine token retuning, presence architecture and component remediation in one rollout"
- description={
- <Text>
- All three move the visual-regression baselines. Rolled out
- separately, a failure is attributable: a baseline moved because a
- curve changed, or because a surface now animates out, or because a
- component was rewritten. Rolled out together, every failure is a
- bisect, and the bisect is across a quarter of work. This is also
- why Foundation ships tokens as aliases before it retunes a single
- value — the alias step is provably invisible, so anything the
- capture catches afterwards belongs to the retune.
- </Text>
- }
- />
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Open questions</Heading>
- <Text color="secondary">
- Each one names what it needs, what it blocks, and where in the lab you
- can look at it instead of arguing about it.
- </Text>
- {OPEN_QUESTIONS.map(question => (
- <Card key={question.id} padding={4}>
- <VStack gap={2}>
- <HStack gap={2} vAlign="center" wrap="wrap" justify="between">
- <Text weight="semibold">{question.question}</Text>
- <Badge
- variant={URGENCY_VARIANT[question.urgency]}
- label={question.urgency}
- />
- </HStack>
- <Grid columns={{minWidth: 260}} gap={3}>
- <VStack gap={1}>
- <Text type="label" weight="semibold">
- Needs
- </Text>
- <Text type="supporting" color="secondary">
- {question.needs}
- </Text>
- </VStack>
- <VStack gap={1}>
- <Text type="label" weight="semibold">
- Blocks
- </Text>
- <Text type="supporting" color="secondary">
- {question.blocks}
- </Text>
- </VStack>
- </Grid>
- <AstryxLink href={question.href}>{question.hrefLabel}</AstryxLink>
- </VStack>
- </Card>
- ))}
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Committed and stretch</Heading>
- <Text color="secondary">
- {`Committed is what should be true at the end of H2 whatever else slips: ${committed.length} items. Stretch is ${stretch.length} more that are worth doing and safe to drop, because nothing in the committed list depends on them.`}
- </Text>
- <Card padding={0}>
- <Table density="balanced">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Item</TableHeaderCell>
- <TableHeaderCell>Level</TableHeaderCell>
- <TableHeaderCell>Why</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {COMMITMENTS.map(item => (
- <TableRow key={item.item}>
- <TableCell>
- <Text weight="semibold">{item.item}</Text>
- </TableCell>
- <TableCell>
- <Badge
- variant={
- item.level === 'committed' ? 'success' : 'neutral'
- }
- label={item.level}
- />
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {item.why}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Risks</Heading>
- <Text color="secondary">
- The brief&rsquo;s six, and what the lab does about each. One of them
- the lab cannot help with at all, which is worth saying out loud.
- </Text>
- <Card padding={0}>
- <Table density="balanced">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Risk</TableHeaderCell>
- <TableHeaderCell>What the lab does about it</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {RISKS.map(risk => (
- <TableRow key={risk.risk}>
- <TableCell>
- <Text>{risk.risk}</Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {risk.mitigation}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Defects in the brief itself</Heading>
- <Text color="secondary">
- {`Found while building the lab, alongside the measurement corrections on the overview — the sweep is ${AUDIT_COUNTS.hardcodedTotal} sites rather than 28, and the transform blocker is ${AUDIT_COUNTS.transformTransitions} sites rather than "20+".`}
- </Text>
- <Grid columns={{minWidth: 300}} gap={3}>
- {BRIEF_DEFECTS.map(defect => (
- <Card key={defect.defect} padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">{defect.defect}</Text>
- <Text type="supporting" color="secondary">
- {defect.detail}
- </Text>
- </VStack>
- </Card>
- ))}
- </Grid>
- </VStack>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/preview-plan.tsx b/apps/sandbox/src/motion/pages/preview-plan.tsx
deleted file mode 100644
index edc0c7c1e4..0000000000
--- a/apps/sandbox/src/motion/pages/preview-plan.tsx
+++ /dev/null
@@ -1,359 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input previewPlan.ts and the generated audit
- * @output What every component's preview has to demonstrate before it is built
- * @position /motion/preview-plan
- *
- * A build plan, not a gallery. The column that matters is the hard case: a
- * preview that only shows the easy case decides nothing, and most of the
- * techniques in this project are chosen by one awkward instance rather than
- * by the general shape.
- */
-
-import {useMemo, useState} from 'react';
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Card} from '@astryxdesign/core/Card';
-import {Divider} from '@astryxdesign/core/Divider';
-import {EmptyState} from '@astryxdesign/core/EmptyState';
-import {Grid} from '@astryxdesign/core/Grid';
-import {
- SegmentedControl,
- SegmentedControlItem,
-} from '@astryxdesign/core/SegmentedControl';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import {TextInput} from '@astryxdesign/core/TextInput';
-import {HStack, VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {LabPage} from '../PageFrame';
-import {
- PREVIEW_GROUPS,
- PREVIEW_PLAN,
- measure,
- type PreviewRow,
- type Verdict,
-} from '../previewPlan';
-
-const VERDICT_VARIANT: Record<
- Verdict,
- 'success' | 'warning' | 'error' | 'neutral'
-> = {
- GOOD: 'success',
- PARTIAL: 'warning',
- ADD: 'error',
- NONE: 'neutral',
-};
-
-const PRIORITY_LABEL: Record<1 | 2 | 3, string> = {
- 1: 'P1 · decides an open question',
- 2: 'P2 · high-frequency surface',
- 3: 'P3 · completeness',
-};
-
-function Field({label, children}: {label: string; children: string}) {
- return (
- <VStack gap={0.5}>
- <Text type="supporting" weight="semibold">
- {label}
- </Text>
- <Text type="supporting" color="secondary">
- {children}
- </Text>
- </VStack>
- );
-}
-
-function RowCard({row}: {row: PreviewRow}) {
- const measurement = measure(row);
- return (
- <Card padding={4}>
- <VStack gap={2}>
- <VStack gap={1}>
- <HStack gap={1.5} vAlign="center" wrap="wrap">
- <Text weight="semibold">{row.component}</Text>
- <Badge variant={VERDICT_VARIANT[row.verdict]} label={row.verdict} />
- <Badge
- variant={row.status === 'built' ? 'success' : 'neutral'}
- label={
- row.status === 'built'
- ? `built · ${row.rig ?? ''}`
- : 'specified'
- }
- />
- <Badge label={PRIORITY_LABEL[row.priority]} />
- </HStack>
- <HStack gap={3} wrap="wrap">
- <Text type="supporting" color="secondary">
- {`Today: ${row.today}`}
- </Text>
- </HStack>
- <Text type="supporting" color="secondary">
- {`Gap: ${row.gap}`}
- </Text>
- </VStack>
-
- <Divider />
-
- <Field label="The preview must show">{row.shows}</Field>
- <Field label="The hard case that decides the technique">
- {row.hardCase}
- </Field>
-
- {row.controls.length > 0 && (
- <HStack gap={1} wrap="wrap">
- {row.controls.map(control => (
- <Badge key={control} variant="info" label={control} />
- ))}
- </HStack>
- )}
-
- {measurement.kind === 'contradiction' && (
- <Banner
- status="error"
- title="Brief and measurement disagree"
- description={<Text>{measurement.note}</Text>}
- />
- )}
- {measurement.kind === 'nuance' && (
- <Banner
- status="warning"
- title="Measured differently"
- description={<Text>{measurement.note}</Text>}
- />
- )}
- {measurement.kind === 'unmeasured' && measurement.note !== '' && (
- <Text type="supporting" color="secondary">
- {measurement.note}
- </Text>
- )}
- </VStack>
- </Card>
- );
-}
-
-export default function PreviewPlanPage() {
- const [verdict, setVerdict] = useState<string>('all');
- const [status, setStatus] = useState<string>('all');
- const [query, setQuery] = useState('');
-
- const filtered = useMemo(() => {
- const needle = query.trim().toLowerCase();
- return PREVIEW_PLAN.filter(row => {
- if (verdict !== 'all' && row.verdict !== verdict) {
- return false;
- }
- if (status !== 'all' && row.status !== status) {
- return false;
- }
- if (needle === '') {
- return true;
- }
- return [
- row.component,
- row.today,
- row.gap,
- row.shows,
- row.hardCase,
- row.group,
- ]
- .join(' ')
- .toLowerCase()
- .includes(needle);
- });
- }, [verdict, status, query]);
-
- const built = PREVIEW_PLAN.filter(row => row.status === 'built');
- const specified = PREVIEW_PLAN.filter(row => row.status === 'specified');
- const disagreements = PREVIEW_PLAN.filter(
- row => measure(row).kind === 'contradiction',
- );
- const queue = [...specified].sort(
- (a, b) =>
- a.priority - b.priority ||
- PREVIEW_GROUPS.indexOf(a.group) - PREVIEW_GROUPS.indexOf(b.group),
- );
-
- return (
- <LabPage
- title="Preview plan"
- intro="Every component in the audit, what its preview has to demonstrate, and the controls it needs. The hard case is the column that matters: a preview that only shows the easy case is worth nothing."
- badges={<Badge label={`${PREVIEW_PLAN.length} rows`} />}
- decides="What every remaining preview has to show before it is worth building.">
- <Grid columns={{minWidth: 200}} gap={3}>
- <Card padding={4}>
- <VStack gap={0.5}>
- <Heading level={3}>{PREVIEW_PLAN.length}</Heading>
- <Text type="supporting" color="secondary">
- Rows across six surfaces
- </Text>
- </VStack>
- </Card>
- <Card padding={4}>
- <VStack gap={0.5}>
- <Heading level={3}>{built.length}</Heading>
- <Text type="supporting" color="secondary">
- Already have a rig in the lab
- </Text>
- </VStack>
- </Card>
- <Card padding={4}>
- <VStack gap={0.5}>
- <Heading level={3}>{specified.length}</Heading>
- <Text type="supporting" color="secondary">
- Specified, not built
- </Text>
- </VStack>
- </Card>
- <Card padding={4}>
- <VStack gap={0.5}>
- <Heading level={3}>{disagreements.length}</Heading>
- <Text type="supporting" color="secondary">
- Rows where the brief and the audit disagree
- </Text>
- </VStack>
- </Card>
- </Grid>
-
- <Banner
- status="warning"
- title={`${disagreements.length} verdicts do not survive the measurement`}
- description={
- <Text>
- Almost all of them are the same mechanism: the brief credits a
- component with the motion it inherits, and the audit measures per
- directory. Tooltip, HoverCard, Popover and the overflow layers get
- their entry from <code>Layer/</code>; FieldStatus gets its slide
- from <code>hooks/containerReveal.stylex.ts</code>. Neither reading
- is wrong, but a rubric scoring components one at a time will score
- these wrong unless it knows where to look.
- </Text>
- }
- />
-
- <VStack gap={3}>
- <HStack gap={3} wrap="wrap" vAlign="end">
- <SegmentedControl
- label="Filter by verdict"
- value={verdict}
- onChange={setVerdict}
- size="sm">
- <SegmentedControlItem value="all" label="All" />
- <SegmentedControlItem value="GOOD" label="GOOD" />
- <SegmentedControlItem value="PARTIAL" label="PARTIAL" />
- <SegmentedControlItem value="ADD" label="ADD" />
- <SegmentedControlItem value="NONE" label="NONE" />
- </SegmentedControl>
- <SegmentedControl
- label="Filter by status"
- value={status}
- onChange={setStatus}
- size="sm">
- <SegmentedControlItem value="all" label="All" />
- <SegmentedControlItem value="built" label="Built" />
- <SegmentedControlItem value="specified" label="Specified" />
- </SegmentedControl>
- <TextInput
- label="Search"
- isLabelHidden
- placeholder="Search components, gaps, hard cases"
- value={query}
- onChange={setQuery}
- hasClear
- width={280}
- />
- <Text type="supporting" color="secondary">
- {`${filtered.length} of ${PREVIEW_PLAN.length}`}
- </Text>
- </HStack>
-
- {filtered.length === 0 ? (
- <EmptyState
- title="Nothing matches"
- description="No row matches that combination of verdict, status and search."
- />
- ) : (
- PREVIEW_GROUPS.map(group => {
- const rows = filtered.filter(row => row.group === group);
- if (rows.length === 0) {
- return null;
- }
- return (
- <VStack key={group} gap={2}>
- <HStack gap={2} vAlign="center">
- <Heading level={2}>{group}</Heading>
- <Badge label={`${rows.length}`} />
- </HStack>
- <Grid columns={{minWidth: 420}} gap={3}>
- {rows.map(row => (
- <RowCard key={row.id} row={row} />
- ))}
- </Grid>
- </VStack>
- );
- })
- )}
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Build queue</Heading>
- <Text color="secondary">
- {`The ${specified.length} specified previews in priority order. P1 rows each settle an open question, so they are worth building before the decision meeting rather than after it.`}
- </Text>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Priority</TableHeaderCell>
- <TableHeaderCell>Component</TableHeaderCell>
- <TableHeaderCell>Surface</TableHeaderCell>
- <TableHeaderCell>Why it is worth building</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {queue.map(row => (
- <TableRow key={row.id}>
- <TableCell>
- <Badge
- variant={
- row.priority === 1
- ? 'error'
- : row.priority === 2
- ? 'warning'
- : 'neutral'
- }
- label={`P${row.priority}`}
- />
- </TableCell>
- <TableCell>
- <Text weight="semibold">{row.component}</Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {row.group}
- </Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {row.hardCase}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- </VStack>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/previews.tsx b/apps/sandbox/src/motion/pages/previews.tsx
deleted file mode 100644
index d4417e44b2..0000000000
--- a/apps/sandbox/src/motion/pages/previews.tsx
+++ /dev/null
@@ -1,287 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input LabDemos rigs, the lab store
- * @output The coverage work, each as a working before-and-after
- * @position /motion/previews
- *
- * The "where to start" list from the brief, minus the presence work that has
- * its own page. Ordered by user-visible impact per unit of work, which is the
- * order the brief argues for and the order these should be picked up in.
- */
-
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Link} from '@astryxdesign/core/Link';
-import {VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {LabPage} from '../PageFrame';
-import {ComparePanes, DemoBody, DemoCard, TokenSlider} from '../LabPrimitives';
-import {
- CheckTickRig,
- ChipRig,
- DisclosureRig,
- ListReorderRig,
- RailRig,
- SkeletonSwapRig,
- StatCountRig,
- TabIndicatorRig,
-} from '../LabDemos';
-
-export default function PreviewsPage() {
- return (
- <LabPage
- title="Live previews"
- intro="The coverage work, each as a working before-and-after. Every control writes a real token, so a value settled here is settled everywhere. Turn the rail up to 4× to judge a curve, then back to 1× to judge whether it is too slow — those are different questions and they need different speeds."
- decides="Sliding indicators, disclosure convergence, the rail, chips, skeletons, lists.">
- <Banner
- status="info"
- title="Ordered by impact per unit of work"
- description={
- <Text>
- This is the brief&rsquo;s where-to-start list with the presence work
- removed, since that has{' '}
- <Link href="/motion/exit-gap">its own page</Link> and is the one
- thing here blocked on a policy decision. Everything below is
- unblocked and can start as soon as the tokens land.
- </Text>
- }
- />
-
- <DemoCard
- title="Sliding indicators"
- question="TabList and SegmentedControl share one decision. A travelling indicator crossing five tabs feels different from one crossing two — judge it on the long jump, not the short one."
- badges={<Badge variant="error" label="ADD" />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — per-item cross-fade',
- content: <TabIndicatorRig mode="before" />,
- },
- {
- tone: 'after',
- label: 'Proposed — one indicator travels',
- content: <TabIndicatorRig mode="after" />,
- },
- ]}
- />
- <DemoBody>
- <TokenSlider token="--duration-reveal" label="travel" max={700} />
- <Text type="supporting" color="secondary">
- The proposed pane uses <code>--ease-move</code> rather than the
- entry curve, because the indicator is already on screen: it needs a
- legible path, not an arrival accent. This is also the strongest
- candidate for the <code>layout</code> spring, since a travelling
- indicator is exactly the interruptible case.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="Disclosure bake-off"
- question="Nine surfaces, three techniques, and the newest component uses the one nobody else does. Settle it before more disclosure surfaces get built."
- badges={<Badge variant="warning" label="PARTIAL — three techniques" />}>
- <ComparePanes
- panes={[
- {
- tone: 'neutral',
- label: 'Grid tracks — CodeBlock, Chat',
- content: <DisclosureRig technique="grid" title="Grid tracks" />,
- },
- {
- tone: 'neutral',
- label: 'Height interpolation',
- content: <DisclosureRig technique="height" title="Height" />,
- },
- {
- tone: 'after',
- label: 'Height + offset fade — Collapsible',
- content: <DisclosureRig technique="offset" title="Collapsible" />,
- },
- ]}
- />
- <DemoBody>
- <TokenSlider token="--duration-reveal" label="reveal" max={700} />
- <Text type="supporting" color="secondary">
- There is probably no single winner. A table row cannot be a grid
- container, so Table row expansion and Table tree cannot use the
- grid-track technique whatever the bake-off concludes. The realistic
- outcome is one default plus a documented exception — which is worth
- writing down as the decision, rather than discovering it halfway
- through the convergence work.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="SideNav rail collapse"
- question="The rail's own width, not just the chevron. width is a layout property, so this is a deliberate criterion-6 exception — does it earn one?"
- badges={<Badge variant="error" label="ADD" />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — only the chevron rotates',
- content: <RailRig mode="before" />,
- },
- {
- tone: 'after',
- label: 'Proposed — the rail animates',
- content: <RailRig mode="after" />,
- },
- ]}
- />
- <DemoBody>
- <Text type="supporting" color="secondary">
- The transform alternative — translate the rail and clip it — keeps
- the animation on the compositor but leaves the content beside it
- un-reflowed until the end, which reads worse than the layout cost.
- Worth prototyping both before granting the exception.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="Skeleton → content"
- question="The archetypal hard swap. The failure is that it happens at a moment the user cannot predict."
- badges={<Badge variant="error" label="ADD" />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — content hard-swaps',
- content: <SkeletonSwapRig mode="before" />,
- },
- {
- tone: 'after',
- label: 'Proposed — crossfade with overlap',
- content: <SkeletonSwapRig mode="after" />,
- },
- ]}
- />
- <DemoBody>
- <TokenSlider token="--duration-state" label="crossfade" max={400} />
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="Chip add and remove"
- question="Tokenizer, Token and FileInput share this. Removal is the hard half: the chip has to leave while its neighbours close the gap."
- badges={<Badge variant="error" label="ADD" />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — instant',
- content: <ChipRig mode="before" />,
- },
- {
- tone: 'after',
- label: 'Proposed — scale in, accelerate away',
- content: <ChipRig mode="after" />,
- },
- ]}
- />
- <DemoBody>
- <TokenSlider token="--duration-enter" label="add" max={500} />
- <TokenSlider token="--duration-exit" label="remove" max={500} />
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="List add, remove and reorder"
- question="Reorder is movement the user did not initiate, so it has to be followable. This is the strongest argument for the layout spring."
- badges={<Badge variant="error" label="ADD" />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — instant',
- content: <ListReorderRig mode="before" />,
- },
- {
- tone: 'after',
- label: 'Proposed — FLIP on --ease-move',
- content: <ListReorderRig mode="after" />,
- },
- ]}
- />
- <DemoBody>
- <Text type="supporting" color="secondary">
- FLIP — measure, move, invert, play — is the technique here because
- the rows are genuinely re-laid-out and only the visual correction is
- animated. Try it at 4×: a shuffle that is legible at 4× and
- illegible at 1× means the duration is too short, not that the
- technique is wrong.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <Grid columns={{minWidth: 420}} gap={4}>
- <DemoCard
- title="Checkbox tick"
- question="A high-frequency surface, so criterion 2 applies: the answer may be that it should be almost nothing."
- badges={<Badge variant="error" label="ADD" />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today',
- content: <CheckTickRig technique="hard" />,
- },
- {
- tone: 'neutral',
- label: 'Draw',
- content: <CheckTickRig technique="draw" />,
- },
- {
- tone: 'after',
- label: 'Scale',
- content: <CheckTickRig technique="scale" />,
- },
- ]}
- />
- </DemoCard>
-
- <DemoCard
- title="Stat value change"
- question="A change of 4 and a change of 4,000 look identical today. Needs a delta threshold, or a jump from 12 to 1,300,000 spins for a second."
- badges={<Badge variant="error" label="ADD" />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — replaces itself',
- content: <StatCountRig mode="before" />,
- },
- {
- tone: 'after',
- label: 'Proposed — counts',
- content: <StatCountRig mode="after" />,
- },
- ]}
- />
- </DemoCard>
- </Grid>
-
- <VStack gap={2}>
- <Heading level={2}>What is not here</Heading>
- <Text color="secondary">
- Around twenty more previews are specified but not built —
- ContextMenu&rsquo;s pointer-anchored origin, CommandPalette filter
- motion, TreeList depth, TransferList&rsquo;s cross-container move,
- Carousel, Calendar month change, Slider keyboard step, Resizable snap.
- Each one has a written brief saying what it must demonstrate, on{' '}
- <Link href="/motion/preview-plan">Preview plan</Link>. The ones above
- were built first because each settles a decision that blocks other
- work.
- </Text>
- </VStack>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/published.tsx b/apps/sandbox/src/motion/pages/published.tsx
deleted file mode 100644
index b56225baa7..0000000000
--- a/apps/sandbox/src/motion/pages/published.tsx
+++ /dev/null
@@ -1,281 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input GUIDANCE_CONFLICTS and PUBLISHED_SECTIONS
- * @output The proposal beside what astryx.atmeta.com/docs/motion tells authors
- * @position /motion/published
- *
- * The exit gap and the delete-don't-degrade behaviour are both documented
- * guidance, correctly followed. That makes two of the proposals policy
- * reversals rather than bug fixes, which changes who has to sign them off and
- * what has to ship in the same stack. Every card here is one conflict; nothing
- * on the page is written by hand except the reading of it.
- */
-
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Button} from '@astryxdesign/core/Button';
-import {Card} from '@astryxdesign/core/Card';
-import {Link as AstryxLink} from '@astryxdesign/core/Link';
-import {HStack, VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import type {ReactNode} from 'react';
-import {ComparePanes, DemoCard} from '../LabPrimitives';
-import {LayerRig, LoopRig} from '../LabDemos';
-import {LabPage} from '../PageFrame';
-import {
- GUIDANCE_CONFLICTS,
- PUBLISHED_PAGE_URL,
- PUBLISHED_SECTIONS,
- type GuidanceConflict,
-} from '../publishedGuidance';
-
-type Severity = GuidanceConflict['severity'];
-
-const SEVERITY: Record<
- Severity,
- {
- readonly variant: 'error' | 'warning' | 'success';
- readonly question: string;
- }
-> = {
- reversal: {
- variant: 'error',
- question:
- 'Two documents give opposite instructions. One of them has to move first.',
- },
- extension: {
- variant: 'warning',
- question:
- 'The page is not wrong, it is incomplete. Does the proposal extend it or replace it?',
- },
- aligned: {
- variant: 'success',
- question:
- 'No conflict. Can the rubric cite this paragraph instead of re-arguing it?',
- },
-};
-
-/** `exit-optional` -> `Exit optional`. The data carries no title, so derive one. */
-function titleOf(id: string): string {
- const words = id.replace(/-/g, ' ');
- return words.charAt(0).toUpperCase() + words.slice(1);
-}
-
-/**
- * Only two conflicts can be settled by looking rather than reading, and both
- * are the reversals. The rest are arguments about wording.
- */
-function demoFor(id: string, tone: 'before' | 'after'): ReactNode {
- if (id === 'exit-optional') {
- return tone === 'before' ? (
- <LayerRig mode="before" label="Tooltip content" triggerLabel="Hover me" />
- ) : (
- <LayerRig mode="after" label="Tooltip content" triggerLabel="Hover me" />
- );
- }
- if (id === 'reduced-motion-delete') {
- return tone === 'before' ? (
- <LoopRig policy="delete" />
- ) : (
- <LoopRig policy="degrade" />
- );
- }
- return null;
-}
-
-function Quote({text, demo}: {text: string; demo: ReactNode}) {
- return (
- <VStack gap={3}>
- <Card padding={3}>
- <Text>{`\u201C${text}\u201D`}</Text>
- </Card>
- {demo}
- </VStack>
- );
-}
-
-export default function PublishedGuidancePage() {
- const reversals = GUIDANCE_CONFLICTS.filter(c => c.severity === 'reversal');
- const extensions = GUIDANCE_CONFLICTS.filter(c => c.severity === 'extension');
- const aligned = GUIDANCE_CONFLICTS.filter(c => c.severity === 'aligned');
- const rewriteSections = new Set(reversals.map(c => c.section));
- const noted = PUBLISHED_SECTIONS.filter(s => s.stale != null);
-
- return (
- <LabPage
- title="Against the published page"
- intro="Every proposal in the brief, beside the paragraph of astryx.atmeta.com/docs/motion it lands on. Quotes are verbatim, so this page can be diffed against the live one."
- badges={<Badge variant="error" label={`${reversals.length} reversals`} />}
- decides="Which proposals are bug fixes and which are reversals of guidance Astryx publishes today.">
- <Banner
- status="error"
- title={`${reversals.length} of the ${GUIDANCE_CONFLICTS.length} conflicts reverse published guidance`}
- description={
- <Text>
- The brief reads the exit gap as historical accident. It is not: the
- published Movement Principles tell authors that tooltips, hover
- cards and dropdown menus may disappear instantly, and Respecting
- User Preferences tells them to replace animation with instant state
- changes. Those two proposals are{' '}
- <strong>policy changes, not bug fixes</strong> — they need a
- decision and an owner rather than a diff. The doc rewrite has to
- ship in the same stack as the code, or the rubric starts failing
- components for doing what the docs still tell the next author to do.
- </Text>
- }
- endContent={
- <AstryxLink
- href={PUBLISHED_PAGE_URL}
- target="_blank"
- rel="noopener noreferrer">
- Read the live page
- </AstryxLink>
- }
- />
-
- <HStack gap={2} wrap="wrap">
- <Badge variant="error" label={`${reversals.length} reversals`} />
- <Badge variant="warning" label={`${extensions.length} extensions`} />
- <Badge variant="success" label={`${aligned.length} aligned`} />
- <Text type="supporting" color="secondary">
- Severity is about the document, not the code: a reversal means the
- published page has to change before the proposal is legitimate.
- </Text>
- </HStack>
-
- {GUIDANCE_CONFLICTS.map(conflict => (
- <DemoCard
- key={conflict.id}
- title={titleOf(conflict.id)}
- question={SEVERITY[conflict.severity].question}
- badges={
- <>
- <Badge
- variant={SEVERITY[conflict.severity].variant}
- label={conflict.severity}
- />
- <Badge label={conflict.section} />
- </>
- }
- actions={
- <Button
- variant="ghost"
- size="sm"
- label="See it in the lab"
- href={conflict.href}
- />
- }
- controls={
- <VStack gap={3}>
- <VStack gap={1}>
- <Text type="label" weight="semibold">
- Reading
- </Text>
- <Text color="secondary">{conflict.reading}</Text>
- </VStack>
- <VStack gap={1}>
- <Text type="label" weight="semibold">
- Resolution
- </Text>
- <Text color="secondary">{conflict.resolution}</Text>
- </VStack>
- </VStack>
- }>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: `Published today — ${conflict.section}`,
- content: (
- <Quote
- text={conflict.published}
- demo={demoFor(conflict.id, 'before')}
- />
- ),
- },
- {
- tone: 'after',
- label: 'Proposed in the brief',
- content: (
- <Quote
- text={conflict.proposed}
- demo={demoFor(conflict.id, 'after')}
- />
- ),
- },
- ]}
- />
- </DemoCard>
- ))}
-
- <VStack gap={3}>
- <Heading level={2}>Scope of the doc rewrite</Heading>
- <Text color="secondary">
- {`${noted.length} of the ${PUBLISHED_SECTIONS.length} sections of the live page need something. Two of them are the reversals above and cannot be deferred: the rubric has no authority while the page contradicts it. The rest are additions — the page is accurate about what exists, and silent about how to choose.`}
- </Text>
- <Card padding={0}>
- <Table density="balanced">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Section</TableHeaderCell>
- <TableHeaderCell>What it says today</TableHeaderCell>
- <TableHeaderCell>Scope</TableHeaderCell>
- <TableHeaderCell>Note</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {PUBLISHED_SECTIONS.map(section => {
- const isRewrite = rewriteSections.has(section.title);
- return (
- <TableRow key={section.title}>
- <TableCell>
- <Text weight="semibold">{section.title}</Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {section.summary}
- </Text>
- </TableCell>
- <TableCell>
- {isRewrite ? (
- <Badge variant="error" label="Rewrite" />
- ) : section.stale != null ? (
- <Badge variant="warning" label="Add to" />
- ) : (
- <Badge label="No change" />
- )}
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {section.stale ?? '\u2014'}
- </Text>
- </TableCell>
- </TableRow>
- );
- })}
- </TableBody>
- </Table>
- </Card>
- </VStack>
-
- <Text type="supporting" color="secondary">
- The rewrite is a deliverable in the brief already, listed last. On this
- reading it is a gate on the rubric rather than a write-up of work
- already done, which moves it earlier in the sequence than the timeline
- has it.
- </Text>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/reduced-motion.tsx b/apps/sandbox/src/motion/pages/reduced-motion.tsx
deleted file mode 100644
index e12cbc149f..0000000000
--- a/apps/sandbox/src/motion/pages/reduced-motion.tsx
+++ /dev/null
@@ -1,515 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input The generated audit, the published guidance, the lab store
- * @output Degrade or delete, with the sweep's worklist attached
- * @position /motion/reduced-motion
- *
- * The page's primary control is the rail's Reduced motion switch, not anything
- * rendered here. It drives the real policy for every demo in the lab, so the
- * argument is made by flipping it and watching rather than by reading a
- * caption about what would happen.
- */
-
-import * as stylex from '@stylexjs/stylex';
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Card} from '@astryxdesign/core/Card';
-import {CodeBlock} from '@astryxdesign/core/CodeBlock';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Link} from '@astryxdesign/core/Link';
-import {HStack, VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import {LabPage} from '../PageFrame';
-import {ComparePanes, DemoBody, DemoCard} from '../LabPrimitives';
-import {LoopRig, TintRig} from '../LabDemos';
-import {useMotionLab, type ReducedMotionMode} from '../MotionLabStore';
-import {
- AUDIT_COUNTS,
- HARDCODED_SITES,
- NO_REDUCED_MOTION,
-} from '../__generated__/motionAudit';
-import {GUIDANCE_CONFLICTS, PUBLISHED_PAGE_URL} from '../publishedGuidance';
-
-const sx = stylex.create({
- full: {width: '100%'},
- mono: {fontFamily: 'var(--font-family-code)', fontSize: '12px'},
- quote: {
- borderInlineStart: '2px solid var(--color-border)',
- paddingInlineStart: '12px',
- maxWidth: '64ch',
- },
-});
-
-const BRIEF_FIGURE = 39;
-
-const MODE_LABEL: Readonly<Record<ReducedMotionMode, string>> = {
- off: 'Off',
- degrade: 'Degrade',
- delete: 'Delete',
-};
-
-/** The sweep's worklist: every animated file with no reduced-motion branch. */
-const WORKLIST = [
- ...NO_REDUCED_MOTION.reduce((acc, row) => {
- const files = acc.get(row.component) ?? [];
- files.push(row.file);
- acc.set(row.component, files);
- return acc;
- }, new Map<string, string[]>()),
-].sort((a, b) => b[1].length - a[1].length || a[0].localeCompare(b[0]));
-
-const INSTANT_ESCAPES = HARDCODED_SITES.filter(site => site.value === '0.01s');
-
-const POLICIES: ReadonlyArray<{
- readonly policy: string;
- readonly survives: string;
- readonly forIt: string;
- readonly againstIt: string;
- readonly status: string;
-}> = [
- {
- policy: 'Delete',
- survives:
- 'Nothing. Transitions collapse to zero, loops stop, the end state arrives on the same frame as the change.',
- forIt:
- 'Safest reading of the accessibility guidance: a user who asked for no motion gets no motion, with no argument about which motion was the harmful kind. Trivially lintable, and it is one line per file.',
- againstIt:
- 'Deletes feedback that happens to be implemented as a transition. A hover tint, a focus ring fade and a spinner all disappear together, and the spinner leaves nothing behind that says "working".',
- status:
- 'What the published page instructs today, and what most of core does.',
- },
- {
- policy: 'Degrade',
- survives:
- 'Opacity and colour. Movement multipliers go to zero; loops stop and are replaced with a determinate state.',
- forIt:
- 'Keeps state feedback while removing the vestibular trigger, which is what both of the project\u2019s references recommend. The thing that hurts is movement, not the fact that a colour took 175ms to arrive.',
- againstIt:
- 'Needs a judgement per component about which half is movement, so it is not a one-line sweep. Gets it wrong quietly: a fade that survives on a surface that also travels is still motion.',
- status:
- 'What rubric criterion 10 proposes. A change of published policy, not a bug fix.',
- },
-];
-
-const CSS_RULE = `/* Movement is a multiplier, so the policy has one place to land. */
-.surface {
- --motion-translate: 1;
- --motion-scale: 1;
- transform: translateY(calc(8px * var(--motion-translate)))
- scale(calc(1 - 0.06 * var(--motion-scale)));
- transition:
- transform var(--duration-enter) var(--ease-entry),
- opacity var(--duration-enter) var(--ease-entry),
- background-color var(--duration-state) var(--ease-state);
-}
-
-/* Degrade: movement goes, opacity and colour stay. Not display: none for
- motion — the feedback is the point, the travel is the problem. */
-@media (prefers-reduced-motion: reduce) {
- .surface {
- --motion-translate: 0;
- --motion-scale: 0;
- }
-
- /* Loops stop. They do not slow down: slower vestibular motion is still
- vestibular motion, and a 3s spinner reads as a hung interface. */
- .spinner,
- .progressIndeterminate {
- animation: none;
- }
-}
-
-/* Hover motion is gated on a fine pointer as well. A touch device fires a
- hover on tap, so an un-gated hover animation runs on every tap. */
-@media (hover: hover) and (pointer: fine) {
- .row:hover {
- transform: translateY(calc(-1px * var(--motion-translate)));
- }
-}
-
-/* An app with its own reduce-motion setting can flip a JS library but cannot
- flip a media query, so the same rules answer to an attribute too. */
-[data-reduced-motion='reduce'] .surface {
- --motion-translate: 0;
- --motion-scale: 0;
-}`;
-
-const HOOK = `/**
- * The JS half of the same policy. Charts, canvas and any motion library read
- * this; CSS reads the media query. They have to agree, or a chart animates
- * while the interface around it does not.
- */
-export function useReducedMotion(): boolean {
- const [reduced, setReduced] = useState(() =>
- typeof window === 'undefined'
- ? false
- : window.matchMedia('(prefers-reduced-motion: reduce)').matches,
- );
-
- useEffect(() => {
- const query = window.matchMedia('(prefers-reduced-motion: reduce)');
- const onChange = (event: MediaQueryListEvent) => setReduced(event.matches);
- query.addEventListener('change', onChange);
- return () => query.removeEventListener('change', onChange);
- }, []);
-
- // The app-level override, so a product setting can force the policy on
- // without touching the OS. Same attribute the CSS above answers to.
- const forced = useContext(MotionPreferenceContext);
- return forced ?? reduced;
-}`;
-
-export default function ReducedMotionPage() {
- const {reducedMotion} = useMotionLab();
- const conflict = GUIDANCE_CONFLICTS.find(
- c => c.id === 'reduced-motion-delete',
- );
-
- return (
- <LabPage
- title="Reduced motion"
- intro="Degrade or delete. Everything else in the sweep is blocked on this answer, because the branch gets written once per file and there are 36 of them."
- badges={
- <>
- <Badge variant="error" label="Criterion 10 — Blocker" />
- <Badge
- variant="warning"
- label={`Rail: ${MODE_LABEL[reducedMotion]}`}
- />
- </>
- }
- decides="Degrade or delete. The decision the 36-file sweep is waiting on.">
- <Banner
- status="info"
- title="Use the Reduced motion switch in the rail above"
- description={
- <Text>
- It is the page&rsquo;s primary control, not a caption: it drives the
- real policy for every demo in the lab, on this page and every other
- one. Set it to <strong>Delete</strong>, then{' '}
- <strong>Degrade</strong>, and watch the same components under each.
- Right now it is set to <strong>{MODE_LABEL[reducedMotion]}</strong>.
- </Text>
- }
- />
-
- <VStack gap={3}>
- <Heading level={2}>The sweep&rsquo;s worklist</Heading>
- <Text color="secondary">
- {AUDIT_COUNTS.filesWithoutReducedMotion} of{' '}
- {AUDIT_COUNTS.animatedFiles} animated files have no{' '}
- <code>prefers-reduced-motion</code> branch at all — measured against
- the installed package. The brief says {BRIEF_FIGURE}; the gap is
- counting method rather than a disagreement worth chasing, but the list
- below is the one to work from because it names the files.
- </Text>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Component</TableHeaderCell>
- <TableHeaderCell>Files</TableHeaderCell>
- <TableHeaderCell>Paths</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {WORKLIST.map(([component, files]) => (
- <TableRow key={component}>
- <TableCell>
- <Text weight="semibold">{component}</Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {files.length}
- </Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {files.join(' · ')}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- <Text type="supporting" color="secondary">
- {WORKLIST[0]?.[0]} carries {WORKLIST[0]?.[1].length} of them and{' '}
- {WORKLIST[1]?.[0]} {WORKLIST[1]?.[1].length}, so two components are
- more than a quarter of the sweep. Both are also the components where a
- wrong answer is most visible.
- </Text>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Degrade or delete</Heading>
- <Card padding={0}>
- <Table density="balanced">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Policy</TableHeaderCell>
- <TableHeaderCell>What survives</TableHeaderCell>
- <TableHeaderCell>For</TableHeaderCell>
- <TableHeaderCell>Against</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {POLICIES.map(row => (
- <TableRow key={row.policy}>
- <TableCell>
- <VStack gap={1}>
- <Text weight="semibold">{row.policy}</Text>
- <Text type="supporting" color="secondary">
- {row.status}
- </Text>
- </VStack>
- </TableCell>
- <TableCell>
- <Text type="supporting">{row.survives}</Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {row.forIt}
- </Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {row.againstIt}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- {conflict != null && (
- <Card padding={4}>
- <VStack gap={2}>
- <HStack gap={2} vAlign="center" wrap="wrap">
- <Text weight="semibold">
- This is a change of published policy, not a bug fix
- </Text>
- <Badge variant="error" label="Reversal" />
- </HStack>
- <VStack gap={1} {...stylex.props(sx.quote)}>
- <Text type="supporting" color="secondary">
- &ldquo;{conflict.published}&rdquo; — {conflict.section},
- published today
- </Text>
- </VStack>
- <Text type="supporting">{conflict.reading}</Text>
- <Text type="supporting" color="secondary">
- {conflict.resolution}
- </Text>
- <Text type="supporting" color="secondary">
- <Link href="/motion/published">
- The conflicts, side by side
- </Link>{' '}
- ·{' '}
- <Link
- href={PUBLISHED_PAGE_URL}
- target="_blank"
- rel="noopener noreferrer">
- the published page
- </Link>
- </Text>
- </VStack>
- </Card>
- )}
- </VStack>
-
- <DemoCard
- title="The three policies, running"
- question="A spinner, a pulse and an indeterminate bar under each answer. Which of these still tells you the system is working?">
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — loops slow to 3s',
- content: <LoopRig policy="today" />,
- },
- {
- tone: 'neutral',
- label: 'Delete — the published answer',
- content: <LoopRig policy="delete" />,
- },
- {
- tone: 'after',
- label: 'Degrade — the proposed answer',
- content: <LoopRig policy="degrade" />,
- },
- ]}
- />
- <DemoBody>
- <Text type="supporting" color="secondary">
- Slowing a loop is the one answer nobody is arguing for and the one
- the code does today. Between the other two, the question is not
- whether the spinner keeps spinning — it does not, either way — but
- whether anything replaces it.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="Hover the rows, then flip the rail"
- question="The tint is state feedback that happens to be implemented as a transition. Does the policy take the feedback or only the fade?">
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Hardcoded 150ms',
- content: <TintRig mode="before" />,
- },
- {
- tone: 'after',
- label: 'Tokenised --duration-state',
- content: <TintRig mode="after" />,
- },
- ]}
- />
- <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
- movement, and this tint is exactly the feedback degrade exists to
- preserve — which is why delete is defensible on a hover tint and
- indefensible on a spinner, where the motion <em>is</em> the message.
- </Text>
- <Text type="supporting" color="secondary">
- The left pane makes the token argument at the same time: it
- hardcodes 150ms, so it fades identically under every policy. A
- 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
- survives. On <strong>Delete</strong> the tint snaps, and the
- affordance goes with it. That is the whole decision, in one hover.
- (This behaviour was itself a bug in the lab until the policy was
- moved out of the stylesheet: the store writes the duration aliases
- inline, and an inline custom property outranks any selector, so the
- delete rule looked right and did nothing.)
- </Text>
- </DemoBody>
- </DemoCard>
-
- <VStack gap={3}>
- <Heading level={2}>
- The <code>0.01s</code> finding
- </Heading>
- <Text color="secondary">
- {INSTANT_ESCAPES.length} of the {AUDIT_COUNTS.hardcodedTotal}{' '}
- hardcoded values are <code>0.01s</code>, and every one is a
- reduced-motion escape in BottomSheet, DateInput or MobileNav. This is
- load-bearing, not sloppiness: a zero duration fires no{' '}
- <code>transitionend</code>, so anything sequencing off that event — an
- unmount, a focus return, a scroll lock release — never runs. The idiom
- is a component author working around the platform.
- </Text>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Site</TableHeaderCell>
- <TableHeaderCell>Component</TableHeaderCell>
- <TableHeaderCell>Property</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {INSTANT_ESCAPES.map(site => (
- <TableRow key={`${site.file}:${site.line}`}>
- <TableCell>
- <Text
- {...stylex.props(
- sx.mono,
- )}>{`${site.file}:${site.line}`}</Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {site.component}
- </Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {site.prop}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- <Grid columns={{minWidth: 300}} gap={3}>
- <Card padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">
- <code>--duration-instant</code> cannot be assumed to be 0
- </Text>
- <Text type="supporting" color="secondary">
- Ship it as <code>0.01ms</code> and every existing sequencing
- path keeps working, at a cost no user can perceive. Ship it as{' '}
- <code>0</code> and these ten sites have to be rewritten to await
- something else in the same change — which is a different, larger
- piece of work than the sweep is scoped for.
- </Text>
- </VStack>
- </Card>
- <Card padding={4}>
- <VStack gap={1.5}>
- <Text weight="semibold">
- Decide it before the sweep, not during
- </Text>
- <Text type="supporting" color="secondary">
- The sweep rewrites these ten lines whichever way the token goes.
- Deciding halfway through means two idioms in the codebase and a
- lint rule that cannot tell which one it is looking at.
- </Text>
- </VStack>
- </Card>
- </Grid>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>The rule, as code</Heading>
- <Text color="secondary">
- What a component author copies. Movement is a multiplier so the policy
- lands in one place; loops stop rather than slow; hover motion is gated
- on a fine pointer because touch fires a hover on tap; and the
- attribute branch exists because an app with its own reduce-motion
- setting can flip a JS library but cannot flip a media query.
- </Text>
- <CodeBlock
- language="css"
- title="The degrade branch"
- code={CSS_RULE}
- hasCopyButton
- maxHeight={420}
- />
- <CodeBlock
- language="tsx"
- title="useReducedMotion() — the JS half of the same policy"
- code={HOOK}
- hasCopyButton
- maxHeight={420}
- />
- <Text type="supporting" color="secondary">
- Both halves ship together or the system disagrees with itself: a chart
- that animates while the interface around it has stopped is worse than
- either policy applied consistently.
- </Text>
- </VStack>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/rubric.tsx b/apps/sandbox/src/motion/pages/rubric.tsx
deleted file mode 100644
index c8047abcfd..0000000000
--- a/apps/sandbox/src/motion/pages/rubric.tsx
+++ /dev/null
@@ -1,743 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input rubric.ts, the generated audit, the published guidance
- * @output The rubric as a bench: every criterion with a pass and a fail running
- * @position /motion/rubric
- *
- * A rubric that is only a table gets read once and then argued about from
- * memory. Every criterion here that can be shown is shown, so "the exit is on
- * the wrong curve" is something you look at rather than something you take on
- * trust.
- */
-
-import type {ReactNode} from 'react';
-import * as stylex from '@stylexjs/stylex';
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Card} from '@astryxdesign/core/Card';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Link} from '@astryxdesign/core/Link';
-import {HStack, VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import {LabPage} from '../PageFrame';
-import {
- BudgetMeter,
- ComparePanes,
- DemoBody,
- DemoCard,
- Runner,
- TokenSlider,
-} from '../LabPrimitives';
-import {
- CheckTickRig,
- InterruptRig,
- LayerRig,
- LoopRig,
- OriginRig,
- OutlineMarkerRig,
- PressRig,
-} from '../LabDemos';
-import {
- AUDIT_COUNTS,
- HARDCODED_SITES,
- NO_REDUCED_MOTION,
- TRANSFORM_TRANSITIONS,
-} from '../__generated__/motionAudit';
-import {
- AUTOMATABLE_LABEL,
- GRANDFATHERING,
- MISSING_PRINCIPLE,
- PASS_BAR,
- RUBRIC_CRITERIA,
- SEVERITY_LABEL,
- SEVERITY_RULES,
- type Automatable,
- type Criterion,
- type Severity,
-} from '../rubric';
-
-const sx = stylex.create({
- full: {width: '100%'},
- mono: {fontFamily: 'var(--font-family-code)', fontSize: '12px'},
- verdict: {
- borderInlineStart: '2px solid var(--color-border)',
- paddingInlineStart: '10px',
- },
- pass: {borderInlineStartColor: 'var(--color-background-success, #3f9a6b)'},
- fail: {borderInlineStartColor: 'var(--color-background-error, #d3543f)'},
- quote: {
- borderInlineStart: '2px solid var(--color-border)',
- paddingInlineStart: '12px',
- maxWidth: '64ch',
- },
-});
-
-const SEVERITY_VARIANT: Readonly<
- Record<Severity, 'error' | 'warning' | 'neutral'>
-> = {
- blocker: 'error',
- 'should-fix': 'warning',
- polish: 'neutral',
-};
-
-const AUTOMATABLE_VARIANT: Readonly<
- Record<Automatable, 'success' | 'info' | 'neutral'>
-> = {
- yes: 'success',
- partly: 'info',
- no: 'neutral',
-};
-
-/** Only the criteria that can be watched get a rig; the rest say why not. */
-function demoFor(id: string): ReactNode {
- switch (id) {
- case 'frequency':
- return (
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label:
- 'Fails — a tick that draws itself, on a control used forty times in a form',
- content: <CheckTickRig technique="draw" />,
- },
- {
- tone: 'after',
- label: 'Passes — instant, because this is a 100+/day interaction',
- content: <CheckTickRig technique="hard" />,
- },
- ]}
- />
- );
- case 'semantic':
- return (
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Fails — exit duration on the entry curve',
- content: (
- <Runner
- durationToken="--duration-exit"
- easeToken="--ease-entry"
- />
- ),
- },
- {
- tone: 'after',
- label: 'Passes — exit duration on the exit curve',
- content: (
- <Runner
- durationToken="--duration-exit"
- easeToken="--ease-exit"
- />
- ),
- },
- ]}
- />
- );
- case 'budget':
- return (
- <DemoBody>
- <Runner durationToken="--duration-enter" easeToken="--ease-entry" />
- <TokenSlider
- token="--duration-enter"
- label="--duration-enter"
- min={0}
- max={900}
- />
- <BudgetMeter token="--duration-enter" />
- </DemoBody>
- );
- case 'compositor':
- return (
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Fails — animates top and height',
- content: <OutlineMarkerRig mode="before" />,
- },
- {
- tone: 'after',
- label: 'Passes — transform only',
- content: <OutlineMarkerRig mode="after" />,
- },
- ]}
- />
- );
- case 'presence':
- return (
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Fails the criterion — and follows the published page',
- content: (
- <LayerRig
- mode="before"
- label="No exit at all"
- triggerLabel="Hover me"
- />
- ),
- },
- {
- tone: 'after',
- label: 'Passes — exit retraces the entry, faster',
- content: (
- <LayerRig
- mode="after"
- label="Exits on --duration-exit"
- triggerLabel="Hover me"
- />
- ),
- },
- ]}
- />
- );
- case 'origin':
- return (
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Fails — scale(0)',
- content: <OriginRig kind="zero" />,
- },
- {
- tone: 'neutral',
- label: 'Half right — 0.94, wrong origin',
- content: <OriginRig kind="centre" />,
- },
- {
- tone: 'after',
- label: 'Passes — anchored to the trigger',
- content: <OriginRig kind="anchored" />,
- },
- ]}
- />
- );
- case 'interruptible':
- return (
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Fails — a keyframe restarts from zero',
- content: <InterruptRig mode="before" />,
- },
- {
- tone: 'after',
- label: 'Passes — a transition retargets',
- content: <InterruptRig mode="after" />,
- },
- ]}
- />
- );
- case 'reduced-motion':
- return (
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — loops slow to 3s',
- content: <LoopRig policy="today" />,
- },
- {
- tone: 'neutral',
- label: 'Delete — what the published page says',
- content: <LoopRig policy="delete" />,
- },
- {
- tone: 'after',
- label: 'Degrade — what the criterion says',
- content: <LoopRig policy="degrade" />,
- },
- ]}
- />
- );
- case 'library':
- return (
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Fails — transition on transform',
- content: <PressRig technique="transform" />,
- },
- {
- tone: 'after',
- label: 'Passes — press on the scale property',
- content: <PressRig technique="scale" />,
- },
- ]}
- />
- );
- default:
- return null;
- }
-}
-
-function Verdict({
- tone,
- label,
- text,
-}: {
- tone: 'pass' | 'fail';
- label: string;
- text: string;
-}) {
- return (
- <VStack
- gap={0.5}
- {...stylex.props(sx.verdict, tone === 'pass' ? sx.pass : sx.fail)}>
- <Text type="supporting" weight="semibold">
- {label}
- </Text>
- <Text type="supporting" color="secondary">
- {text}
- </Text>
- </VStack>
- );
-}
-
-function CriterionCard({criterion}: {criterion: Criterion}) {
- const demo = demoFor(criterion.id);
- return (
- <DemoCard
- title={`${criterion.n}. ${criterion.title}`}
- question={criterion.rule}
- badges={
- <>
- <Badge
- variant={SEVERITY_VARIANT[criterion.severity]}
- label={SEVERITY_LABEL[criterion.severity]}
- />
- <Badge
- variant={AUTOMATABLE_VARIANT[criterion.automatable]}
- label={AUTOMATABLE_LABEL[criterion.automatable]}
- />
- {criterion.guidance === 'reversal' && (
- <Badge variant="error" label="Reverses published guidance" />
- )}
- {criterion.guidance === 'aligned' && (
- <Badge variant="success" label="Already published" />
- )}
- </>
- }>
- <DemoBody>
- <Grid columns={{minWidth: 260}} gap={3}>
- <Verdict tone="pass" label="Passes" text={criterion.pass} />
- <Verdict tone="fail" label="Fails" text={criterion.fail} />
- </Grid>
- <Text type="supporting" color="secondary">
- <strong>Checked by: </strong>
- {criterion.check}
- {criterion.severityNote != null ? ` ${criterion.severityNote}` : ''}
- </Text>
- {criterion.evidence != null && (
- <Text type="supporting" color="secondary">
- <strong>Measured: </strong>
- {criterion.evidence}
- </Text>
- )}
- {criterion.guidanceNote != null && (
- <Text type="supporting" color="secondary">
- <strong>
- {criterion.guidance === 'reversal'
- ? 'Contradicts the published Motion page: '
- : 'Cites the published Motion page: '}
- </strong>
- {criterion.guidanceNote}{' '}
- <Link href="/motion/published">See the conflicts</Link>
- </Text>
- )}
- </DemoBody>
- {demo}
- </DemoCard>
- );
-}
-
-/** The reduced-motion worklist, collapsed to components so it fits on a card. */
-const REDUCED_BY_COMPONENT = [
- ...NO_REDUCED_MOTION.reduce((acc, row) => {
- acc.set(row.component, (acc.get(row.component) ?? 0) + 1);
- return acc;
- }, new Map<string, number>()),
-].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
-
-const MULTI_PROPERTY_TRANSFORMS = TRANSFORM_TRANSITIONS.filter(
- site => site.decl?.includes(',') === true,
-).length;
-
-const INSTANT_ESCAPES = HARDCODED_SITES.filter(
- site => site.value === '0.01s',
-).length;
-
-const TABLE_TINTS = HARDCODED_SITES.filter(
- site => site.value === '150ms' && site.component === 'Table',
-).length;
-
-export default function MotionRubricPage() {
- const mechanical = RUBRIC_CRITERIA.filter(c => c.automatable === 'yes');
- const blockers = RUBRIC_CRITERIA.filter(c => c.severity === 'blocker');
- const reversals = RUBRIC_CRITERIA.filter(c => c.guidance === 'reversal');
-
- return (
- <LabPage
- title="Rubric bench"
- intro="Twelve criteria, each with a pass and a fail you can watch. Astryx already gates lab-to-core promotion on an accessibility checklist; motion works the same way or it does not work at all — published, graded per component, tracked."
- badges={
- <Badge variant="info" label={`${RUBRIC_CRITERIA.length} criteria`} />
- }
- decides="Whether each criterion is checkable, and what a pass and a fail look like.">
- <Banner
- status="warning"
- title="The brief says ten graded criteria. Its own table has twelve."
- description={
- <Text>
- Twelve is what the table describes and twelve is what is graded
- here. Fix the number in Deliverables before publication — a count in
- a deliverable is the thing that gets quoted back in a review, and
- nobody recounts the table. Criteria{' '}
- {reversals.map(c => c.n).join(' and ')} reverse guidance the
- published Motion page gives today, so the rubric cannot gate on
- either until that page is rewritten.
- </Text>
- }
- endContent={<Link href="/motion/published">The conflicts</Link>}
- />
-
- <VStack gap={3}>
- <Heading level={2}>How it grades</Heading>
- <Text color="secondary">{PASS_BAR}</Text>
- <Card padding={0}>
- <Table density="balanced">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Severity</TableHeaderCell>
- <TableHeaderCell>What it means</TableHeaderCell>
- <TableHeaderCell>Effect on the gate</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {SEVERITY_RULES.map(row => (
- <TableRow key={row.severity}>
- <TableCell>
- <Badge
- variant={SEVERITY_VARIANT[row.severity]}
- label={SEVERITY_LABEL[row.severity]}
- />
- </TableCell>
- <TableCell>
- <Text type="supporting">{row.meaning}</Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {row.gate}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- <Text type="supporting" color="secondary">
- Blockers: {blockers.length} of {RUBRIC_CRITERIA.length}. Mechanical
- today: {mechanical.length}. A component with two open should-fix items
- still passes; a third stops it, which is what keeps the second one
- from becoming permanent.
- </Text>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>The twelve</Heading>
- {RUBRIC_CRITERIA.map(criterion => (
- <CriterionCard key={criterion.id} criterion={criterion} />
- ))}
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>What the rubric would have caught</Heading>
- <Text color="secondary">
- Measured against <code>@astryxdesign/core</code> by the audit script,
- not read out of the brief. These are the rows a reviewer would have
- been handed on the day the component landed.
- </Text>
-
- <DemoCard
- title="Criterion 6 — compositor-only"
- question={`${AUDIT_COUNTS.transformTransitions} transform transitions across ${AUDIT_COUNTS.transformTransitionComponents} components. Every one of them is also a criterion-12 finding.`}>
- <DemoBody>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Site</TableHeaderCell>
- <TableHeaderCell>Declaration</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {TRANSFORM_TRANSITIONS.slice(0, 6).map(site => (
- <TableRow key={`${site.file}:${site.line}`}>
- <TableCell>
- <Text
- {...stylex.props(
- sx.mono,
- )}>{`${site.file}:${site.line}`}</Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {site.decl}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- <Text type="supporting" color="secondary">
- {MULTI_PROPERTY_TRANSFORMS} of these declare{' '}
- <code>transform</code> inside a longer property list rather than
- on its own, so a grep for{' '}
- <code>transitionProperty: &lsquo;transform&rsquo;</code> finds
- barely half of them. That is worth knowing before anyone scopes
- criterion 12 from a search —{' '}
- <Link href="/motion/bugs">the bugs page has the whole list</Link>,
- and the count has already moved twice as the scanner improved.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="Criterion 10 — reduced motion"
- question={`${AUDIT_COUNTS.filesWithoutReducedMotion} of ${AUDIT_COUNTS.animatedFiles} animated files have no reduced-motion branch. This is the sweep.`}>
- <DemoBody>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Component</TableHeaderCell>
- <TableHeaderCell>Files with no branch</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {REDUCED_BY_COMPONENT.slice(0, 6).map(
- ([component, count]) => (
- <TableRow key={component}>
- <TableCell>
- <Text>{component}</Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {count}
- </Text>
- </TableCell>
- </TableRow>
- ),
- )}
- </TableBody>
- </Table>
- </Card>
- <Text type="supporting" color="secondary">
- Table alone accounts for {REDUCED_BY_COMPONENT[0]?.[1]} of the{' '}
- {AUDIT_COUNTS.filesWithoutReducedMotion}.{' '}
- <Link href="/motion/reduced-motion">
- The full worklist is on the reduced-motion page
- </Link>
- , where it also has to wait on degrade-or-delete: the sweep writes
- whichever answer wins {AUDIT_COUNTS.filesWithoutReducedMotion}{' '}
- times.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <DemoCard
- title="Criterion 3 — token fidelity"
- question={`${AUDIT_COUNTS.hardcodedTotal} hardcoded values: ${AUDIT_COUNTS.hardcodedDuration} durations, ${AUDIT_COUNTS.hardcodedEasing} curves. The brief budgeted for 28.`}>
- <DemoBody>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Site</TableHeaderCell>
- <TableHeaderCell>Property</TableHeaderCell>
- <TableHeaderCell>Value</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {[
- 'Table/plugins/columnResize/useTableColumnResize.tsx',
- 'BottomSheet/BottomSheetPanel.tsx',
- 'StatusDot/StatusDot.tsx',
- 'Chat/ChatMessageMetadata.tsx',
- 'hooks/useKeyboardHint.tsx',
- 'Button/Button.tsx',
- ]
- .map(file =>
- HARDCODED_SITES.find(site => site.file === file),
- )
- .filter(
- (site): site is (typeof HARDCODED_SITES)[number] =>
- site != null,
- )
- .map(site => (
- <TableRow key={`${site.file}:${site.line}:${site.prop}`}>
- <TableCell>
- <Text
- {...stylex.props(
- sx.mono,
- )}>{`${site.file}:${site.line}`}</Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {site.prop}
- </Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)}>{site.value}</Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- <Text type="supporting" color="secondary">
- Not all of them are carelessness: {INSTANT_ESCAPES} are the{' '}
- <code>0.01s</code> reduced-motion escape and {TABLE_TINTS} are the
- same 150ms tint in Table. The rubric would have caught every one
- at review time, which is the argument for the lint rule rather
- than the sweep.
- </Text>
- </DemoBody>
- </DemoCard>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Automatable?</Heading>
- <Text color="secondary">
- {mechanical.length} of {RUBRIC_CRITERIA.length} are mechanical today —{' '}
- {mechanical.map(c => c.n).join(', ')}. Five more can be narrowed by
- lint to a question a reviewer answers in one line. Three are judgement
- and always will be.
- </Text>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>#</TableHeaderCell>
- <TableHeaderCell>Criterion</TableHeaderCell>
- <TableHeaderCell>Automatable</TableHeaderCell>
- <TableHeaderCell>What checks it</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {RUBRIC_CRITERIA.map(c => (
- <TableRow key={c.id}>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {c.n}
- </Text>
- </TableCell>
- <TableCell>
- <Text weight="semibold">{c.title}</Text>
- </TableCell>
- <TableCell>
- <Badge
- variant={AUTOMATABLE_VARIANT[c.automatable]}
- label={AUTOMATABLE_LABEL[c.automatable]}
- />
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {c.check}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Grandfathering</Heading>
- <Text color="secondary">
- The rubric is worth nothing if it fails 48 animating components on the
- day it lands, and worth nothing if it never fails anything. This is
- the split.
- </Text>
- <Card padding={0}>
- <Table density="balanced">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Situation</TableHeaderCell>
- <TableHeaderCell>Rule</TableHeaderCell>
- <TableHeaderCell>Why</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {GRANDFATHERING.map(row => (
- <TableRow key={row.situation}>
- <TableCell>
- <Text weight="semibold">{row.situation}</Text>
- </TableCell>
- <TableCell>
- <Text type="supporting">{row.rule}</Text>
- </TableCell>
- <TableCell>
- <Text type="supporting" color="secondary">
- {row.why}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>A principle the rubric drops</Heading>
- <Card padding={4}>
- <VStack gap={2}>
- <HStack gap={2} vAlign="center" wrap="wrap">
- <Text weight="semibold">{MISSING_PRINCIPLE.title}</Text>
- <Badge variant="warning" label="Published, ungraded" />
- </HStack>
- <VStack gap={1} {...stylex.props(sx.quote)}>
- <Text type="supporting" color="secondary">
- &ldquo;{MISSING_PRINCIPLE.published}&rdquo;
- </Text>
- </VStack>
- <Text type="supporting">{MISSING_PRINCIPLE.gap}</Text>
- <Text type="supporting" color="secondary">
- {MISSING_PRINCIPLE.measuredAgainst}
- </Text>
- <Text type="supporting">
- <strong>Recommendation: </strong>
- {MISSING_PRINCIPLE.recommendation}
- </Text>
- <Text type="supporting" color="secondary">
- <Link href="/motion/published">
- The published page against the proposal, conflict by conflict
- </Link>
- </Text>
- </VStack>
- </Card>
- </VStack>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/springs.tsx b/apps/sandbox/src/motion/pages/springs.tsx
deleted file mode 100644
index ddd278276b..0000000000
--- a/apps/sandbox/src/motion/pages/springs.tsx
+++ /dev/null
@@ -1,467 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input SPRINGS from motionTokens, the spring model, the lab store
- * @output The four named springs, tunable, beside the CSS pair for the same gesture
- * @position /motion/springs
- *
- * Springs are the only part of the proposal with no CSS representation, so
- * they live in the JS mirror rather than the token file. That is not a
- * technicality: a spring is what gesture-driven and interruptible motion
- * needs, because it carries velocity through an interruption where a keyframe
- * restarts from zero.
- *
- * The runner and the plot use the lab's CSS module classes rather than local
- * styles so a spring-driven box and a token-driven <Runner> are pixel
- * identical — the comparison is only honest if the only difference is timing.
- */
-
-import {useCallback, useRef, useState} from 'react';
-import * as stylex from '@stylexjs/stylex';
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Button} from '@astryxdesign/core/Button';
-import {CodeBlock} from '@astryxdesign/core/CodeBlock';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Link} from '@astryxdesign/core/Link';
-import {MetadataList, MetadataListItem} from '@astryxdesign/core/MetadataList';
-import {VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {
- SegmentedControl,
- SegmentedControlItem,
-} from '@astryxdesign/core/SegmentedControl';
-import {LabPage} from '../PageFrame';
-import {DemoBody, DemoCard, LabSlider, Runner, useLoop} from '../LabPrimitives';
-import {useMotionLab} from '../MotionLabStore';
-import {SPRINGS} from '../motionTokens';
-import {createSpring, plotPath} from '../spring';
-import styles from '../MotionLab.module.css';
-
-const sx = stylex.create({
- full: {width: '100%'},
- mono: {fontFamily: 'var(--font-family-code)'},
- prose: {maxWidth: '72ch'},
-});
-
-/** Bounce above this stops reading as a crisp library. Rubric criterion 11. */
-const CRISP_BOUNCE_CEILING = 0.3;
-
-const PLOT_WIDTH = 380;
-const PLOT_HEIGHT = 148;
-const PLOT_PAD = 18;
-/** Plot past the nominal duration so the overshoot is visible, not clipped. */
-const PLOT_TAIL = 1.5;
-
-function pct(value: number): string {
- return `${(value * 100).toFixed(1)}%`;
-}
-
-/**
- * The spring's position over time. The dashed line is the target: everything
- * above it is overshoot, and the vertical mark is where the nominal duration
- * ends — a light spring is still moving there, which is the thing the number
- * in the readout is measuring.
- */
-function SpringPlot({duration, bounce}: {duration: number; bounce: number}) {
- const spring = createSpring(duration, bounce);
- const span = spring.duration * PLOT_TAIL;
- const yMin = -0.08;
- const yMax = Math.max(1.2, spring.overshoot() + 0.1);
- const toY = (y: number) =>
- PLOT_HEIGHT -
- PLOT_PAD -
- ((y - yMin) / (yMax - yMin)) * (PLOT_HEIGHT - PLOT_PAD * 2);
- const nominalX = PLOT_PAD + (1 / PLOT_TAIL) * (PLOT_WIDTH - PLOT_PAD * 2);
-
- return (
- <svg
- className={styles.curveCanvas}
- width={PLOT_WIDTH}
- height={PLOT_HEIGHT}
- viewBox={`0 0 ${PLOT_WIDTH} ${PLOT_HEIGHT}`}
- role="img"
- aria-label={`Spring position over time, duration ${duration} seconds, bounce ${bounce}`}>
- <line
- x1={PLOT_PAD}
- y1={toY(1)}
- x2={PLOT_WIDTH - PLOT_PAD}
- y2={toY(1)}
- stroke="var(--color-border)"
- strokeDasharray="3 3"
- />
- <line
- x1={nominalX}
- y1={PLOT_PAD}
- x2={nominalX}
- y2={PLOT_HEIGHT - PLOT_PAD}
- stroke="var(--color-text-tertiary, #8a8a8a)"
- strokeDasharray="2 4"
- />
- <path
- d={plotPath(
- x => spring.sample(x * span),
- PLOT_WIDTH,
- PLOT_HEIGHT,
- PLOT_PAD,
- yMin,
- yMax,
- )}
- fill="none"
- stroke="var(--color-brand)"
- strokeWidth={2}
- />
- </svg>
- );
-}
-
-/**
- * A box driven by the spring itself rather than by a duration token, which is
- * why it cannot be the shared <Runner>: the timing comes from the sampled
- * curve, and only the slow-mo multiplier is shared with the rest of the lab.
- */
-function SpringRunner({duration, bounce}: {duration: number; bounce: number}) {
- const {speed, reducedMotion} = useMotionLab();
- const dotRef = useRef<HTMLSpanElement | null>(null);
- const trackRef = useRef<HTMLDivElement | null>(null);
-
- const run = useCallback(() => {
- const dot = dotRef.current;
- const track = trackRef.current;
- if (dot == null || track == null) {
- return;
- }
- for (const animation of dot.getAnimations()) {
- animation.cancel();
- }
- const spring = createSpring(duration, bounce);
- // Short of the far edge, so an overshooting spring is not clipped by the
- // track it is travelling in.
- const distance = Math.max(0, track.clientWidth - 52);
- // A spring is movement, which is the first thing either reduced-motion
- // policy removes — so the box arrives rather than travels.
- const isInstant = reducedMotion !== 'off';
- dot.animate(
- [{transform: 'translateX(0)'}, {transform: `translateX(${distance}px)`}],
- {
- duration: isInstant ? 1 : Math.max(1, spring.duration * 1000 * speed),
- easing: isInstant ? 'linear' : spring.linear(),
- fill: 'both',
- },
- );
- }, [bounce, duration, reducedMotion, speed]);
-
- useLoop(run, duration * 1000 * speed + 900);
-
- return (
- <div ref={trackRef} className={styles.runner}>
- <span ref={dotRef} className={styles.runnerDot} />
- </div>
- );
-}
-
-/**
- * The same spring, retargeted mid-flight. The box picks up from wherever it
- * is but from a standstill, because a sampled curve has no velocity to carry.
- * A real spring integrator does — which is the argument for the JS spring
- * over the CSS fallback for anything gesture-driven.
- */
-function InterruptDemo({duration, bounce}: {duration: number; bounce: number}) {
- const {speed, reducedMotion} = useMotionLab();
- const [isOut, setOut] = useState(false);
- const dotRef = useRef<HTMLSpanElement | null>(null);
- const trackRef = useRef<HTMLDivElement | null>(null);
-
- const toggle = useCallback(() => {
- const dot = dotRef.current;
- const track = trackRef.current;
- if (dot == null || track == null) {
- return;
- }
- const next = !isOut;
- setOut(next);
- const spring = createSpring(duration, bounce);
- const distance = Math.max(0, track.clientWidth - 52);
- // The running animation does not commit its value, so the position has to
- // be read off the box before it is cancelled.
- const matrix = new DOMMatrixReadOnly(
- window.getComputedStyle(dot).transform,
- );
- for (const animation of dot.getAnimations()) {
- animation.cancel();
- }
- const isInstant = reducedMotion !== 'off';
- dot.animate(
- [
- {transform: `translateX(${matrix.m41}px)`},
- {transform: `translateX(${next ? distance : 0}px)`},
- ],
- {
- duration: isInstant ? 1 : Math.max(1, spring.duration * 1000 * speed),
- easing: isInstant ? 'linear' : spring.linear(),
- fill: 'both',
- },
- );
- }, [bounce, duration, isOut, reducedMotion, speed]);
-
- return (
- <VStack gap={2} {...stylex.props(sx.full)}>
- <div ref={trackRef} className={styles.runner}>
- <span ref={dotRef} className={styles.runnerDot} />
- </div>
- <Button
- size="sm"
- variant="secondary"
- label="Send it back — press twice, fast"
- onClick={toggle}
- />
- </VStack>
- );
-}
-
-function SpringCard({
- name,
- use,
- cssCounterpart,
-}: {
- name: string;
- use: string;
- cssCounterpart: readonly [string, string];
-}) {
- const {springs, setSpring} = useMotionLab();
- const tuned = springs[name];
- const spring = createSpring(tuned.duration, tuned.bounce);
- const isBouncy = tuned.bounce > CRISP_BOUNCE_CEILING;
-
- return (
- <DemoCard
- title={name}
- question={use}
- badges={
- isBouncy ? (
- <Badge
- variant="warning"
- label={`bounce ${tuned.bounce.toFixed(2)} — past crisp`}
- />
- ) : (
- <Badge
- label={`${Math.round(tuned.duration * 1000)}ms · bounce ${tuned.bounce.toFixed(2)}`}
- />
- )
- }>
- <DemoBody>
- <SpringPlot duration={tuned.duration} bounce={tuned.bounce} />
- <VStack gap={1} {...stylex.props(sx.full)}>
- <Text type="supporting" color="secondary">
- spring — <code>{name}</code>
- </Text>
- <SpringRunner duration={tuned.duration} bounce={tuned.bounce} />
- <Text type="supporting" color="secondary">
- CSS counterpart — <code>{cssCounterpart[0]}</code> +{' '}
- <code>{cssCounterpart[1]}</code>
- </Text>
- <Runner
- durationToken={cssCounterpart[0]}
- easeToken={cssCounterpart[1]}
- />
- </VStack>
- <LabSlider
- label="Duration"
- value={tuned.duration}
- min={0.1}
- max={1.2}
- step={0.05}
- format={v => `${v.toFixed(2)}s`}
- onChange={v => setSpring(name, {duration: v, bounce: tuned.bounce})}
- />
- <LabSlider
- label="Bounce"
- value={tuned.bounce}
- min={0}
- max={0.6}
- step={0.05}
- format={v => v.toFixed(2)}
- onChange={v => setSpring(name, {duration: tuned.duration, bounce: v})}
- />
- <MetadataList columns={2} label={{position: 'top'}}>
- <MetadataListItem label="Duration">
- <Text {...stylex.props(sx.mono)}>
- {spring.duration.toFixed(2)}s
- </Text>
- </MetadataListItem>
- <MetadataListItem label="Bounce">
- <Text {...stylex.props(sx.mono)}>{spring.bounce.toFixed(2)}</Text>
- </MetadataListItem>
- <MetadataListItem label="Overshoot">
- <Text {...stylex.props(sx.mono)}>
- {pct(spring.overshoot() - 1)}
- </Text>
- </MetadataListItem>
- <MetadataListItem label="At nominal duration">
- <Text {...stylex.props(sx.mono)}>{pct(spring.settle())}</Text>
- </MetadataListItem>
- <MetadataListItem label="Stiffness">
- <Text {...stylex.props(sx.mono)}>{spring.stiffness}</Text>
- </MetadataListItem>
- <MetadataListItem label="Damping">
- <Text {...stylex.props(sx.mono)}>{spring.damping}</Text>
- </MetadataListItem>
- </MetadataList>
- </DemoBody>
- </DemoCard>
- );
-}
-
-export default function MotionSpringsPage() {
- const {springs} = useMotionLab();
- const [escapeHatch, setEscapeHatch] = useState<string>(SPRINGS[0].name);
- const hatch = springs[escapeHatch];
- const hatchSpring = createSpring(hatch.duration, hatch.bounce);
- const bouncy = SPRINGS.filter(
- s => springs[s.name].bounce > CRISP_BOUNCE_CEILING,
- );
-
- return (
- <LabPage
- title="Springs"
- intro="A spring is described by duration and bounce, not by a curve, and it has no CSS representation at all — which is why the proposal keeps springs in the JS mirror rather than the token file. What they buy is interruption: a spring carries velocity through a change of target, where a keyframe restarts from zero. That is the whole case for having them, and it only pays off in gesture-driven and interruptible motion."
- decides="Whether the four named springs feel right, and whether they belong in the theme contract."
- badges={<Badge variant="info" label="JS mirror only — no CSS form" />}>
- <Banner
- status={bouncy.length > 0 ? 'warning' : 'info'}
- title={
- bouncy.length > 0
- ? `${bouncy.length} spring(s) tuned past bounce 0.3`
- : 'Bounce belongs in 0.1–0.3 for a crisp library'
- }
- description={
- <Text>
- Rubric criterion 11 is that visible bounce is for drag-to-dismiss
- and playful moments; a dashboard stays crisp. Every slider below
- runs to 0.6 on purpose. At bounce {CRISP_BOUNCE_CEILING} the box
- passes its target by{' '}
- {pct(createSpring(0.4, CRISP_BOUNCE_CEILING).overshoot() - 1)} and
- settles back; at 0.6 it passes by{' '}
- {pct(createSpring(0.4, 0.6).overshoot() - 1)} and reads as a toy.
- Overshoot depends only on bounce, not on duration, so this is the
- one number worth arguing about — and it is easier to agree on by
- looking than by reading it.
- </Text>
- }
- />
-
- <Grid columns={{minWidth: 420}} gap={4}>
- {SPRINGS.map(spec => (
- <SpringCard
- key={spec.name}
- name={spec.name}
- use={spec.use}
- cssCounterpart={spec.cssCounterpart}
- />
- ))}
- </Grid>
-
- <DemoCard
- title="What the preview actually is"
- question="An approximation, and it is worth knowing where it stops being one."
- badges={<Badge label="honest about the model" />}>
- <DemoBody>
- <Text color="secondary" {...stylex.props(sx.prose)}>
- Motion describes a spring as duration and bounce. This lab
- reproduces that as a damped harmonic oscillator — bounce maps to the
- damping ratio, duration to the settle time — and then samples the
- curve into a CSS <code>linear()</code> easing so a plain transition
- can play it. Close enough to judge feel, and to argue about whether
- 0.2 belongs in a crisp library.
- </Text>
- <Text color="secondary" {...stylex.props(sx.prose)}>
- The sampled curve is also the escape hatch: a component that cannot
- take a JS dependency can still run the spring shape from CSS. What
- it cannot do is interruption. Press the button below twice in quick
- succession — the box retargets from wherever it is, but from a
- standstill, because a curve has no velocity to carry. A real spring
- integrator does. So the fallback is for shape, and gesture work
- wants the JS spring.
- </Text>
- <InterruptDemo duration={hatch.duration} bounce={hatch.bounce} />
- <SegmentedControl
- label="Which spring to emit"
- size="sm"
- value={escapeHatch}
- onChange={value => setEscapeHatch(value as string)}>
- {SPRINGS.map(spec => (
- <SegmentedControlItem
- key={spec.name}
- value={spec.name}
- label={spec.name}
- />
- ))}
- </SegmentedControl>
- <CodeBlock
- language="css"
- title={`${escapeHatch} — CSS fallback, sampled from the spring`}
- hasCopyButton
- isWrapped
- maxHeight={220}
- code={`/* No JS dependency. Shape only: an interruption restarts from rest. */
-.thing {
- transition-property: transform;
- transition-duration: ${Math.round(hatchSpring.duration * 1000)}ms;
- transition-timing-function: ${hatchSpring.linear(16)};
-}`}
- />
- <Text type="supporting" color="secondary">
- Sampled at 16 points here so it is readable; the mirror emits 64.
- Overshoot {pct(hatchSpring.overshoot() - 1)}, which is the part a
- cubic-bezier cannot express without going out of its 0–1 box.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <VStack gap={3}>
- <Heading level={2}>
- Open question: should springs be theme-tunable?
- </Heading>
- <Text color="secondary" {...stylex.props(sx.prose)}>
- A theme already retunes the whole duration scale from three numbers —
- a snappy theme sets{' '}
- <code>{'{fast: 100, medium: 250, ratio: 0.75}'}</code> and every
- primitive moves with it. Springs have no such axis, so today they are
- the same everywhere no matter what the theme says. If one theme is
- meant to feel bouncier than another, springs belong in the theme
- contract alongside the duration scale — and adding them after the
- contract ships is a breaking change to it. This wants deciding before
- the token work lands, not after.
- </Text>
- <CodeBlock
- language="ts"
- title="packages/core/src/theme/expandMotionScale.ts — the axis today, and the question"
- hasCopyButton
- code={`export interface MotionScaleConfig {
- fast: number; // 175 — micro-interactions
- medium: number; // 410 — entrance and exit
- slow?: number; // 975 — continuous
- ratio: number; // 0.75 — min = base × ratio, max = base ÷ ratio
- easing?: string; // overrides --ease-standard
-
- // Proposed, and the decision this page is asking for. Optional is not the
- // same as cheap: once themes ship without it, a theme author who tunes
- // duration and finds springs unmoved has been told the contract covers
- // motion when it covers only half of it.
- spring?: Record<'press' | 'swap' | 'panel' | 'layout', {duration: number; bounce: number}>;
-}`}
- />
- <Text type="supporting" color="secondary">
- Springs are defined natively in the mirror rather than parsed out of
- CSS, since they have no CSS form to parse. See{' '}
- <Link href="/motion/js-mirror">JS token mirror</Link> for the emitted
- shape and <Link href="/motion/export">Export tuning</Link> for what
- ships.
- </Text>
- </VStack>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/tokens.tsx b/apps/sandbox/src/motion/pages/tokens.tsx
deleted file mode 100644
index 5b12ce55f0..0000000000
--- a/apps/sandbox/src/motion/pages/tokens.tsx
+++ /dev/null
@@ -1,441 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input motionTokens, the lab store, Core components
- * @output The semantic token proposal, tunable
- * @position /motion/tokens
- *
- * The page the rest of the lab depends on: every control here writes a real
- * custom property, so a curve settled on this page is the curve every demo in
- * every other section is already using.
- */
-
-import * as stylex from '@stylexjs/stylex';
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Card} from '@astryxdesign/core/Card';
-import {CodeBlock} from '@astryxdesign/core/CodeBlock';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Link} from '@astryxdesign/core/Link';
-import {HStack, VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import {LabPage} from '../PageFrame';
-import {
- BudgetMeter,
- ComparePanes,
- CurveEditor,
- DemoBody,
- DemoCard,
- Runner,
- TokenSlider,
- isNamedCurve,
-} from '../LabPrimitives';
-import {useMotionLab} from '../MotionLabStore';
-import {
- CURRENT_EASE,
- PRIMITIVE_DURATIONS,
- SEMANTIC_DURATIONS,
- SEMANTIC_EASES,
- STAGGERS,
-} from '../motionTokens';
-import {HARDCODED_SITES} from '../__generated__/motionAudit';
-
-const sx = stylex.create({
- full: {width: '100%'},
- mono: {fontFamily: 'var(--font-family-code)'},
- jobRow: {maxWidth: '46ch'},
-});
-
-const CURVE_PRESETS = [
- ['ease-out', 'cubic-bezier(0, 0, 0.58, 1)'],
- ['iOS', 'cubic-bezier(0.32, 0.72, 0, 1)'],
- ['expo-out', 'cubic-bezier(0.16, 1, 0.3, 1)'],
-] as const;
-
-/** The duration each curve is best judged at — a linear curve needs a long run. */
-function previewDuration(easeName: string): string {
- if (easeName === '--ease-linear') {
- return '--duration-continuous';
- }
- if (easeName === '--ease-drawer') {
- return '--duration-overlay';
- }
- if (easeName === '--ease-move') {
- return '--duration-reveal';
- }
- return '--duration-enter';
-}
-
-/** Which curve reads best against a given duration, for the duration cards. */
-function pairedEase(durationName: string): string {
- switch (durationName) {
- case '--duration-exit':
- return '--ease-exit';
- case '--duration-continuous':
- return '--ease-linear';
- case '--duration-reveal':
- return '--ease-move';
- case '--duration-overlay':
- return '--ease-drawer';
- default:
- return '--ease-entry';
- }
-}
-
-export default function MotionTokensPage() {
- const {rawToken, setToken} = useMotionLab();
- const exitCurveSite = HARDCODED_SITES.find(
- s => s.component === 'BottomSheet' && s.value.startsWith('cubic-bezier'),
- );
-
- return (
- <LabPage
- title="Semantic motion tokens"
- intro="The current scale names sizes. An author choosing between --duration-fast-max and --duration-medium-min is guessing, because neither name says what it is for. The proposal keeps the primitive scale exactly as it is and adds a semantic layer on top, the way colour already works."
- decides="Whether six easings and eight durations are the right vocabulary, and what each value should be."
- badges={
- <Badge variant="info" label="every control writes a real token" />
- }>
- <Banner
- status="info"
- title="One curve is doing three jobs"
- description={
- <Text>
- Core ships exactly one easing token,{' '}
- <code>
- {CURRENT_EASE.name}: {CURRENT_EASE.value}
- </code>
- , and it covers entry, exit and state at once. The codebase has
- already discovered this and worked around it locally — with a
- comment measuring why.
- {exitCurveSite != null && (
- <>
- {' '}
- <code>
- {exitCurveSite.file}:{exitCurveSite.line}
- </code>{' '}
- authors <code>{exitCurveSite.value}</code> by hand for the
- sheet&rsquo;s exit.
- </>
- )}
- </Text>
- }
- />
-
- <DemoCard
- title="The same three jobs, one curve and six"
- question="Watch the exit lane. On the standard curve a leaving surface spends its travel immediately and then coasts, which is right for an arrival and wrong for a departure."
- badges={<Badge variant="neutral" label="run at 4× to judge" />}>
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — --ease-standard for all three',
- content: (
- <VStack gap={2} {...stylex.props(sx.full)}>
- {(
- [
- ['Arriving', '--duration-enter'],
- ['Leaving', '--duration-exit'],
- ['Moving', '--duration-reveal'],
- ] as const
- ).map(([label, duration]) => (
- <VStack key={label} gap={1} {...stylex.props(sx.full)}>
- <Text type="supporting" color="secondary">
- {label}
- </Text>
- <Runner
- durationToken={duration}
- easeToken="--ease-standard-today"
- />
- </VStack>
- ))}
- </VStack>
- ),
- },
- {
- tone: 'after',
- label: 'Proposed — the curve names the job',
- content: (
- <VStack gap={2} {...stylex.props(sx.full)}>
- {(
- [
- ['Arriving', '--duration-enter', '--ease-entry'],
- ['Leaving', '--duration-exit', '--ease-exit'],
- ['Moving', '--duration-reveal', '--ease-move'],
- ] as const
- ).map(([label, duration, ease]) => (
- <VStack key={label} gap={1} {...stylex.props(sx.full)}>
- <Text type="supporting" color="secondary">
- {label} — <code>{ease}</code>
- </Text>
- <Runner durationToken={duration} easeToken={ease} />
- </VStack>
- ))}
- </VStack>
- ),
- },
- ]}
- />
- <DemoBody>
- <Text type="supporting" color="secondary">
- The sheet needed its own curve because the standard one, measured on
- device, “put the sheet half off-screen in 59ms of a 410ms close and
- 90% off in 163ms — the travel is over before the eye has followed
- it”. That comment, already in the codebase, is the specification for{' '}
- <code>--ease-exit</code>. Promoting it is not a new idea; it is the
- second time someone has needed it.
- </Text>
- </DemoBody>
- </DemoCard>
-
- <VStack gap={3}>
- <Heading level={2}>Easing</Heading>
- <Text color="secondary">
- Drag a control point and every demo in the lab moves with it. Arrow
- keys nudge; hold shift for a bigger step.
- </Text>
- <Grid columns={{minWidth: 420}} gap={4}>
- {SEMANTIC_EASES.map(ease => {
- const duration = previewDuration(ease.name);
- const value = rawToken(ease.name);
- return (
- <DemoCard
- key={ease.name}
- title={ease.name}
- question={ease.job}
- badges={
- isNamedCurve(value) ? (
- <Badge label="CSS keyword — nothing to tune" />
- ) : undefined
- }>
- <DemoBody>
- {!isNamedCurve(value) && (
- <CurveEditor
- value={value}
- onChange={next => setToken(ease.name, next)}
- presets={[['reset', ease.value], ...CURVE_PRESETS]}
- />
- )}
- <VStack gap={1} {...stylex.props(sx.full)}>
- <Text type="supporting" color="secondary">
- today — <code>--ease-standard</code>
- </Text>
- <Runner
- durationToken={duration}
- easeToken="--ease-standard-today"
- />
- <Text type="supporting" color="secondary">
- proposed — <code>{ease.name}</code>
- </Text>
- <Runner durationToken={duration} easeToken={ease.name} />
- </VStack>
- <Text
- type="supporting"
- color="secondary"
- {...stylex.props(sx.jobRow)}>
- {ease.rationale}
- </Text>
- {ease.evidence != null && (
- <Text type="supporting" color="secondary">
- Already in the code: <code>{ease.evidence}</code>
- </Text>
- )}
- </DemoBody>
- </DemoCard>
- );
- })}
- </Grid>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Duration</Heading>
- <Text color="secondary">
- Aliases onto the existing primitives, so a theme retunes them for free
- through the motion scale it already has.
- </Text>
- <Grid columns={{minWidth: 380}} gap={4}>
- {SEMANTIC_DURATIONS.map(duration => (
- <DemoCard
- key={duration.name}
- title={duration.name}
- question={duration.job}
- badges={
- <Badge
- label={
- duration.primitive == null
- ? 'new'
- : duration.primitive.replace('--duration-', '')
- }
- />
- }>
- <DemoBody>
- {duration.ms > 0 && (
- <>
- <Runner
- durationToken={duration.name}
- easeToken={pairedEase(duration.name)}
- />
- <TokenSlider token={duration.name} max={900} />
- <BudgetMeter token={duration.name} />
- {duration.budget != null && (
- <Text type="supporting" color="secondary">
- Reference budget {duration.budget[0]}–
- {duration.budget[1]}ms.
- </Text>
- )}
- </>
- )}
- {duration.note != null && (
- <Text
- type="supporting"
- color="secondary"
- {...stylex.props(sx.jobRow)}>
- {duration.note}
- </Text>
- )}
- </DemoBody>
- </DemoCard>
- ))}
- </Grid>
- </VStack>
-
- <Banner
- status="warning"
- title="The slow band is simultaneously unused and too short"
- description={
- <Text>
- Interface motion should stay under 300ms unless it is an overlay, so{' '}
- <code>--duration-medium-max</code> (550ms) and everything above it
- has no interface use. Meanwhile the components that genuinely need a
- long loop bypass the scale entirely, because it stops at 1300ms:
- StatusDot runs 2s and Chat 1.5s, both hardcoded. Either extend the
- band or say plainly that ambient motion is a separate concern from
- interface motion — but the two loops cannot be swept onto tokens
- until one of those happens.
- </Text>
- }
- />
-
- <DemoCard
- title="Stagger"
- question="Group entrances want 30–80ms between items. Longer feels slow, and stagger must never block interaction — the last item has to be reachable before it has finished arriving.">
- <DemoBody>
- {STAGGERS.map(([name, , job]) => (
- <VStack key={name} gap={1} {...stylex.props(sx.full)}>
- <HStack gap={2} vAlign="center">
- <Text {...stylex.props(sx.mono)}>{name}</Text>
- <Text type="supporting" color="secondary">
- {job}
- </Text>
- </HStack>
- <TokenSlider token={name} max={160} step={5} />
- </VStack>
- ))}
- </DemoBody>
- </DemoCard>
-
- <VStack gap={3}>
- <Heading level={2}>The primitive scale, unchanged</Heading>
- <Text color="secondary">
- Theme-generated and working. Nothing here moves — the semantic layer
- sits on top, which is what keeps the change non-breaking.
- </Text>
- <Card padding={0}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Primitive</TableHeaderCell>
- <TableHeaderCell>Value</TableHeaderCell>
- <TableHeaderCell>Semantic alias</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {PRIMITIVE_DURATIONS.map(([name, ms]) => {
- const aliases = SEMANTIC_DURATIONS.filter(
- d => d.primitive === name,
- );
- return (
- <TableRow key={name}>
- <TableCell>
- <Text {...stylex.props(sx.mono)}>{name}</Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {ms}ms
- </Text>
- </TableCell>
- <TableCell>
- {aliases.length > 0 ? (
- <HStack gap={1} wrap="wrap">
- {aliases.map(a => (
- <Badge
- key={a.name}
- variant="success"
- label={a.name}
- />
- ))}
- </HStack>
- ) : (
- <Text color="secondary">—</Text>
- )}
- </TableCell>
- </TableRow>
- );
- })}
- </TableBody>
- </Table>
- </Card>
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Where this lands</Heading>
- <Text color="secondary">
- Not a <code>:root</code> block — core defines its tokens through
- StyleX, so the proposal is an addition to two existing objects.
- </Text>
- <CodeBlock
- language="ts"
- title="@astryxdesign/core/src/theme/tokens.stylex.ts"
- hasCopyButton
- code={`export const easeDefaults = {
- '--ease-standard': 'cubic-bezier(0.24, 1, 0.4, 1)', // kept, deprecated in docs
- '--ease-entry': ${JSON.stringify(rawToken('--ease-entry'))},
- '--ease-exit': ${JSON.stringify(rawToken('--ease-exit'))},
- '--ease-move': ${JSON.stringify(rawToken('--ease-move'))},
- '--ease-state': ${JSON.stringify(rawToken('--ease-state'))},
- '--ease-linear': ${JSON.stringify(rawToken('--ease-linear'))},
- '--ease-drawer': ${JSON.stringify(rawToken('--ease-drawer'))},
-} as const;
-
-export const durationDefaults = {
- // the nine primitives stay exactly as they are
- ...
- // semantic layer, aliased so a theme retunes both at once
-${SEMANTIC_DURATIONS.map(
- d =>
- ` '${d.name}': ${JSON.stringify(rawToken(d.name))},${
- d.primitive != null ? ` // ${d.primitive}` : ''
- }`,
-).join('\n')}
-} as const;`}
- />
- <Text type="supporting" color="secondary">
- The export page emits this with whatever you have tuned. See{' '}
- <Link href="/motion/export">Export tuning</Link>.
- </Text>
- </VStack>
- </LabPage>
- );
-}
diff --git a/apps/sandbox/src/motion/pages/violations.tsx b/apps/sandbox/src/motion/pages/violations.tsx
deleted file mode 100644
index 98517ab05c..0000000000
--- a/apps/sandbox/src/motion/pages/violations.tsx
+++ /dev/null
@@ -1,509 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-/**
- * @file page.tsx
- * @input The generated audit, the lab store
- * @output Every hardcoded duration and curve, with what it becomes
- * @position /motion/violations
- *
- * The brief says 28; the measured number is higher, and the difference is not
- * carelessness: a third of them are one deliberate reduced-motion idiom. The
- * page is organised around that, because a sweep planned for 28 careless
- * values and a sweep that contains a policy question are different pieces of
- * work. Counts come from the generated audit, never from prose.
- */
-
-import {useMemo, useState} from 'react';
-import * as stylex from '@stylexjs/stylex';
-import {Badge} from '@astryxdesign/core/Badge';
-import {Banner} from '@astryxdesign/core/Banner';
-import {Card} from '@astryxdesign/core/Card';
-import {Grid} from '@astryxdesign/core/Grid';
-import {Link} from '@astryxdesign/core/Link';
-import {
- SegmentedControl,
- SegmentedControlItem,
-} from '@astryxdesign/core/SegmentedControl';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableHeaderCell,
- TableRow,
-} from '@astryxdesign/core/Table';
-import {TextInput} from '@astryxdesign/core/TextInput';
-import {HStack, VStack} from '@astryxdesign/core/Layout';
-import {Heading, Text} from '@astryxdesign/core/Text';
-import {LabPage} from '../PageFrame';
-import {ComparePanes, DemoBody, DemoCard, TokenSlider} from '../LabPrimitives';
-import {LoopRig, TintRig} from '../LabDemos';
-import {
- AUDIT_COUNTS,
- HARDCODED_BY_COMPONENT,
- HARDCODED_SITES,
- LITERAL_VALUES,
- type HardcodedSite,
-} from '../__generated__/motionAudit';
-
-const sx = stylex.create({
- full: {width: '100%'},
- mono: {fontFamily: 'var(--font-family-code)', fontSize: '12px'},
- bad: {color: 'var(--color-text-error, #d3543f)'},
- good: {color: 'var(--color-text-success, #2f7d52)'},
- search: {maxWidth: '280px', width: '100%'},
- scroll: {maxHeight: '560px', overflow: 'auto', width: '100%'},
- statValue: {fontSize: '24px', fontWeight: 650, letterSpacing: '-0.02em'},
-});
-
-/**
- * What each literal should become. Grouped by the shape of the decision rather
- * than by component, because the sweep is only mechanical for two of these
- * four groups — the other two need an answer first.
- */
-type Family = {
- readonly id: string;
- readonly title: string;
- readonly blurb: string;
- readonly token: string;
- readonly matches: (site: HardcodedSite) => boolean;
- readonly mechanical: boolean;
- readonly blockedBy?: string;
-};
-
-const FAMILIES: ReadonlyArray<Family> = [
- {
- id: 'instant',
- title: 'Reduced-motion escapes',
- blurb:
- 'Every one of these is the same idiom: collapse a transition to nothing when the user has asked for less motion. It is not sloppiness, and it is not safe to sweep blind — a zero duration fires no transitionend, so anything sequencing off that event breaks. The 0.01s spelling exists to keep the event.',
- token: '--duration-instant',
- matches: s => s.ms != null && s.ms <= 10,
- mechanical: false,
- blockedBy:
- 'Decide whether --duration-instant is 0 or 0.01ms before sweeping any of these.',
- },
- {
- id: 'table',
- title: 'Table interaction tint',
- blurb:
- 'Ten sites across columnResize, groupedRows, rowExpansion, stickyColumns and tree: seven 150ms durations and three bare `ease` curves, several of them the two halves of one `transition` shorthand. This resolves an open question in the brief — its "nine hardcoded values in Table" and its "six hardcoded 150ms values in Table tree" are the same set counted twice, not fifteen sites. 150ms and the token\u2019s 175ms are near-indistinguishable at 1×, so what this family buys is the lint rule, not a visual change.',
- token: '--duration-state',
- matches: s => s.component === 'Table',
- mechanical: true,
- },
- {
- id: 'loops',
- title: 'Ambient loops',
- blurb:
- 'StatusDot at 2s and Chat at 1.5s, both outside a scale that stops at 1300ms. They did not bypass the tokens by accident — there is no token that reaches. This group cannot be swept until the slow band is extended or ambient motion is declared a separate concern.',
- token: '--duration-continuous (does not reach)',
- matches: s => s.ms != null && s.ms >= 1000,
- mechanical: false,
- blockedBy: 'Needs the ambient-band decision.',
- },
- {
- id: 'curves',
- title: 'Curves authored by hand',
- blurb:
- 'Mostly linear, and mostly correct: a progress bar and a scroll-driven wheel should be linear. The exception is the sheet exit, which authors a full cubic-bezier with a comment measuring why the standard curve fails. That comment is the specification for --ease-exit.',
- token: '--ease-linear / --ease-exit / --ease-state',
- matches: s => s.kind === 'easing',
- mechanical: true,
- },
-];
-
-function familyOf(site: HardcodedSite): Family | undefined {
- return FAMILIES.find(f => f.matches(site));
-}
-
-function tokenFor(site: HardcodedSite): string {
- if (site.kind === 'easing') {
- if (site.value === 'linear') {
- return '--ease-linear';
- }
- if (site.value.startsWith('cubic-bezier')) {
- return '--ease-exit';
- }
- return '--ease-state';
- }
- if (site.ms == null) {
- return '--duration-state';
- }
- if (site.ms <= 10) {
- return '--duration-instant';
- }
- if (site.ms >= 1000) {
- return 'no token reaches';
- }
- if (site.ms <= 160) {
- return '--duration-state';
- }
- return '--duration-enter';
-}
-
-function countIn(familyId: string): number {
- return HARDCODED_SITES.filter(s => familyOf(s)?.id === familyId).length;
-}
-
-export default function ViolationsPage() {
- const [query, setQuery] = useState('');
- const [kind, setKind] = useState<'all' | 'duration' | 'easing'>('all');
-
- const rows = useMemo(
- () =>
- HARDCODED_SITES.filter(site => {
- if (kind !== 'all' && site.kind !== kind) {
- return false;
- }
- if (query.trim() === '') {
- return true;
- }
- const q = query.toLowerCase();
- return (
- site.component.toLowerCase().includes(q) ||
- site.file.toLowerCase().includes(q) ||
- site.value.toLowerCase().includes(q) ||
- site.prop.toLowerCase().includes(q)
- );
- }),
- [kind, query],
- );
-
- return (
- <LabPage
- title="Hardcoded durations and curves"
- intro="The token linter polices type, spacing, radius and colour. It has no entry for duration or easing, which is a complete explanation for every site below. Adding those entries turns rubric criterion 3 from a review question into a build failure."
- decides="What each hardcoded site becomes, and whether the swap is visible at all."
- badges={
- <Badge
- variant="error"
- label={`${AUDIT_COUNTS.hardcodedTotal} measured`}
- />
- }>
- <Banner
- status="warning"
- title={`The brief says 28. The measured number is ${AUDIT_COUNTS.hardcodedTotal}.`}
- description={
- <Text>
- Higher, not lower — so the sweep is bigger than budgeted. More
- importantly, the extra is not more of the same: {countIn('instant')}{' '}
- of them are one reduced-motion idiom that needs a decision before it
- can be touched, and {countIn('loops')} are ambient loops that no
- token currently reaches. Two of the four families below are
- mechanical; the other two are blocked on answers, and together they
- are {countIn('instant') + countIn('loops')} of the{' '}
- {AUDIT_COUNTS.hardcodedTotal}.
- </Text>
- }
- />
-
- <Grid columns={{minWidth: 220}} gap={3}>
- {[
- [
- AUDIT_COUNTS.hardcodedTotal,
- 'Hardcoded sites',
- 'measured against [email protected]',
- ],
- [AUDIT_COUNTS.hardcodedDuration, 'Durations and delays', ''],
- [AUDIT_COUNTS.hardcodedEasing, 'Curves', ''],
- [
- AUDIT_COUNTS.durationWithoutCurve,
- 'Durations with no curve',
- 'silently taking the CSS default',
- ],
- ].map(([value, label, detail]) => (
- <Card key={String(label)} padding={4}>
- <VStack gap={0.5}>
- <span {...stylex.props(sx.statValue)}>{value}</span>
- <Text type="supporting">{label}</Text>
- {detail !== '' && (
- <Text type="supporting" color="secondary">
- {detail}
- </Text>
- )}
- </VStack>
- </Card>
- ))}
- </Grid>
-
- <VStack gap={3}>
- <Heading level={2}>Four families, two of them blocked</Heading>
- {FAMILIES.map(family => {
- const count = HARDCODED_SITES.filter(
- s => familyOf(s)?.id === family.id,
- ).length;
- return (
- <DemoCard
- key={family.id}
- title={family.title}
- question={family.blurb}
- badges={
- <HStack gap={1}>
- <Badge label={`${count} sites`} />
- <Badge
- variant={family.mechanical ? 'success' : 'warning'}
- label={family.mechanical ? 'mechanical' : 'blocked'}
- />
- </HStack>
- }>
- {family.id === 'table' && (
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — 150ms, default curve',
- content: <TintRig mode="before" />,
- },
- {
- tone: 'after',
- label: 'Proposed — --duration-state, --ease-state',
- content: <TintRig mode="after" />,
- },
- ]}
- />
- )}
- {family.id === 'loops' && (
- <ComparePanes
- panes={[
- {
- tone: 'before',
- label: 'Today — hardcoded, outside the scale',
- content: <LoopRig policy="today" />,
- },
- {
- tone: 'neutral',
- label: 'Stopped',
- content: <LoopRig policy="degrade" />,
- },
- ]}
- />
- )}
- <DemoBody>
- {family.id === 'table' && (
- <>
- <TokenSlider
- token="--duration-state"
- label="state"
- max={400}
- />
- <Text type="supporting" color="secondary">
- Put the rail on 4× or 8× if you want to see the difference
- between 150 and 175 at all. That it is hard to see at 1×
- is the honest finding, and it is the argument for treating
- this family as a lint fix rather than a design change.
- </Text>
- </>
- )}
- {family.blockedBy != null && (
- <Text type="supporting" {...stylex.props(sx.bad)}>
- Blocked: {family.blockedBy}
- </Text>
- )}
- <HStack gap={2} wrap="wrap">
- {HARDCODED_SITES.filter(s => familyOf(s)?.id === family.id)
- .slice(0, 6)
- .map((s, i) => (
- <Text
- key={`${s.file}:${s.line}:${i}`}
- {...stylex.props(sx.mono)}
- color="secondary">
- {s.file}:{s.line}
- </Text>
- ))}
- {count > 6 && (
- <Text type="supporting" color="secondary">
- +{count - 6} more in the table below
- </Text>
- )}
- </HStack>
- </DemoBody>
- </DemoCard>
- );
- })}
- </VStack>
-
- <VStack gap={3}>
- <Heading level={2}>Every site</Heading>
- <HStack gap={2} vAlign="center" wrap="wrap">
- <div {...stylex.props(sx.search)}>
- <TextInput
- label="Filter sites"
- isLabelHidden
- placeholder="Filter by component, file or value…"
- value={query}
- onChange={setQuery}
- />
- </div>
- <SegmentedControl
- label="Kind"
- size="sm"
- value={kind}
- onChange={value => setKind(value as 'all' | 'duration' | 'easing')}>
- <SegmentedControlItem value="all" label="All" />
- <SegmentedControlItem value="duration" label="Durations" />
- <SegmentedControlItem value="easing" label="Curves" />
- </SegmentedControl>
- <Text type="supporting" color="secondary">
- {rows.length} of {HARDCODED_SITES.length}
- </Text>
- </HStack>
- <Card padding={0}>
- <div {...stylex.props(sx.scroll)}>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Component</TableHeaderCell>
- <TableHeaderCell>Site</TableHeaderCell>
- <TableHeaderCell>Property</TableHeaderCell>
- <TableHeaderCell>Today</TableHeaderCell>
- <TableHeaderCell>Becomes</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {/* Two sites can share file, line, value and property when one
- declaration carries a duration and a curve, so the index is
- part of the identity. */}
- {rows.map((site, i) => (
- <TableRow
- key={`${site.file}:${site.line}:${site.prop}:${site.value}:${i}`}>
- <TableCell>
- <Text weight="semibold">{site.component}</Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {site.file}:{site.line}
- </Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono)} color="secondary">
- {site.prop}
- </Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono, sx.bad)}>
- {site.value}
- </Text>
- </TableCell>
- <TableCell>
- <Text {...stylex.props(sx.mono, sx.good)}>
- {tokenFor(site)}
- </Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </div>
- </Card>
- </VStack>
-
- <Grid columns={{minWidth: 320}} gap={3}>
- <Card padding={4}>
- <VStack gap={2}>
- <Heading level={3}>Literals in use</Heading>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Value</TableHeaderCell>
- <TableHeaderCell>Sites</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {LITERAL_VALUES.map(([value, count]) => (
- <TableRow key={value}>
- <TableCell>
- <Text {...stylex.props(sx.mono)}>{value}</Text>
- </TableCell>
- <TableCell>
- <Text>{count}</Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </VStack>
- </Card>
- <Card padding={4}>
- <VStack gap={2}>
- <Heading level={3}>By component</Heading>
- <Table density="compact">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Component</TableHeaderCell>
- <TableHeaderCell>Sites</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {HARDCODED_BY_COMPONENT.map(([name, count]) => (
- <TableRow key={name}>
- <TableCell>
- <Text>{name}</Text>
- </TableCell>
- <TableCell>
- <Text>{count}</Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </VStack>
- </Card>
- </Grid>
-
- <VStack gap={3}>
- <Heading level={2}>Sweep order</Heading>
- <Card padding={0}>
- <Table density="balanced">
- <TableHeader>
- <TableRow>
- <TableHeaderCell>Step</TableHeaderCell>
- <TableHeaderCell>Why this order</TableHeaderCell>
- </TableRow>
- </TableHeader>
- <TableBody>
- {[
- [
- '1. Land the semantic tokens as aliases',
- 'Nothing to migrate to until they exist, and aliasing means nothing shifts perceptually while the sweep runs.',
- ],
- [
- '2. Add the lint rules in warn mode',
- 'Produces the real inventory continuously, so this page stops being a snapshot.',
- ],
- [
- '3. Answer the two blocked families',
- 'Whether --duration-instant is 0 or 0.01ms, and whether the slow band grows an ambient tier.',
- ],
- [
- '4. Sweep',
- 'Mechanical once the tokens and the answers both exist.',
- ],
- [
- '5. Flip lint to error',
- 'Only once the count is zero, or the remainder is explicitly allowlisted.',
- ],
- ].map(([step, why]) => (
- <TableRow key={step}>
- <TableCell>
- <Text weight="semibold">{step}</Text>
- </TableCell>
- <TableCell>
- <Text color="secondary">{why}</Text>
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- </Card>
- <Text type="supporting" color="secondary">
- The rule stub is on <Link href="/motion/export">Export tuning</Link>.
- The reduced-motion decision that blocks family one is on{' '}
- <Link href="/motion/reduced-motion">Reduced motion</Link>.
- </Text>
- </VStack>
- </LabPage>
- );
-}