An open source design system that's fully customizable and agent ready
TypeScript
fix(theme-neutral): map tokens to reviewed palette (#6034)
rubyycheungcde73c74d84b
diff --git a/.changeset/neutral-theme-palette-token-mapping.md b/.changeset/neutral-theme-palette-token-mapping.mdnew file mode 100644index 0000000000..08ff33b7d2--- /dev/null+++ b/.changeset/neutral-theme-palette-token-mapping.md@@ -0,0 +1,10 @@+---+'@astryxdesign/theme-neutral': patch+'@astryxdesign/cli': patch+---++[fix] Remap Neutral's semantic, syntax, and categorical color tokens to the+reviewed theme-owned palette through named stop references. Keep the maintained+CLI template synchronized.++@rubyycheungdiff --git a/packages/cli/api/theme/add/add.test.mjs b/packages/cli/api/theme/add/add.test.mjsindex 8c0bda27de..d7cd79bb62 100644--- a/packages/cli/api/theme/add/add.test.mjs+++ b/packages/cli/api/theme/add/add.test.mjs@@ -37,9 +37,33 @@ describe('themeAdd (api/theme/add)', () => {}});+ it('copies every relative import required by the scaffolded theme', async () => {+ const result = await themeAdd('neutral', {cwd: tmpDir});+ const outputDir = path.join(tmpDir, result.data.outputDir);+ const relativeImports = /from\s+['"](\.\.?\/[^'"]+)['"]/g;++ for (const file of result.data.files) {+ if (!/\.(?:ts|tsx|mjs)$/.test(file)) continue;+ const source = fs.readFileSync(path.join(outputDir, file), 'utf-8');+ for (const [, specifier] of source.matchAll(relativeImports)) {+ const imported = path.resolve(outputDir, path.dirname(file), specifier);+ expect(+ fs.existsSync(imported) ||+ fs.existsSync(`${imported}.ts`) ||+ fs.existsSync(`${imported}.tsx`) ||+ fs.existsSync(`${imported}.mjs`),+ ).toBe(true);+ }+ }+ });+it('strips the Meta copyright header from copied files', async () => {const result = await themeAdd('neutral', {cwd: tmpDir});- const first = path.join(tmpDir, result.data.outputDir, result.data.files[0]);+ const first = path.join(+ tmpDir,+ result.data.outputDir,+ result.data.files[0],+ );expect(fs.readFileSync(first, 'utf-8')).not.toMatch(/Copyright \(c\) Meta Platforms/,);@@ -62,9 +86,9 @@ describe('themeAdd (api/theme/add)', () => {});it('throws ERR_UNKNOWN_THEME for an unknown slug (with suggestions)', async () => {- await expect(themeAdd('does-not-exist', {cwd: tmpDir})).rejects.toMatchObject(- {code: 'ERR_UNKNOWN_THEME'},- );+ await expect(+ themeAdd('does-not-exist', {cwd: tmpDir}),+ ).rejects.toMatchObject({code: 'ERR_UNKNOWN_THEME'});});it('refuses to overwrite existing files without overwrite', async () => {diff --git a/packages/cli/assets/templates/themes/manifest.json b/packages/cli/assets/templates/themes/manifest.jsonindex ade41f6415..282e69a975 100644--- a/packages/cli/assets/templates/themes/manifest.json+++ b/packages/cli/assets/templates/themes/manifest.json@@ -50,6 +50,7 @@"icons.tsx","neutralPalettes.ts","neutralPalettes.generated.ts",+ "neutralPaletteRefs.generated.ts","neutralPalettes.generated.receipt.json","palette.config.json"]diff --git a/packages/cli/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts b/packages/cli/assets/templates/themes/neutral/neutralPaletteRefs.generated.tsnew file mode 100644index 0000000000..eadc9c7f17--- /dev/null+++ b/packages/cli/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts@@ -0,0 +1,50 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++// Generated from neutralPalettes.generated.ts for the stops used by+// neutralTheme.ts. Keep the complete palette available for authoring and+// audits, but do not make consumers pay for unused palette stops.+// prettier-ignore+export const neutralPaletteRefs = {+ purple: {+ light: {30: '#6b187c', 70: '#d885eb', 75: '#e496f6', 80: '#efa8ff', 85: '#f3bfff', 90: '#f7d5ff'},+ dark: {85: '#f3bfff'},+ },+ green: {+ light: {30: '#0b5615', 40: '#237028', 45: '#2f7d33', 65: '#6ab26b', 75: '#90ca90', 80: '#a4d6a3'},+ dark: {80: '#aad4a9', 85: '#bce0bb'},+ },+ neutral: {+ light: {0: '#000000', 5: '#111111', 15: '#262626', 35: '#525252', 45: '#6a6a6a', 50: '#777777', 65: '#9e9e9e', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},+ dark: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 15: '#262626', 35: '#525252', 65: '#9e9e9e', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},+ },+ orange: {+ light: {30: '#733100', 75: '#ff9e55', 85: '#ffc7a1'},+ dark: {65: '#df843f', 80: '#ffb37e', 85: '#ffc7a1'},+ },+ blue: {+ light: {30: '#00458c', 50: '#0074e2', 80: '#a1caff', 85: '#b9d7ff'},+ dark: {65: '#5aa0f8', 75: '#88bcff', 80: '#a1caff', 85: '#b9d7ff'},+ },+ red: {+ light: {30: '#8a0011', 35: '#9e0015', 55: '#de4745', 65: '#fa6762', 80: '#ffaea7', 85: '#ffc4be'},+ dark: {75: '#ff9890', 80: '#ffaea7', 85: '#ffc4be'},+ },+ yellow: {+ light: {30: '#584400', 40: '#745b00', 65: '#c29900', 75: '#e2b623', 80: '#eec448', 85: '#f8d36a'},+ dark: {80: '#e3c36c', 90: '#fae19e'},+ },+ teal: {+ light: {30: '#005348', 80: '#90d7c8', 85: '#a9e2d6'},+ dark: {65: '#4fb1a0', 75: '#81c9bb'},+ },+ cyan: {+ dark: {65: '#49adc4', 75: '#71c7dd', 80: '#85d5e9', 85: '#9ae2f4'},+ light: {30: '#00505f'},+ },+ pink: {+ light: {30: '#83004b', 70: '#fc78b1', 85: '#ffc0d7'},+ dark: {75: '#fd92bd', 85: '#ffc0d7'},+ },+} as const;++export default neutralPaletteRefs;diff --git a/packages/cli/assets/templates/themes/neutral/neutralTheme.ts b/packages/cli/assets/templates/themes/neutral/neutralTheme.tsindex 0ffd52635b..894d9d2f57 100644--- a/packages/cli/assets/templates/themes/neutral/neutralTheme.ts+++ b/packages/cli/assets/templates/themes/neutral/neutralTheme.ts@@ -1,65 +1,34 @@// Copyright (c) Meta Platforms, Inc. and affiliates.-/**- * Neutral Theme- *- * A pure grayscale spine with a from-scratch OKLCH-derived categorical- * palette. Hues are placed at evenly-spaced positions on the OKLCH wheel,- * chosen to keep each color recognizable at every tone (no red drift for- * orange, no blue drift for purple) and well-separated from its neighbors.- *- * Core neutral palette: #fafafa, #f5f5f5, #e5e5e5, #737373, #262626, #0a0a0a- *- * Categorical hues (OKLCH; chroma = max-in-gamut at the saturated stop):- * Red H=25 Orange H=65 Yellow H=90 Green H=145- * Teal H=180 Cyan H=215 Blue H=250 Purple H=320 Pink H=355- *- * Saturated badge stops:- * • Cool/medium hues sit at OKLCH L=0.48–0.50 with white text (AA+)- * • Bright warm hues (orange L=0.68, yellow L=0.80) use dark text- *- * Token tonal stops:- * bg = T90 (light) / T20 (dark)- * border = T80 / T30- * icon = T30 / T80- * text = T30 / T80- *- * All 9 saturated badge values pass WCAG AA against their label (>= 4.5:1);- * `scripts/check-badge-contrast.test.mjs` holds every theme to that.- *- * Only overrides tokens that differ from the defaults.- */-import {defineTheme,defineSyntaxTheme,type TokenValue,} from '@astryxdesign/core/theme';import {neutralIconRegistry} from './icons';+import {neutralPaletteRefs} from './neutralPaletteRefs.generated';++const {blue, cyan, green, neutral, orange, pink, purple, red, teal, yellow} =+ neutralPaletteRefs;+const withAlpha = (color: string, alpha: string) => `${color}${alpha}`;-/**- * Neutral syntax palette — pulled from the OKLCH T30 (light) / T80 (dark)- * stops of the categorical ramps. Same colors used by --color-icon-* tokens.- */const neutralSyntax = defineSyntaxTheme({name: 'astryx-neutral',tokens: {- keyword: ['#700084', '#efa8ff'], // purple T30/T80- string: ['#005600', '#a6d2a2'], // green (sat T30 / pastel T80)- comment: ['#737373', '#a3a3a3'], // neutral- number: ['#6e3500', '#ffb37f'], // orange- function: ['#00458c', '#a0caff'], // blue T30/T80 H=255- type: ['#700084', '#efa8ff'], // purple- variable: ['#171717', '#e5e5e5'], // near-black / near-white- operator: ['#737373', '#a3a3a3'], // neutral- constant: ['#6e3500', '#ffb37f'], // orange- tag: ['#89001a', '#ffaeaa'], // red- attribute: ['#584400', '#eec12f'], // yellow- property: ['#005348', '#83dac9'], // teal- // #a3a3a3/#525252 (this pair's own disabled-text tone) failed WCAG AA- // against the syntax background: 2.42:1 light, 2.53:1 dark. #5386.- punctuation: ['#6e6e6e', '#a0a0a0'], // neutral, 4.89:1 / 7.57:1- background: ['#fafafa', '#0a0a0a'],+ keyword: [purple.light[30], purple.light[80]],+ string: [green.light[30], green.light[80]],+ comment: [neutral.light[45], neutral.dark[65]],+ number: [orange.light[30], orange.dark[80]],+ function: [blue.light[30], blue.dark[80]],+ type: [purple.light[30], purple.light[80]],+ variable: [neutral.light[5], neutral.dark[90]],+ operator: [neutral.light[45], neutral.dark[65]],+ constant: [orange.light[30], orange.dark[80]],+ tag: [red.light[30], red.dark[80]],+ attribute: [yellow.light[30], yellow.light[80]],+ property: [teal.light[30], teal.light[80]],+ punctuation: [neutral.light[45], neutral.dark[65]],+ background: [neutral.light[100], neutral.dark[5]],},});@@ -122,235 +91,136 @@ export const neutralTheme = defineTheme({syntax: neutralSyntax,tokens: {- // =========================================================================- // Core — pure grayscale spine (Tailwind neutral)- // 50:#fafafa 100:#f5f5f5 200:#e5e5e5 300:#d4d4d4 400:#a3a3a3- // 500:#737373 600:#525252 700:#404040 800:#262626 900:#171717 950:#0a0a0a- // =========================================================================-- // =========================================================================- // Backgrounds — Figma-style flat with a single lifted surface.- //- // Dark mode collapses card / popover / muted to body T10. Cards and- // popovers lift purely via shadow + inset highlight (see --shadow-*- // below) — they don't need a distinct tone.- //- // Surface is the exception: it's tonally LIGHTER than body (T15) so- // interactive components that sit on top of body have a clear,- // differentiated foreground. Real consumers of --color-background-surface- // are: switches, radios, checkboxes, multi-selectors, dialogs, app- // shells, sections — all things that need to lift above the canvas.- //- // surface T15 #262626 — interactive surfaces lifted above body- // body T10 #1b1b1b — main canvas- // card T10 #1b1b1b — same as body, lifts via --shadow-low- // popover T10 #1b1b1b — same as body, lifts via --shadow-med- // muted T10 #1b1b1b — same as body- //- // Light mode keeps the standard ladder (white surfaces float on tinted- // body; shadows do most of the lifting):- // surface T100 #ffffff- // body T95 #f1f1f1- // card T100 #ffffff- // popover T100 #ffffff- // muted T95 #f1f1f1- //- // All values use the OKLCH Neutral tonal palette (chroma=0).- // =========================================================================- '--color-background-surface': ['#ffffff', '#262626'],- '--color-background-body': ['#f1f1f1', '#1b1b1b'],- '--color-background-card': ['#ffffff', '#1b1b1b'],- '--color-background-popover': ['#ffffff', '#1b1b1b'],- '--color-background-muted': ['#f1f1f1', '#1b1b1b'],-- // Accent + neutral surface tints (sit alongside backgrounds)- '--color-accent': ['#262626', '#ebebeb'],- '--color-accent-muted': ['#f1f1f1', '#262626'],- '--color-neutral': ['#0000000F', '#FFFFFF1A'],+ '--color-background-surface': [neutral.light[100], neutral.dark[15]],+ '--color-background-body': [neutral.light[95], neutral.dark[10]],+ '--color-background-card': [neutral.light[100], neutral.dark[10]],+ '--color-background-popover': [neutral.light[100], neutral.dark[10]],+ '--color-background-muted': [neutral.light[95], neutral.dark[10]],++ '--color-accent': [neutral.light[15], neutral.dark[95]],+ '--color-accent-muted': [neutral.light[95], neutral.dark[15]],+ '--color-neutral': [+ withAlpha(neutral.light[0], '0F'),+ withAlpha(neutral.dark[100], '1A'),+ ],// Overlays (modal scrims, hover/pressed tints)- '--color-overlay': ['#00000080', '#000000CC'],- '--color-overlay-hover': ['#0000000D', '#FFFFFF0D'],- '--color-overlay-pressed': ['#0000001A', '#FFFFFF1A'],+ '--color-overlay': [+ withAlpha(neutral.light[0], '80'),+ withAlpha(neutral.dark[0], 'CC'),+ ],+ '--color-overlay-hover': [+ withAlpha(neutral.light[0], '0D'),+ withAlpha(neutral.dark[100], '0D'),+ ],+ '--color-overlay-pressed': [+ withAlpha(neutral.light[0], '1A'),+ withAlpha(neutral.dark[100], '1A'),+ ],// Text- '--color-text-primary': ['#171717', '#fafafa'],- // Light secondary is neutral-600 (#525252), not 500 (#737373): 500 only- // reaches 4.19:1 on the T95 body (#f1f1f1), just under WCAG AA 4.5:1.- // 600 clears it (6.9:1 on body, 7.8:1 on card). Dark stays neutral-400.- '--color-text-secondary': ['#525252', '#a3a3a3'],- '--color-text-disabled': ['#a3a3a3', '#525252'],- '--color-text-accent': ['#262626', '#ebebeb'],- '--color-on-dark': '#ffffff',- '--color-on-light': '#171717',- // Contrast: neutral accent is near-black (L) / near-white (D)- '--color-on-accent': ['#ffffff', '#171717'],- '--color-on-success': ['#ffffff', '#171717'],- '--color-on-error': ['#ffffff', '#171717'],- '--color-on-warning': '#171717',+ '--color-text-primary': [neutral.light[5], neutral.dark[100]],+ '--color-text-secondary': [neutral.light[35], neutral.dark[65]],+ '--color-text-disabled': [neutral.light[65], neutral.dark[35]],+ '--color-text-accent': [neutral.light[15], neutral.dark[95]],+ '--color-on-dark': neutral.light[100],+ '--color-on-light': neutral.light[5],+ '--color-on-accent': [neutral.light[100], neutral.dark[5]],+ '--color-on-success': [neutral.light[100], neutral.dark[5]],+ '--color-on-error': [neutral.light[100], neutral.dark[5]],+ '--color-on-warning': neutral.light[5],// Icon- '--color-icon-accent': ['#262626', '#ebebeb'],- '--color-icon-primary': ['#171717', '#fafafa'],- '--color-icon-secondary': ['#737373', '#a3a3a3'],- '--color-icon-disabled': ['#a3a3a3', '#525252'],-- // Status / Sentiment — dark mode follows the issue #2150 rubric:- //- // Light mode: pastel T90 banner bg + dark T30/T40 text/icon. Locked- // light values for cards/banners/inputs/destructive btn.- // Dark mode : tinted-dark T20 bg + light pastel T80 text. INVERTED- // from light. Avoids the §5 "pastel-in-both-modes"- // anti-pattern (locked pastels glow against a dark body).- //- // --color-X = "saturated text/icon stop":- // light = T40 dark colored (sits on light pastel)- // dark = T80 light pastel (sits on dark tinted bg)- // Used by destructive button text, input border/icon- // (in light), banner-status-* text overrides.- // --color-X-muted = "muted bg stop":- // light = T90 light pastel- // dark = hue-tinted alpha overlay (T70 stop @ 24%)- // Used by banner bg, status-input message bg,- // destructive button bg. Dark mode uses an alpha- // overlay rather than a solid T20 tinted bg so- // the surface composes onto whatever sits behind- // it (body, card, popover) rather than reading- // as a hard colored panel.- //- // 24% alpha = '3D' suffix. Hue values match --color-icon-{X} dark- // slots (palette T70). Composited onto body #1b1b1b, the effective- // bg luminance hits ~1.65-1.70:1 vs body — visible colored surface- // without the heaviness of a solid T20 panel.- '--color-success': ['#007004', '#9fe59b'],- '--color-error': ['#a50c25', '#ffc6c1'],- '--color-warning': ['#745b00', '#fdcf4f'],- '--color-success-muted': ['#c5e5c0', '#84c9803D'],- '--color-error-muted': ['#facecb', '#ff9e973D'],- '--color-warning-muted': ['#f8da9d', '#deb4333D'],-- // Border- '--color-border': ['#00000014', '#FFFFFF1A'],- '--color-border-emphasized': ['#d4d4d4', '#525252'],+ '--color-icon-accent': [neutral.light[15], neutral.dark[95]],+ '--color-icon-primary': [neutral.light[5], neutral.dark[100]],+ '--color-icon-secondary': [neutral.light[50], neutral.dark[65]],+ '--color-icon-disabled': [neutral.light[65], neutral.dark[35]],++ '--color-success': [green.light[40], green.light[80]],+ '--color-error': [red.light[35], red.dark[85]],+ '--color-warning': [yellow.light[40], yellow.light[85]],+ '--color-success-muted': [green.dark[85], withAlpha(green.light[75], '3D')],+ '--color-error-muted': [red.light[85], withAlpha(red.dark[75], '3D')],+ '--color-warning-muted': [+ yellow.dark[90],+ withAlpha(yellow.light[75], '3D'),+ ],++ '--color-border': [+ withAlpha(neutral.light[0], '14'),+ withAlpha(neutral.dark[100], '1A'),+ ],+ '--color-border-emphasized': [neutral.light[85], neutral.dark[35]],// Effects- '--color-skeleton': ['#ebebeb', '#525252'],- '--color-shadow': ['#0000001A', '#0000004D'],+ '--color-skeleton': [neutral.light[95], neutral.dark[35]],+ '--color-shadow': [+ withAlpha(neutral.light[0], '1A'),+ withAlpha(neutral.dark[0], '4D'),+ ],'--color-tint-hover': ['black', 'white'],- // =========================================================================- // Categorical — light mode uses pastel surfaces + dark colored text;- // dark mode INVERTS to a hue-tinted alpha overlay surface +- // light pastel text (per #2150 rubric §3 — pick the tone- // that satisfies required contrast against every surface- // the token touches).- //- // Per-token tone choice (CIELab L*):- // bg light=T87-T90 pastel dark=T70 hue @ 24% alpha overlay- // (composites onto body to ~1.65:1- // vs body — colored surface that- // feels lighter than a solid T20- // panel; same hue as --color-icon-X- // dark slot, just at lower opacity)- // border light=T80 pastel dark=T60 mid-bright (>=5.8:1 vs body)- // icon light=T30 dark colored dark=T70 light pastel- // text light=T30 dark colored dark=T80 light pastel (>=7:1 on bg)- //- // Light pastels still use the per-hue chroma table (red/blue C=0.05,- // orange/green/purple/pink C=0.06, teal/cyan C=0.07, yellow H=85 C=0.10)- // for equal PERCEIVED saturation. Dark stops (T60/T70/T80) come from- // the dark-mode tonal palette (chroma×0.85, +5 tone lift tapering 80-95).- // =========================================================================-- // Each row's dark slots are HCT-derived from the source hex listed in- // apps/sandbox/src/app/(fullscreen)/pages/neutral-palette/page.tsx via- // the canonical dark-ramp transform (chroma×0.85, +5 tone-lift taper)- // — same algorithm the Tonal Palettes preview renders. Border=T60,- // icon=T70, text=T80. Background uses the T70 hue at 24% alpha so the- // overlay surface composites onto body to ~1.65:1 luminance.-- // Red H=22 — source #eb183a- '--color-background-red': ['#facecb', '#ff9e973D'],- '--color-border-red': ['#e6bab8', '#ff6f6c'],- '--color-icon-red': ['#89001a', '#ff9e97'],- '--color-text-red': ['#89001a', '#ffc6c1'],-- // Orange H=55 — source #d57113- '--color-background-orange': ['#fad0b5', '#ffa2583D'],- '--color-border-orange': ['#e6bda2', '#e2883e'],- '--color-icon-orange': ['#6e3500', '#ffa258'],- '--color-text-orange': ['#6e3500', '#ffc9a2'],-- // Yellow H=90 — source #f8c723- // Light-mode butter-yellow pastel at H=85 C=0.085 L=0.90 — yellow- // sits at the green-cyan luminance peak so it feels louder than the- // other status hues at the same canonical L. Picker decision: pull- // L down one step (0.91→0.90) and C down to its identity floor- // (0.10→0.085, just above the bronze threshold) so it sits closer- // to red/blue's perceived brightness without losing yellow identity.- // Dark-mode comes from the canonical H=90 ramp for tonal-palette- // consistency.- '--color-background-yellow': ['#f8da9d', '#deb4333D'],- '--color-border-yellow': ['#e4c279', '#c0990e'],- '--color-icon-yellow': ['#584400', '#deb433'],- '--color-text-yellow': ['#584400', '#fdcf4f'],-- // Green H=144 — source #358a3a- '--color-background-green': ['#c5e5c0', '#84c9803D'],- '--color-border-green': ['#b2d1ac', '#69ad67'],- '--color-icon-green': ['#0c5700', '#84c980'],- '--color-text-green': ['#0c5700', '#9fe59b'],-- // Teal H=180 — source #0c7365- // Light pastel uses L=0.87 C=0.065 (a step darker + less chroma than- // the L=0.888 C=0.07 used by other hues) to compensate for the- // green-cyan luminance overshoot — at the same OKLCH L, teal/cyan read- // ~5% brighter than red/blue because the eye's luminance response- // peaks in this band. Dropping L+C brings perceived brightness in- // line with the rest of the palette without losing hue identity.- '--color-background-teal': ['#a5e3d6', '#7ec6b83D'],- '--color-border-teal': ['#94d6c8', '#63ab9d'],- '--color-icon-teal': ['#005348', '#7ec6b8'],- '--color-text-teal': ['#005348', '#99e2d3'],-- // Cyan H=215 — source #0c6f82- // Same L=0.87 C=0.065 pastel as teal (luminance overshoot compensation).- '--color-background-cyan': ['#a3e0ef', '#83c2d43D'],- '--color-border-cyan': ['#91d3e3', '#67a7b8'],- '--color-icon-cyan': ['#00505f', '#83c2d4'],- '--color-text-cyan': ['#00505f', '#9edef0'],-- // Blue H=255 — source #0074e2- // T50 #0074e2 reserved for filled Info badge / progressbar / inset hover.- '--color-background-blue': ['#c4ddfb', '#9eb7ff3D'],- '--color-border-blue': ['#b1c9e7', '#6d9cfe'],- '--color-icon-blue': ['#00458c', '#9eb7ff'],- '--color-text-blue': ['#00458c', '#c7d3ff'],-- // Purple H=320 — source #980fb2- '--color-background-purple': ['#eccef3', '#f297ff3D'],- '--color-border-purple': ['#d8bbdf', '#dd74f0'],- '--color-icon-purple': ['#700084', '#f297ff'],- '--color-text-purple': ['#700084', '#fac1ff'],-- // Pink H=355 — source #b10e69- '--color-background-pink': ['#fccadc', '#ff99c33D'],- '--color-border-pink': ['#e7b7c8', '#f273aa'],- '--color-icon-pink': ['#83004b', '#ff99c3'],- '--color-text-pink': ['#83004b', '#ffc3da'],-- // Gray (categorical neutral, chroma 0)- // Light: #e5e5e5 (Neutral 200) so it's visibly distinct from the- // lighter body / muted surface (both #f5f5f5).- // Dark : var(--color-neutral) — semi-transparent white wash- // (#FFFFFF1A, 10%). Matches the same treatment the gray- // badge uses; clearly distinct from the body T10 #1b1b1b- // while staying chroma-0 neutral. Solid T15 #1c1c1c was- // indistinguishable from --color-background-muted.- '--color-background-gray': ['#e5e5e5', 'var(--color-neutral)'],- '--color-border-gray': ['#d4d4d4', '#262626'],- '--color-icon-gray': ['#525252', '#a3a3a3'],- '--color-text-gray': ['#262626', '#e5e5e5'],+ '--color-background-red': [red.light[85], withAlpha(red.dark[75], '3D')],+ '--color-border-red': [red.light[80], red.light[65]],+ '--color-icon-red': [red.light[30], red.dark[75]],+ '--color-text-red': [red.light[30], red.dark[85]],++ '--color-background-orange': [+ orange.light[85],+ withAlpha(orange.light[75], '3D'),+ ],+ '--color-border-orange': [orange.light[85], orange.dark[65]],+ '--color-icon-orange': [orange.light[30], orange.light[75]],+ '--color-text-orange': [orange.light[30], orange.dark[85]],++ '--color-background-yellow': [+ yellow.dark[90],+ withAlpha(yellow.light[75], '3D'),+ ],+ '--color-border-yellow': [yellow.dark[80], yellow.light[65]],+ '--color-icon-yellow': [yellow.light[30], yellow.light[75]],+ '--color-text-yellow': [yellow.light[30], yellow.light[85]],++ '--color-background-green': [+ green.dark[85],+ withAlpha(green.light[75], '3D'),+ ],+ '--color-border-green': [green.dark[80], green.light[65]],+ '--color-icon-green': [green.light[30], green.light[75]],+ '--color-text-green': [green.light[30], green.light[80]],++ '--color-background-teal': [teal.light[85], withAlpha(teal.dark[75], '3D')],+ '--color-border-teal': [teal.light[80], teal.dark[65]],+ '--color-icon-teal': [teal.light[30], teal.dark[75]],+ '--color-text-teal': [teal.light[30], teal.light[85]],++ '--color-background-cyan': [cyan.dark[85], withAlpha(cyan.dark[75], '3D')],+ '--color-border-cyan': [cyan.dark[80], cyan.dark[65]],+ '--color-icon-cyan': [cyan.light[30], cyan.dark[75]],+ '--color-text-cyan': [cyan.light[30], cyan.dark[85]],++ '--color-background-blue': [blue.light[85], withAlpha(blue.dark[75], '3D')],+ '--color-border-blue': [blue.light[80], blue.dark[65]],+ '--color-icon-blue': [blue.light[30], blue.dark[75]],+ '--color-text-blue': [blue.light[30], blue.dark[85]],++ '--color-background-purple': [+ purple.light[90],+ withAlpha(purple.light[75], '3D'),+ ],+ '--color-border-purple': [purple.light[85], purple.light[70]],+ '--color-icon-purple': [purple.light[30], purple.light[75]],+ '--color-text-purple': [purple.light[30], purple.dark[85]],++ '--color-background-pink': [pink.light[85], withAlpha(pink.dark[75], '3D')],+ '--color-border-pink': [pink.light[85], pink.light[70]],+ '--color-icon-pink': [pink.light[30], pink.dark[75]],+ '--color-text-pink': [pink.light[30], pink.dark[85]],++ '--color-background-gray': [neutral.light[90], 'var(--color-neutral)'],+ '--color-border-gray': [neutral.light[85], neutral.dark[15]],+ '--color-icon-gray': [neutral.light[35], neutral.dark[65]],+ '--color-text-gray': [neutral.light[15], neutral.dark[90]],// =========================================================================// Radius — slightly larger than default (kept as-is)@@ -395,11 +265,11 @@ export const neutralTheme = defineTheme({'0 4px 6px light-dark(oklch(0 0 0 / 10%), oklch(0 0 0 / 50%)), ' +'0 12px 24px light-dark(oklch(0 0 0 / 15%), oklch(0 0 0 / 70%)), ' +'inset 0 0 0 1px light-dark(transparent, oklch(1 0 0 / 15%))',- '--shadow-inset-hover': 'inset 0px 0px 0px 2px #0074e24D',- '--shadow-inset-selected': 'inset 0px 0px 0px 2px #0074e280',- '--shadow-inset-success': 'inset 0px 0px 0px 2px #1981004D',- '--shadow-inset-warning': 'inset 0px 0px 0px 2px #ffce2f4D',- '--shadow-inset-error': 'inset 0px 0px 0px 2px #e33f4a4D',+ '--shadow-inset-hover': `inset 0px 0px 0px 2px ${withAlpha(blue.light[50], '4D')}`,+ '--shadow-inset-selected': `inset 0px 0px 0px 2px ${withAlpha(blue.light[50], '80')}`,+ '--shadow-inset-success': `inset 0px 0px 0px 2px ${withAlpha(green.light[45], '4D')}`,+ '--shadow-inset-warning': `inset 0px 0px 0px 2px ${withAlpha(yellow.light[85], '4D')}`,+ '--shadow-inset-error': `inset 0px 0px 0px 2px ${withAlpha(red.light[55], '4D')}`,},components: {diff --git a/packages/themes/neutral/README.md b/packages/themes/neutral/README.mdindex 20e382911c..c1c3034d11 100644--- a/packages/themes/neutral/README.md+++ b/packages/themes/neutral/README.md@@ -49,10 +49,10 @@ Neutral is the reference implementation for palette-aware theme templates.Templates may follow its ownership, review, and alignment workflow withoutcopying its colors or stop layout.-Use semantic theme tokens in components. Neutral's runtime theme does not import-the complete authoring palette. Mapping semantic tokens to reviewed stops is a-separate change, so palette generation and token adoption can be reviewed-independently.+Use semantic theme tokens in components. Neutral's theme source maps those roles+to named palette stops, while the prebuilt theme and CSS contain their resolved+values. Changing the generated palette must include the regenerated receipt,+token diff, tests, and visual review.The committed request and receipt preserve the generation inputs and provenance.CLI regeneration is not yet a supported release workflow; until that toolingdiff --git a/packages/themes/neutral/neutral.spec.md b/packages/themes/neutral/neutral.spec.mdindex bcdd237e01..fc21f48cb3 100644--- a/packages/themes/neutral/neutral.spec.md+++ b/packages/themes/neutral/neutral.spec.md@@ -23,13 +23,13 @@ references:# Neutral theme specification-This record is the current approved palette record. It does not decide-cross-theme local-token, palette-generation, compiler, or artifact APIs;-current `spec:AST-006` owns the accepted local-token contract. This record keeps-Neutral's package adoption separate. DEC-2 ratifies the exact palette shipped-by this change. Token remapping, proposed local-token roles, and additional-component mappings remain separate work; they are not part of this release and-must not be treated as an approved public contract.+This record is the current approved palette and Neutral token-mapping record.+It does not decide cross-theme local-token, palette-generation, compiler, or+artifact APIs; current `spec:AST-006` owns the accepted local-token contract.+DEC-2 ratifies the exact palette shipped by this change, and DEC-4 ratifies the+reviewed Neutral token mappings shipped with it. Proposed local-token roles and+additional component mappings remain separate work and must not be treated as+an approved public contract.## Intent and audience@@ -127,11 +127,11 @@ geometry/shadow changes, which are reviewed independently.## Compatibility and migration-This knowledge-only record changes no package output. Existing Neutral authoring,-portable token overrides, runtime behavior, and package exports remain unchanged.-Neutral stays unenrolled until it explicitly supplies `localTokens`; merely-emitting or referencing the same prefix today does not activate validation or-create the public contract.+This record documents the package output shipped by the current Neutral change.+Existing Neutral authoring and portable token names remain stable while the+reviewed mappings are emitted through the runtime theme and CLI template.+Neutral explicitly supplies `localTokens`; the exact names and meanings are+therefore part of its public compatibility contract.Implementation requires the parent AST-006 implementation to ship first,followed by complete rendered evidence and exact-head approval for every@@ -162,9 +162,11 @@ measurement-tool implementation.## Build and artifact contractThe package manifest and build tests define Neutral's runtime, CSS, declaration,-and export outputs. The palette remains in a theme-owned source file for-authoring and audits. It is not part of `defineTheme`, the package's runtime-exports, generated CSS, or generic theme-build artifacts.+and export outputs. The complete palette remains in a theme-owned source file+for authoring and audits, while the generated selected-stop references used by+`defineTheme` are included in the runtime and CLI template artifacts. The+complete authoring palette is not bundled into generated CSS or generic+theme-build artifacts.## Verification map@@ -178,10 +180,10 @@ exports, generated CSS, or generic theme-build artifacts.## Decision log-The decisions below record settled input for the portions they name. This-record's approval covers the exact palette only. Token mappings, local-token-roles, and rendered-evidence questions stay explicitly separate for later-review and release.+The decisions below record settled input for the portions they name. DEC-2+approves the exact palette, and DEC-4 approves the reviewed token mappings+shipped by this release. Local-token roles and rendered-evidence questions+remain subject to the specific approval gates stated in their decisions.### DEC-1 — Own one exact Neutral filled-accent-status role@@ -242,6 +244,23 @@ and stop coordinates.Rejected: reducing the entire palette's vibrancy, using translucent colors, orchanging semantic token mappings in the palette-value change.+### DEC-4 — Map Neutral roles through reviewed palette references++**Reference:** `theme:neutral/DEC-4`++**Decider:** `rubyycheung`, `2026-09-04`++Neutral's semantic, categorical, syntax, and color-bearing effect values use+named palette-stop references when an approved match exists. Token names and+meanings remain unchanged. Alpha variants derive from the referenced stop+rather than duplicating its hex value.++The mapping is role-aware rather than a blind nearest-color conversion. Very+dark foregrounds preserve their darker role, ordinary backgrounds do not become+true black automatically, and a reviewed token may use the closer value from+the companion ramp. Intentional values without an approved palette match remain+explicit theme-local values.+## Open questions- **OQ1 — Is rendered light/dark evidence complete for the proposed tuple anddiff --git a/packages/themes/neutral/src/neutralPaletteRefs.generated.ts b/packages/themes/neutral/src/neutralPaletteRefs.generated.tsnew file mode 100644index 0000000000..eadc9c7f17--- /dev/null+++ b/packages/themes/neutral/src/neutralPaletteRefs.generated.ts@@ -0,0 +1,50 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++// Generated from neutralPalettes.generated.ts for the stops used by+// neutralTheme.ts. Keep the complete palette available for authoring and+// audits, but do not make consumers pay for unused palette stops.+// prettier-ignore+export const neutralPaletteRefs = {+ purple: {+ light: {30: '#6b187c', 70: '#d885eb', 75: '#e496f6', 80: '#efa8ff', 85: '#f3bfff', 90: '#f7d5ff'},+ dark: {85: '#f3bfff'},+ },+ green: {+ light: {30: '#0b5615', 40: '#237028', 45: '#2f7d33', 65: '#6ab26b', 75: '#90ca90', 80: '#a4d6a3'},+ dark: {80: '#aad4a9', 85: '#bce0bb'},+ },+ neutral: {+ light: {0: '#000000', 5: '#111111', 15: '#262626', 35: '#525252', 45: '#6a6a6a', 50: '#777777', 65: '#9e9e9e', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},+ dark: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 15: '#262626', 35: '#525252', 65: '#9e9e9e', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},+ },+ orange: {+ light: {30: '#733100', 75: '#ff9e55', 85: '#ffc7a1'},+ dark: {65: '#df843f', 80: '#ffb37e', 85: '#ffc7a1'},+ },+ blue: {+ light: {30: '#00458c', 50: '#0074e2', 80: '#a1caff', 85: '#b9d7ff'},+ dark: {65: '#5aa0f8', 75: '#88bcff', 80: '#a1caff', 85: '#b9d7ff'},+ },+ red: {+ light: {30: '#8a0011', 35: '#9e0015', 55: '#de4745', 65: '#fa6762', 80: '#ffaea7', 85: '#ffc4be'},+ dark: {75: '#ff9890', 80: '#ffaea7', 85: '#ffc4be'},+ },+ yellow: {+ light: {30: '#584400', 40: '#745b00', 65: '#c29900', 75: '#e2b623', 80: '#eec448', 85: '#f8d36a'},+ dark: {80: '#e3c36c', 90: '#fae19e'},+ },+ teal: {+ light: {30: '#005348', 80: '#90d7c8', 85: '#a9e2d6'},+ dark: {65: '#4fb1a0', 75: '#81c9bb'},+ },+ cyan: {+ dark: {65: '#49adc4', 75: '#71c7dd', 80: '#85d5e9', 85: '#9ae2f4'},+ light: {30: '#00505f'},+ },+ pink: {+ light: {30: '#83004b', 70: '#fc78b1', 85: '#ffc0d7'},+ dark: {75: '#fd92bd', 85: '#ffc0d7'},+ },+} as const;++export default neutralPaletteRefs;diff --git a/packages/themes/neutral/src/neutralTheme.test.ts b/packages/themes/neutral/src/neutralTheme.test.tsindex 2626d1b12d..00f4450e1c 100644--- a/packages/themes/neutral/src/neutralTheme.test.ts+++ b/packages/themes/neutral/src/neutralTheme.test.ts@@ -1,8 +1,28 @@// Copyright (c) Meta Platforms, Inc. and affiliates.import {describe, expect, it} from 'vitest';+import {neutralPalettes} from './neutralPalettes';import {neutralTheme} from './neutralTheme';+function contrastRatio(foreground: string, background: string): number {+ const luminance = (hex: string): number => {+ const channels = [0, 2, 4].map(offset =>+ Number.parseInt(hex.slice(offset + 1, offset + 3), 16),+ );+ return channels.reduce((sum, channel, index) => {+ const srgb = channel / 255;+ const linear =+ srgb <= 0.04045 ? srgb / 12.92 : Math.pow((srgb + 0.055) / 1.055, 2.4);+ return sum + linear * [0.2126, 0.7152, 0.0722][index];+ }, 0);+ };+ const foregroundLuminance = luminance(foreground);+ const backgroundLuminance = luminance(background);+ const lighter = Math.max(foregroundLuminance, backgroundLuminance);+ const darker = Math.min(foregroundLuminance, backgroundLuminance);+ return (lighter + 0.05) / (darker + 0.05);+}+const statusFill = {accent: 'var(--astryx-theme-neutral-color-status-fill-accent)',success: 'var(--astryx-theme-neutral-color-status-fill-success)',@@ -10,8 +30,209 @@ const statusFill = {error: 'var(--astryx-theme-neutral-color-status-fill-error)',} as const;+const lightDark = (light: string, dark: string) =>+ `light-dark(${light}, ${dark})`;++describe('neutral theme palette mappings', () => {+ it('keeps semantic and categorical tokens aligned with reviewed stops', () => {+ const mappings = {+ '--color-background-surface': lightDark(+ neutralPalettes.neutral.light[100],+ neutralPalettes.neutral.dark[15],+ ),+ '--color-background-body': lightDark(+ neutralPalettes.neutral.light[95],+ neutralPalettes.neutral.dark[10],+ ),+ '--color-text-primary': lightDark(+ neutralPalettes.neutral.light[5],+ neutralPalettes.neutral.dark[100],+ ),+ '--color-icon-primary': lightDark(+ neutralPalettes.neutral.light[5],+ neutralPalettes.neutral.dark[100],+ ),+ '--color-success': lightDark(+ neutralPalettes.green.light[40],+ neutralPalettes.green.light[80],+ ),+ '--color-warning': lightDark(+ neutralPalettes.yellow.light[40],+ neutralPalettes.yellow.light[85],+ ),+ '--color-error': lightDark(+ neutralPalettes.red.light[35],+ neutralPalettes.red.dark[85],+ ),+ '--color-background-red': lightDark(+ neutralPalettes.red.light[85],+ `${neutralPalettes.red.dark[75]}3D`,+ ),+ '--color-border-red': lightDark(+ neutralPalettes.red.light[80],+ neutralPalettes.red.light[65],+ ),+ '--color-icon-red': lightDark(+ neutralPalettes.red.light[30],+ neutralPalettes.red.dark[75],+ ),+ '--color-text-red': lightDark(+ neutralPalettes.red.light[30],+ neutralPalettes.red.dark[85],+ ),+ '--color-background-orange': lightDark(+ neutralPalettes.orange.light[85],+ `${neutralPalettes.orange.light[75]}3D`,+ ),+ '--color-border-orange': lightDark(+ neutralPalettes.orange.light[85],+ neutralPalettes.orange.dark[65],+ ),+ '--color-icon-orange': lightDark(+ neutralPalettes.orange.light[30],+ neutralPalettes.orange.light[75],+ ),+ '--color-text-orange': lightDark(+ neutralPalettes.orange.light[30],+ neutralPalettes.orange.dark[85],+ ),+ '--color-background-yellow': lightDark(+ neutralPalettes.yellow.dark[90],+ `${neutralPalettes.yellow.light[75]}3D`,+ ),+ '--color-border-yellow': lightDark(+ neutralPalettes.yellow.dark[80],+ neutralPalettes.yellow.light[65],+ ),+ '--color-icon-yellow': lightDark(+ neutralPalettes.yellow.light[30],+ neutralPalettes.yellow.light[75],+ ),+ '--color-text-yellow': lightDark(+ neutralPalettes.yellow.light[30],+ neutralPalettes.yellow.light[85],+ ),+ '--color-background-green': lightDark(+ neutralPalettes.green.dark[85],+ `${neutralPalettes.green.light[75]}3D`,+ ),+ '--color-border-green': lightDark(+ neutralPalettes.green.dark[80],+ neutralPalettes.green.light[65],+ ),+ '--color-icon-green': lightDark(+ neutralPalettes.green.light[30],+ neutralPalettes.green.light[75],+ ),+ '--color-text-green': lightDark(+ neutralPalettes.green.light[30],+ neutralPalettes.green.light[80],+ ),+ '--color-background-teal': lightDark(+ neutralPalettes.teal.light[85],+ `${neutralPalettes.teal.dark[75]}3D`,+ ),+ '--color-border-teal': lightDark(+ neutralPalettes.teal.light[80],+ neutralPalettes.teal.dark[65],+ ),+ '--color-icon-teal': lightDark(+ neutralPalettes.teal.light[30],+ neutralPalettes.teal.dark[75],+ ),+ '--color-text-teal': lightDark(+ neutralPalettes.teal.light[30],+ neutralPalettes.teal.light[85],+ ),+ '--color-background-cyan': lightDark(+ neutralPalettes.cyan.dark[85],+ `${neutralPalettes.cyan.dark[75]}3D`,+ ),+ '--color-border-cyan': lightDark(+ neutralPalettes.cyan.dark[80],+ neutralPalettes.cyan.dark[65],+ ),+ '--color-icon-cyan': lightDark(+ neutralPalettes.cyan.light[30],+ neutralPalettes.cyan.dark[75],+ ),+ '--color-text-cyan': lightDark(+ neutralPalettes.cyan.light[30],+ neutralPalettes.cyan.dark[85],+ ),+ '--color-background-blue': lightDark(+ neutralPalettes.blue.light[85],+ `${neutralPalettes.blue.dark[75]}3D`,+ ),+ '--color-border-blue': lightDark(+ neutralPalettes.blue.light[80],+ neutralPalettes.blue.dark[65],+ ),+ '--color-icon-blue': lightDark(+ neutralPalettes.blue.light[30],+ neutralPalettes.blue.dark[75],+ ),+ '--color-text-blue': lightDark(+ neutralPalettes.blue.light[30],+ neutralPalettes.blue.dark[85],+ ),+ '--color-background-purple': lightDark(+ neutralPalettes.purple.light[90],+ `${neutralPalettes.purple.light[75]}3D`,+ ),+ '--color-border-purple': lightDark(+ neutralPalettes.purple.light[85],+ neutralPalettes.purple.light[70],+ ),+ '--color-icon-purple': lightDark(+ neutralPalettes.purple.light[30],+ neutralPalettes.purple.light[75],+ ),+ '--color-text-purple': lightDark(+ neutralPalettes.purple.light[30],+ neutralPalettes.purple.dark[85],+ ),+ '--color-background-pink': lightDark(+ neutralPalettes.pink.light[85],+ `${neutralPalettes.pink.dark[75]}3D`,+ ),+ '--color-border-pink': lightDark(+ neutralPalettes.pink.light[85],+ neutralPalettes.pink.light[70],+ ),+ '--color-icon-pink': lightDark(+ neutralPalettes.pink.light[30],+ neutralPalettes.pink.dark[75],+ ),+ '--color-text-pink': lightDark(+ neutralPalettes.pink.light[30],+ neutralPalettes.pink.dark[85],+ ),+ };++ expect(neutralTheme.tokens).toMatchObject(mappings);+ });+});++describe('neutral syntax contrast', () => {+ it('keeps light CodeBlock comments and operators at normal-text AA', () => {+ const background = neutralPalettes.neutral.light[100];+ for (const token of ['comment', 'operator'] as const) {+ expect(neutralTheme.tokens[`--color-syntax-${token}`]).toBe(+ lightDark(+ neutralPalettes.neutral.light[45],+ neutralPalettes.neutral.dark[65],+ ),+ );+ expect(+ contrastRatio(neutralPalettes.neutral.light[45], background),+ ).toBeGreaterThanOrEqual(4.5);+ }+ });+});+describe('neutral theme-local status mappings', () => {- it('owns reusable status fills through exact Neutral-local token names', () => {+ it('preserves the independently approved component status fills', () => {expect(neutralTheme.localTokens).toMatchObject({'--astryx-theme-neutral-color-status-fill-accent':'light-dark(#0074e2, #6d9cfe)',diff --git a/packages/themes/neutral/src/neutralTheme.ts b/packages/themes/neutral/src/neutralTheme.tsindex 0ffd52635b..894d9d2f57 100644--- a/packages/themes/neutral/src/neutralTheme.ts+++ b/packages/themes/neutral/src/neutralTheme.ts@@ -1,65 +1,34 @@// Copyright (c) Meta Platforms, Inc. and affiliates.-/**- * Neutral Theme- *- * A pure grayscale spine with a from-scratch OKLCH-derived categorical- * palette. Hues are placed at evenly-spaced positions on the OKLCH wheel,- * chosen to keep each color recognizable at every tone (no red drift for- * orange, no blue drift for purple) and well-separated from its neighbors.- *- * Core neutral palette: #fafafa, #f5f5f5, #e5e5e5, #737373, #262626, #0a0a0a- *- * Categorical hues (OKLCH; chroma = max-in-gamut at the saturated stop):- * Red H=25 Orange H=65 Yellow H=90 Green H=145- * Teal H=180 Cyan H=215 Blue H=250 Purple H=320 Pink H=355- *- * Saturated badge stops:- * • Cool/medium hues sit at OKLCH L=0.48–0.50 with white text (AA+)- * • Bright warm hues (orange L=0.68, yellow L=0.80) use dark text- *- * Token tonal stops:- * bg = T90 (light) / T20 (dark)- * border = T80 / T30- * icon = T30 / T80- * text = T30 / T80- *- * All 9 saturated badge values pass WCAG AA against their label (>= 4.5:1);- * `scripts/check-badge-contrast.test.mjs` holds every theme to that.- *- * Only overrides tokens that differ from the defaults.- */-import {defineTheme,defineSyntaxTheme,type TokenValue,} from '@astryxdesign/core/theme';import {neutralIconRegistry} from './icons';+import {neutralPaletteRefs} from './neutralPaletteRefs.generated';++const {blue, cyan, green, neutral, orange, pink, purple, red, teal, yellow} =+ neutralPaletteRefs;+const withAlpha = (color: string, alpha: string) => `${color}${alpha}`;-/**- * Neutral syntax palette — pulled from the OKLCH T30 (light) / T80 (dark)- * stops of the categorical ramps. Same colors used by --color-icon-* tokens.- */const neutralSyntax = defineSyntaxTheme({name: 'astryx-neutral',tokens: {- keyword: ['#700084', '#efa8ff'], // purple T30/T80- string: ['#005600', '#a6d2a2'], // green (sat T30 / pastel T80)- comment: ['#737373', '#a3a3a3'], // neutral- number: ['#6e3500', '#ffb37f'], // orange- function: ['#00458c', '#a0caff'], // blue T30/T80 H=255- type: ['#700084', '#efa8ff'], // purple- variable: ['#171717', '#e5e5e5'], // near-black / near-white- operator: ['#737373', '#a3a3a3'], // neutral- constant: ['#6e3500', '#ffb37f'], // orange- tag: ['#89001a', '#ffaeaa'], // red- attribute: ['#584400', '#eec12f'], // yellow- property: ['#005348', '#83dac9'], // teal- // #a3a3a3/#525252 (this pair's own disabled-text tone) failed WCAG AA- // against the syntax background: 2.42:1 light, 2.53:1 dark. #5386.- punctuation: ['#6e6e6e', '#a0a0a0'], // neutral, 4.89:1 / 7.57:1- background: ['#fafafa', '#0a0a0a'],+ keyword: [purple.light[30], purple.light[80]],+ string: [green.light[30], green.light[80]],+ comment: [neutral.light[45], neutral.dark[65]],+ number: [orange.light[30], orange.dark[80]],+ function: [blue.light[30], blue.dark[80]],+ type: [purple.light[30], purple.light[80]],+ variable: [neutral.light[5], neutral.dark[90]],+ operator: [neutral.light[45], neutral.dark[65]],+ constant: [orange.light[30], orange.dark[80]],+ tag: [red.light[30], red.dark[80]],+ attribute: [yellow.light[30], yellow.light[80]],+ property: [teal.light[30], teal.light[80]],+ punctuation: [neutral.light[45], neutral.dark[65]],+ background: [neutral.light[100], neutral.dark[5]],},});@@ -122,235 +91,136 @@ export const neutralTheme = defineTheme({syntax: neutralSyntax,tokens: {- // =========================================================================- // Core — pure grayscale spine (Tailwind neutral)- // 50:#fafafa 100:#f5f5f5 200:#e5e5e5 300:#d4d4d4 400:#a3a3a3- // 500:#737373 600:#525252 700:#404040 800:#262626 900:#171717 950:#0a0a0a- // =========================================================================-- // =========================================================================- // Backgrounds — Figma-style flat with a single lifted surface.- //- // Dark mode collapses card / popover / muted to body T10. Cards and- // popovers lift purely via shadow + inset highlight (see --shadow-*- // below) — they don't need a distinct tone.- //- // Surface is the exception: it's tonally LIGHTER than body (T15) so- // interactive components that sit on top of body have a clear,- // differentiated foreground. Real consumers of --color-background-surface- // are: switches, radios, checkboxes, multi-selectors, dialogs, app- // shells, sections — all things that need to lift above the canvas.- //- // surface T15 #262626 — interactive surfaces lifted above body- // body T10 #1b1b1b — main canvas- // card T10 #1b1b1b — same as body, lifts via --shadow-low- // popover T10 #1b1b1b — same as body, lifts via --shadow-med- // muted T10 #1b1b1b — same as body- //- // Light mode keeps the standard ladder (white surfaces float on tinted- // body; shadows do most of the lifting):- // surface T100 #ffffff- // body T95 #f1f1f1- // card T100 #ffffff- // popover T100 #ffffff- // muted T95 #f1f1f1- //- // All values use the OKLCH Neutral tonal palette (chroma=0).- // =========================================================================- '--color-background-surface': ['#ffffff', '#262626'],- '--color-background-body': ['#f1f1f1', '#1b1b1b'],- '--color-background-card': ['#ffffff', '#1b1b1b'],- '--color-background-popover': ['#ffffff', '#1b1b1b'],- '--color-background-muted': ['#f1f1f1', '#1b1b1b'],-- // Accent + neutral surface tints (sit alongside backgrounds)- '--color-accent': ['#262626', '#ebebeb'],- '--color-accent-muted': ['#f1f1f1', '#262626'],- '--color-neutral': ['#0000000F', '#FFFFFF1A'],+ '--color-background-surface': [neutral.light[100], neutral.dark[15]],+ '--color-background-body': [neutral.light[95], neutral.dark[10]],+ '--color-background-card': [neutral.light[100], neutral.dark[10]],+ '--color-background-popover': [neutral.light[100], neutral.dark[10]],+ '--color-background-muted': [neutral.light[95], neutral.dark[10]],++ '--color-accent': [neutral.light[15], neutral.dark[95]],+ '--color-accent-muted': [neutral.light[95], neutral.dark[15]],+ '--color-neutral': [+ withAlpha(neutral.light[0], '0F'),+ withAlpha(neutral.dark[100], '1A'),+ ],// Overlays (modal scrims, hover/pressed tints)- '--color-overlay': ['#00000080', '#000000CC'],- '--color-overlay-hover': ['#0000000D', '#FFFFFF0D'],- '--color-overlay-pressed': ['#0000001A', '#FFFFFF1A'],+ '--color-overlay': [+ withAlpha(neutral.light[0], '80'),+ withAlpha(neutral.dark[0], 'CC'),+ ],+ '--color-overlay-hover': [+ withAlpha(neutral.light[0], '0D'),+ withAlpha(neutral.dark[100], '0D'),+ ],+ '--color-overlay-pressed': [+ withAlpha(neutral.light[0], '1A'),+ withAlpha(neutral.dark[100], '1A'),+ ],// Text- '--color-text-primary': ['#171717', '#fafafa'],- // Light secondary is neutral-600 (#525252), not 500 (#737373): 500 only- // reaches 4.19:1 on the T95 body (#f1f1f1), just under WCAG AA 4.5:1.- // 600 clears it (6.9:1 on body, 7.8:1 on card). Dark stays neutral-400.- '--color-text-secondary': ['#525252', '#a3a3a3'],- '--color-text-disabled': ['#a3a3a3', '#525252'],- '--color-text-accent': ['#262626', '#ebebeb'],- '--color-on-dark': '#ffffff',- '--color-on-light': '#171717',- // Contrast: neutral accent is near-black (L) / near-white (D)- '--color-on-accent': ['#ffffff', '#171717'],- '--color-on-success': ['#ffffff', '#171717'],- '--color-on-error': ['#ffffff', '#171717'],- '--color-on-warning': '#171717',+ '--color-text-primary': [neutral.light[5], neutral.dark[100]],+ '--color-text-secondary': [neutral.light[35], neutral.dark[65]],+ '--color-text-disabled': [neutral.light[65], neutral.dark[35]],+ '--color-text-accent': [neutral.light[15], neutral.dark[95]],+ '--color-on-dark': neutral.light[100],+ '--color-on-light': neutral.light[5],+ '--color-on-accent': [neutral.light[100], neutral.dark[5]],+ '--color-on-success': [neutral.light[100], neutral.dark[5]],+ '--color-on-error': [neutral.light[100], neutral.dark[5]],+ '--color-on-warning': neutral.light[5],// Icon- '--color-icon-accent': ['#262626', '#ebebeb'],- '--color-icon-primary': ['#171717', '#fafafa'],- '--color-icon-secondary': ['#737373', '#a3a3a3'],- '--color-icon-disabled': ['#a3a3a3', '#525252'],-- // Status / Sentiment — dark mode follows the issue #2150 rubric:- //- // Light mode: pastel T90 banner bg + dark T30/T40 text/icon. Locked- // light values for cards/banners/inputs/destructive btn.- // Dark mode : tinted-dark T20 bg + light pastel T80 text. INVERTED- // from light. Avoids the §5 "pastel-in-both-modes"- // anti-pattern (locked pastels glow against a dark body).- //- // --color-X = "saturated text/icon stop":- // light = T40 dark colored (sits on light pastel)- // dark = T80 light pastel (sits on dark tinted bg)- // Used by destructive button text, input border/icon- // (in light), banner-status-* text overrides.- // --color-X-muted = "muted bg stop":- // light = T90 light pastel- // dark = hue-tinted alpha overlay (T70 stop @ 24%)- // Used by banner bg, status-input message bg,- // destructive button bg. Dark mode uses an alpha- // overlay rather than a solid T20 tinted bg so- // the surface composes onto whatever sits behind- // it (body, card, popover) rather than reading- // as a hard colored panel.- //- // 24% alpha = '3D' suffix. Hue values match --color-icon-{X} dark- // slots (palette T70). Composited onto body #1b1b1b, the effective- // bg luminance hits ~1.65-1.70:1 vs body — visible colored surface- // without the heaviness of a solid T20 panel.- '--color-success': ['#007004', '#9fe59b'],- '--color-error': ['#a50c25', '#ffc6c1'],- '--color-warning': ['#745b00', '#fdcf4f'],- '--color-success-muted': ['#c5e5c0', '#84c9803D'],- '--color-error-muted': ['#facecb', '#ff9e973D'],- '--color-warning-muted': ['#f8da9d', '#deb4333D'],-- // Border- '--color-border': ['#00000014', '#FFFFFF1A'],- '--color-border-emphasized': ['#d4d4d4', '#525252'],+ '--color-icon-accent': [neutral.light[15], neutral.dark[95]],+ '--color-icon-primary': [neutral.light[5], neutral.dark[100]],+ '--color-icon-secondary': [neutral.light[50], neutral.dark[65]],+ '--color-icon-disabled': [neutral.light[65], neutral.dark[35]],++ '--color-success': [green.light[40], green.light[80]],+ '--color-error': [red.light[35], red.dark[85]],+ '--color-warning': [yellow.light[40], yellow.light[85]],+ '--color-success-muted': [green.dark[85], withAlpha(green.light[75], '3D')],+ '--color-error-muted': [red.light[85], withAlpha(red.dark[75], '3D')],+ '--color-warning-muted': [+ yellow.dark[90],+ withAlpha(yellow.light[75], '3D'),+ ],++ '--color-border': [+ withAlpha(neutral.light[0], '14'),+ withAlpha(neutral.dark[100], '1A'),+ ],+ '--color-border-emphasized': [neutral.light[85], neutral.dark[35]],// Effects- '--color-skeleton': ['#ebebeb', '#525252'],- '--color-shadow': ['#0000001A', '#0000004D'],+ '--color-skeleton': [neutral.light[95], neutral.dark[35]],+ '--color-shadow': [+ withAlpha(neutral.light[0], '1A'),+ withAlpha(neutral.dark[0], '4D'),+ ],'--color-tint-hover': ['black', 'white'],- // =========================================================================- // Categorical — light mode uses pastel surfaces + dark colored text;- // dark mode INVERTS to a hue-tinted alpha overlay surface +- // light pastel text (per #2150 rubric §3 — pick the tone- // that satisfies required contrast against every surface- // the token touches).- //- // Per-token tone choice (CIELab L*):- // bg light=T87-T90 pastel dark=T70 hue @ 24% alpha overlay- // (composites onto body to ~1.65:1- // vs body — colored surface that- // feels lighter than a solid T20- // panel; same hue as --color-icon-X- // dark slot, just at lower opacity)- // border light=T80 pastel dark=T60 mid-bright (>=5.8:1 vs body)- // icon light=T30 dark colored dark=T70 light pastel- // text light=T30 dark colored dark=T80 light pastel (>=7:1 on bg)- //- // Light pastels still use the per-hue chroma table (red/blue C=0.05,- // orange/green/purple/pink C=0.06, teal/cyan C=0.07, yellow H=85 C=0.10)- // for equal PERCEIVED saturation. Dark stops (T60/T70/T80) come from- // the dark-mode tonal palette (chroma×0.85, +5 tone lift tapering 80-95).- // =========================================================================-- // Each row's dark slots are HCT-derived from the source hex listed in- // apps/sandbox/src/app/(fullscreen)/pages/neutral-palette/page.tsx via- // the canonical dark-ramp transform (chroma×0.85, +5 tone-lift taper)- // — same algorithm the Tonal Palettes preview renders. Border=T60,- // icon=T70, text=T80. Background uses the T70 hue at 24% alpha so the- // overlay surface composites onto body to ~1.65:1 luminance.-- // Red H=22 — source #eb183a- '--color-background-red': ['#facecb', '#ff9e973D'],- '--color-border-red': ['#e6bab8', '#ff6f6c'],- '--color-icon-red': ['#89001a', '#ff9e97'],- '--color-text-red': ['#89001a', '#ffc6c1'],-- // Orange H=55 — source #d57113- '--color-background-orange': ['#fad0b5', '#ffa2583D'],- '--color-border-orange': ['#e6bda2', '#e2883e'],- '--color-icon-orange': ['#6e3500', '#ffa258'],- '--color-text-orange': ['#6e3500', '#ffc9a2'],-- // Yellow H=90 — source #f8c723- // Light-mode butter-yellow pastel at H=85 C=0.085 L=0.90 — yellow- // sits at the green-cyan luminance peak so it feels louder than the- // other status hues at the same canonical L. Picker decision: pull- // L down one step (0.91→0.90) and C down to its identity floor- // (0.10→0.085, just above the bronze threshold) so it sits closer- // to red/blue's perceived brightness without losing yellow identity.- // Dark-mode comes from the canonical H=90 ramp for tonal-palette- // consistency.- '--color-background-yellow': ['#f8da9d', '#deb4333D'],- '--color-border-yellow': ['#e4c279', '#c0990e'],- '--color-icon-yellow': ['#584400', '#deb433'],- '--color-text-yellow': ['#584400', '#fdcf4f'],-- // Green H=144 — source #358a3a- '--color-background-green': ['#c5e5c0', '#84c9803D'],- '--color-border-green': ['#b2d1ac', '#69ad67'],- '--color-icon-green': ['#0c5700', '#84c980'],- '--color-text-green': ['#0c5700', '#9fe59b'],-- // Teal H=180 — source #0c7365- // Light pastel uses L=0.87 C=0.065 (a step darker + less chroma than- // the L=0.888 C=0.07 used by other hues) to compensate for the- // green-cyan luminance overshoot — at the same OKLCH L, teal/cyan read- // ~5% brighter than red/blue because the eye's luminance response- // peaks in this band. Dropping L+C brings perceived brightness in- // line with the rest of the palette without losing hue identity.- '--color-background-teal': ['#a5e3d6', '#7ec6b83D'],- '--color-border-teal': ['#94d6c8', '#63ab9d'],- '--color-icon-teal': ['#005348', '#7ec6b8'],- '--color-text-teal': ['#005348', '#99e2d3'],-- // Cyan H=215 — source #0c6f82- // Same L=0.87 C=0.065 pastel as teal (luminance overshoot compensation).- '--color-background-cyan': ['#a3e0ef', '#83c2d43D'],- '--color-border-cyan': ['#91d3e3', '#67a7b8'],- '--color-icon-cyan': ['#00505f', '#83c2d4'],- '--color-text-cyan': ['#00505f', '#9edef0'],-- // Blue H=255 — source #0074e2- // T50 #0074e2 reserved for filled Info badge / progressbar / inset hover.- '--color-background-blue': ['#c4ddfb', '#9eb7ff3D'],- '--color-border-blue': ['#b1c9e7', '#6d9cfe'],- '--color-icon-blue': ['#00458c', '#9eb7ff'],- '--color-text-blue': ['#00458c', '#c7d3ff'],-- // Purple H=320 — source #980fb2- '--color-background-purple': ['#eccef3', '#f297ff3D'],- '--color-border-purple': ['#d8bbdf', '#dd74f0'],- '--color-icon-purple': ['#700084', '#f297ff'],- '--color-text-purple': ['#700084', '#fac1ff'],-- // Pink H=355 — source #b10e69- '--color-background-pink': ['#fccadc', '#ff99c33D'],- '--color-border-pink': ['#e7b7c8', '#f273aa'],- '--color-icon-pink': ['#83004b', '#ff99c3'],- '--color-text-pink': ['#83004b', '#ffc3da'],-- // Gray (categorical neutral, chroma 0)- // Light: #e5e5e5 (Neutral 200) so it's visibly distinct from the- // lighter body / muted surface (both #f5f5f5).- // Dark : var(--color-neutral) — semi-transparent white wash- // (#FFFFFF1A, 10%). Matches the same treatment the gray- // badge uses; clearly distinct from the body T10 #1b1b1b- // while staying chroma-0 neutral. Solid T15 #1c1c1c was- // indistinguishable from --color-background-muted.- '--color-background-gray': ['#e5e5e5', 'var(--color-neutral)'],- '--color-border-gray': ['#d4d4d4', '#262626'],- '--color-icon-gray': ['#525252', '#a3a3a3'],- '--color-text-gray': ['#262626', '#e5e5e5'],+ '--color-background-red': [red.light[85], withAlpha(red.dark[75], '3D')],+ '--color-border-red': [red.light[80], red.light[65]],+ '--color-icon-red': [red.light[30], red.dark[75]],+ '--color-text-red': [red.light[30], red.dark[85]],++ '--color-background-orange': [+ orange.light[85],+ withAlpha(orange.light[75], '3D'),+ ],+ '--color-border-orange': [orange.light[85], orange.dark[65]],+ '--color-icon-orange': [orange.light[30], orange.light[75]],+ '--color-text-orange': [orange.light[30], orange.dark[85]],++ '--color-background-yellow': [+ yellow.dark[90],+ withAlpha(yellow.light[75], '3D'),+ ],+ '--color-border-yellow': [yellow.dark[80], yellow.light[65]],+ '--color-icon-yellow': [yellow.light[30], yellow.light[75]],+ '--color-text-yellow': [yellow.light[30], yellow.light[85]],++ '--color-background-green': [+ green.dark[85],+ withAlpha(green.light[75], '3D'),+ ],+ '--color-border-green': [green.dark[80], green.light[65]],+ '--color-icon-green': [green.light[30], green.light[75]],+ '--color-text-green': [green.light[30], green.light[80]],++ '--color-background-teal': [teal.light[85], withAlpha(teal.dark[75], '3D')],+ '--color-border-teal': [teal.light[80], teal.dark[65]],+ '--color-icon-teal': [teal.light[30], teal.dark[75]],+ '--color-text-teal': [teal.light[30], teal.light[85]],++ '--color-background-cyan': [cyan.dark[85], withAlpha(cyan.dark[75], '3D')],+ '--color-border-cyan': [cyan.dark[80], cyan.dark[65]],+ '--color-icon-cyan': [cyan.light[30], cyan.dark[75]],+ '--color-text-cyan': [cyan.light[30], cyan.dark[85]],++ '--color-background-blue': [blue.light[85], withAlpha(blue.dark[75], '3D')],+ '--color-border-blue': [blue.light[80], blue.dark[65]],+ '--color-icon-blue': [blue.light[30], blue.dark[75]],+ '--color-text-blue': [blue.light[30], blue.dark[85]],++ '--color-background-purple': [+ purple.light[90],+ withAlpha(purple.light[75], '3D'),+ ],+ '--color-border-purple': [purple.light[85], purple.light[70]],+ '--color-icon-purple': [purple.light[30], purple.light[75]],+ '--color-text-purple': [purple.light[30], purple.dark[85]],++ '--color-background-pink': [pink.light[85], withAlpha(pink.dark[75], '3D')],+ '--color-border-pink': [pink.light[85], pink.light[70]],+ '--color-icon-pink': [pink.light[30], pink.dark[75]],+ '--color-text-pink': [pink.light[30], pink.dark[85]],++ '--color-background-gray': [neutral.light[90], 'var(--color-neutral)'],+ '--color-border-gray': [neutral.light[85], neutral.dark[15]],+ '--color-icon-gray': [neutral.light[35], neutral.dark[65]],+ '--color-text-gray': [neutral.light[15], neutral.dark[90]],// =========================================================================// Radius — slightly larger than default (kept as-is)@@ -395,11 +265,11 @@ export const neutralTheme = defineTheme({'0 4px 6px light-dark(oklch(0 0 0 / 10%), oklch(0 0 0 / 50%)), ' +'0 12px 24px light-dark(oklch(0 0 0 / 15%), oklch(0 0 0 / 70%)), ' +'inset 0 0 0 1px light-dark(transparent, oklch(1 0 0 / 15%))',- '--shadow-inset-hover': 'inset 0px 0px 0px 2px #0074e24D',- '--shadow-inset-selected': 'inset 0px 0px 0px 2px #0074e280',- '--shadow-inset-success': 'inset 0px 0px 0px 2px #1981004D',- '--shadow-inset-warning': 'inset 0px 0px 0px 2px #ffce2f4D',- '--shadow-inset-error': 'inset 0px 0px 0px 2px #e33f4a4D',+ '--shadow-inset-hover': `inset 0px 0px 0px 2px ${withAlpha(blue.light[50], '4D')}`,+ '--shadow-inset-selected': `inset 0px 0px 0px 2px ${withAlpha(blue.light[50], '80')}`,+ '--shadow-inset-success': `inset 0px 0px 0px 2px ${withAlpha(green.light[45], '4D')}`,+ '--shadow-inset-warning': `inset 0px 0px 0px 2px ${withAlpha(yellow.light[85], '4D')}`,+ '--shadow-inset-error': `inset 0px 0px 0px 2px ${withAlpha(red.light[55], '4D')}`,},components: {diff --git a/scripts/check-theme-template.test.mjs b/scripts/check-theme-template.test.mjsindex c9c4b85bdb..d43b6c2aad 100644--- a/scripts/check-theme-template.test.mjs+++ b/scripts/check-theme-template.test.mjs@@ -52,6 +52,10 @@ const NEUTRAL_GENERATED_PALETTE = path.join(REPO_ROOT,'packages/themes/neutral/src/neutralPalettes.generated.ts',);+const NEUTRAL_PALETTE_REFS = path.join(+ REPO_ROOT,+ 'packages/themes/neutral/src/neutralPaletteRefs.generated.ts',+);const NEUTRAL_GENERATED_RECEIPT = path.join(REPO_ROOT,'packages/themes/neutral/src/neutralPalettes.generated.receipt.json',@@ -249,6 +253,10 @@ describe('theme template stays in sync with the theme system', () => {NEUTRAL_GENERATED_PALETTE,path.join(NEUTRAL_TEMPLATE_DIR, 'neutralPalettes.generated.ts'),],+ [+ NEUTRAL_PALETTE_REFS,+ path.join(NEUTRAL_TEMPLATE_DIR, 'neutralPaletteRefs.generated.ts'),+ ],[NEUTRAL_GENERATED_RECEIPT,path.join(diff --git a/scripts/generate-cli-themes.mjs b/scripts/generate-cli-themes.mjsindex 3e8e98371e..9960a22399 100644--- a/scripts/generate-cli-themes.mjs+++ b/scripts/generate-cli-themes.mjs@@ -104,6 +104,10 @@ function main() {source: path.join(srcDir, `${id}Palettes.generated.ts`),output: `${id}Palettes.generated.ts`,},+ {+ source: path.join(srcDir, `${id}PaletteRefs.generated.ts`),+ output: `${id}PaletteRefs.generated.ts`,+ },{source: path.join(srcDir, `${id}Palettes.generated.receipt.json`),output: `${id}Palettes.generated.receipt.json`,