An open source design system that's fully customizable and agent ready
TypeScript
feat(theme): accept a [light, dark] tuple for defineTheme color.accent (#2279) (#4592)
Jiun Shin59399613497d
diff --git a/.changeset/define-theme-tuple-accent.md b/.changeset/define-theme-tuple-accent.mdnew file mode 100644index 0000000000..08e9fbf383--- /dev/null+++ b/.changeset/define-theme-tuple-accent.md@@ -0,0 +1,9 @@+---+'@astryxdesign/cli': patch+'@astryxdesign/core': patch+---++[feat] `defineTheme`: `color.accent` accepts a `[light, dark]` tuple (#2279)++`ColorScaleConfig.accent` now takes either a single hex or a `[light, dark]` tuple, matching `TokenValue`. With a tuple, `expandColorScale` derives the light half of every generated `light-dark()` pair from the light seed's palettes and the dark half from the dark seed's, so each scheme gets a consistent derived palette (muted, on-accent, neutrals) instead of the `tokens['--color-accent']` workaround that skips scale generation. Single-string configs are unchanged, token for token. Also documents the precedence between `color` and `tokens` for accent-derived values: `tokens` entries win token by token, the `var(--color-accent)` reference tokens follow a `--color-accent` override at runtime, and the baked `--color-on-accent` stays derived from the `color.accent` seed.+@jiunshinndiff --git a/packages/cli/assets/docs/theme.doc.dense.mjs b/packages/cli/assets/docs/theme.doc.dense.mjsindex 71de45989d..91367e3b6f 100644--- a/packages/cli/assets/docs/theme.doc.dense.mjs+++ b/packages/cli/assets/docs/theme.doc.dense.mjs@@ -9,7 +9,7 @@ export const docsDense = {{ section: 'Available Themes', title: 'Themes', content: [null, null, { type: 'prose', text: 'published: neutral (start here), butter, chocolate, gothic (dark-only), matcha, stone, y2k. @astryxdesign/theme-{name} = source (runtime). @astryxdesign/theme-{name}/built = optimized (+ theme.css).' }] },{ section: 'Theme Props', title: 'Props', content: [null] },{ section: 'Creating a Custom Theme', title: 'Custom Theme', content: [{ type: 'prose', text: '`theme list` + `theme add <slug>` to start from a shipped theme, or defineTheme from scratch. only override tokens that differ.' }, null, { type: 'prose', text: '`astryx theme template` writes theme.template.ts: every defineTheme field + token families + override syntax, annotated, with the CLI command that prints each reference.' }] },- { section: 'defineTheme', title: 'defineTheme', content: [{ type: 'prose', text: 'scale configs (color, typography, radius, motion) + explicit token overrides + component overrides. color derives full palette from accent hex via HCT.' }, null, null] },+ { section: 'defineTheme', title: 'defineTheme', content: [{ type: 'prose', text: 'scale configs (color, typography, radius, motion) + explicit token overrides + component overrides. color derives full palette from accent via HCT; accent = hex or [light, dark] tuple (per-scheme palettes). tokens overrides win token-by-token; --color-on-accent stays baked from color.accent, so prefer a tuple accent over overriding --color-accent.' }, null, null] },{ section: 'Component Style Overrides', title: 'Component Overrides', content: [{ type: 'prose', text: 'components field uses semantic component keys + style keys (base, variant:value, stateName), not raw selectors. for external CSS, prefer data-* selectors from `astryx docs styling`. write standard CSS (borderRadius, padding) — pipeline expands to internal vars. public vars (--button-focus-offset etc) set directly. private vars (--_*) cannot be set — use CSS properties. run `astryx component <Name>` for details.' }, null, null, null, null] },{ section: 'Custom Variants', title: 'Custom Variants', content: [{ type: 'prose', text: 'any unknown prop:value in components becomes a new variant. astryx theme build generates TS augmentations. works on any extensible prop axis (variant, status, etc).' }, null, null, null, null] },{ section: 'Building Themes for Production', title: 'Build for Production', content: [{ type: 'prose', text: 'astryx theme build compiles defineTheme to static CSS. outputs .css + .js (__built:true) + .d.ts.' }, null, null, null, null] },diff --git a/packages/cli/assets/docs/theme.doc.mjs b/packages/cli/assets/docs/theme.doc.mjsindex db5ed1e3f5..1ab09f2629 100644--- a/packages/cli/assets/docs/theme.doc.mjs+++ b/packages/cli/assets/docs/theme.doc.mjs@@ -162,7 +162,7 @@ function App() {content: [{type: 'prose',- text: 'defineTheme creates a theme from token overrides and optional scale configs. Scale configs generate tokens from parameters. Explicit token overrides always take precedence over scale-generated values.',+ text: 'defineTheme creates a theme from token overrides and optional scale configs. Scale configs generate tokens from parameters. Explicit token overrides always take precedence over scale-generated values, token by token. One caveat for the accent: overriding --color-accent in tokens re-points the reference tokens (--color-accent-muted, --color-text-accent, --color-icon-accent) but NOT --color-on-accent, which stays baked from the color.accent seed. To give each scheme its own accent with a consistent derived palette, pass a [light, dark] tuple to color.accent instead of overriding the token.',},{type: 'code',@@ -172,7 +172,8 @@ function App() {const myTheme = defineTheme({name: 'my-theme',- color: { accent: '#7B61FF', neutralStyle: 'cool' },+ // accent: single hex, or [light, dark] tuple to seed each scheme separately+ color: { accent: ['#7B61FF', '#9B85FF'], neutralStyle: 'cool' },typography: {scale: { base: 14, ratio: 1.2 },body: { family: 'Inter', fallbacks: '-apple-system, sans-serif' },@@ -181,7 +182,7 @@ const myTheme = defineTheme({motion: { fast: 175, medium: 410, ratio: 0.75 },tokens: {// Explicit overrides take precedence over scale-generated values- '--color-accent': ['#7B61FF', '#9B85FF'],+ '--color-background-body': ['#FFFFFF', '#0A0A0A'],},components: {button: { 'variant:primary': { color: 'white' } },@@ -195,7 +196,7 @@ const myTheme = defineTheme({['color','--color-accent, --color-background-*, --color-text-*, --color-border, etc.',- 'accent? (hex; omit for neutral-only), neutralStyle? (warm|cool|neutral), contrast? (standard|high)',+ 'accent? (hex or [light, dark] tuple; omit for neutral-only), neutralStyle? (warm|cool|neutral), contrast? (standard|high)',],['typography.scale',diff --git a/packages/cli/assets/docs/theme.doc.zh.mjs b/packages/cli/assets/docs/theme.doc.zh.mjsindex a444c09738..4f851ded67 100644--- a/packages/cli/assets/docs/theme.doc.zh.mjs+++ b/packages/cli/assets/docs/theme.doc.zh.mjs@@ -9,7 +9,7 @@ export const docsZh = {{ section: 'Available Themes', title: '可用主题', content: [null, null, { type: 'prose', text: '已发布主题:neutral(推荐起点)、butter、chocolate、gothic(仅暗色)、matcha、stone、y2k。@astryxdesign/theme-{name} = 源码版(运行时注入)。@astryxdesign/theme-{name}/built = 优化版(配合 theme.css)。' }] },{ section: 'Theme Props', title: 'Theme 属性', content: [null] },{ section: 'Creating a Custom Theme', title: '创建自定义主题', content: [{ type: 'prose', text: '用 `theme list` + `theme add <slug>` 从内置主题开始,或用 defineTheme 从零编写。只覆盖与默认值不同的令牌。' }, null, { type: 'prose', text: '`astryx theme template` 会写入 theme.template.ts:带注释的完整参考,涵盖每个 defineTheme 字段、令牌族和覆盖语法,并标明打印各自参考的 CLI 命令。' }] },- { section: 'defineTheme', title: 'defineTheme', content: [{ type: 'prose', text: '支持比例配置(typography、radius、motion)+ 显式令牌覆盖 + 组件覆盖。' }, null, null] },+ { section: 'defineTheme', title: 'defineTheme', content: [{ type: 'prose', text: '支持比例配置(color、typography、radius、motion)+ 显式令牌覆盖 + 组件覆盖。color 通过 HCT 从 accent 派生完整调色板;accent 接受单个十六进制值或 [light, dark] 元组(每个模式使用各自的种子色)。tokens 覆盖按令牌逐个生效;--color-on-accent 始终由 color.accent 计算得出,因此优先使用元组 accent 而不是覆盖 --color-accent。' }, null, null] },{ section: 'Building Themes for Production', title: '生产构建', content: [{ type: 'prose', text: 'astryx theme build 将 defineTheme 编译为静态 CSS。输出 .css + .js(__built:true)+ .d.ts。' }, null, null, null, null] },{ section: 'Runtime vs Built Themes', title: '运行时 vs 构建', content: [{ type: 'prose', text: '运行时:useInsertionEffect 在客户端注入样式。构建:静态 CSS 在首次渲染时就存在。SSR 应用请使用 /built + theme.css。' }, null, null, null] },{ section: 'Light/Dark Mode', title: '亮/暗模式', content: [{ type: 'prose', text: "令牌值使用 [light, dark] 元组实现自动模式切换。Theme 上 mode='system'(默认)跟随系统偏好。" }, null, null] },diff --git a/packages/cli/assets/theme.template.ts b/packages/cli/assets/theme.template.tsindex 998309607d..f00f68e705 100644--- a/packages/cli/assets/theme.template.ts+++ b/packages/cli/assets/theme.template.ts@@ -105,12 +105,13 @@ export const myTheme = defineTheme({// ───────────────────────────────────────────────────────────────────────/**- * Generates the neutral ramp and the accent tokens from one seed colour+ * Generates the neutral ramp and the accent tokens from a seed colour* using the HCT perceptual model: surfaces, text, icons, borders, muted* fills, hover and pressed overlays — light and dark both.*- * accent seed hex; omit to keep the default accent and re-tone only- * the neutrals+ * accent seed hex, or a [light, dark] pair to seed each scheme's+ * palette from its own colour; omit to keep the default+ * accent and re-tone only the neutrals* neutralStyle 'warm' | 'cool' | 'neutral' — the temperature of the greys* contrast 'standard' | 'high' — 'high' widens the text/surface tone* gap, for dense data UI or bright and clinical screensdiff --git a/packages/core/src/theme/defineTheme.ts b/packages/core/src/theme/defineTheme.tsindex 6fe7c7aea7..012250addd 100644--- a/packages/core/src/theme/defineTheme.ts+++ b/packages/core/src/theme/defineTheme.ts@@ -248,20 +248,38 @@ export interface DefineThemeInput {*/radius?: RadiusScaleConfig;/**- * Color scale configuration. Generates color token overrides from a- * single accent color using the HCT perceptual color model.+ * Color scale configuration. Generates color token overrides from an+ * accent seed using the HCT perceptual color model.** Only generates tokens derivable from the accent — status colors,* categorical hues, and fixed tokens (on-dark/on-light) use defaults.- * Explicit `tokens` entries always take precedence.+ *+ * `accent` accepts a single hex (same seed for both color schemes) or a+ * `[light, dark]` tuple, matching `TokenValue`. With a tuple, the light+ * scheme's full palette derives from the light seed and the dark+ * scheme's from the dark seed.** `accent` is optional — omit it for a neutral-only theme, which keeps* the default accent tokens and only themes the neutrals.*+ * Precedence vs `tokens`: explicit `tokens` entries win over generated+ * values, token by token. Because `--color-accent-muted`,+ * `--color-text-accent` and `--color-icon-accent` are generated as+ * `var(--color-accent)` references, a `tokens['--color-accent']`+ * override re-points them at runtime. `--color-on-accent` does NOT+ * follow: it is baked from the `color.accent` seed (a contrast+ * computation CSS cannot express), so overriding the accent through+ * `tokens` without also overriding `--color-on-accent` leaves the two+ * out of sync. To re-seat the whole palette per scheme, prefer a tuple+ * `color.accent` over the `tokens['--color-accent']` workaround.+ ** @example- * ```tsx+ * ```* color: { accent: '#0064E0', neutralStyle: 'cool', contrast: 'standard' }*+ * // Per-scheme accents — light palette from the first seed, dark from the second+ * color: { accent: ['#0064E0', '#48CAE4'] }+ ** // Neutral-only — accent tokens stay at their defaults* color: { neutralStyle: 'warm' }* ```diff --git a/packages/core/src/theme/expandColorScale.test.ts b/packages/core/src/theme/expandColorScale.test.tsindex 341e68edec..0262523954 100644--- a/packages/core/src/theme/expandColorScale.test.ts+++ b/packages/core/src/theme/expandColorScale.test.ts@@ -192,6 +192,144 @@ describe('expandColorScale — neutral-only themes (#2279)', () => {});});+describe('expandColorScale — tuple accent (#2279)', () => {+ const LIGHT_SEED = '#B7410E';+ const DARK_SEED = '#48CAE4';++ it('accepts a [light, dark] tuple and generates the accent tokens', () => {+ const tokens = expandColorScale({accent: [LIGHT_SEED, DARK_SEED]});+ for (const key of ACCENT_TOKENS) {+ expect(tokens).toHaveProperty(key);+ }+ expect(tokens['--color-accent']).toMatch(/^light-dark\(#/);+ expect(tokens['--color-on-accent']).toMatch(/^light-dark\(#/);+ });++ it('a same-halves tuple matches the single-string expansion, token for token', () => {+ // Pins the string path as the tuple fast path: introducing tuples must+ // not re-color any existing single-accent theme.+ const fromString = expandColorScale({accent: LIGHT_SEED});+ const fromTuple = expandColorScale({accent: [LIGHT_SEED, LIGHT_SEED]});+ expect(fromTuple).toEqual(fromString);+ });++ it('derives the light palette from the light seed and the dark palette from the dark seed', () => {+ // Every generated light-dark() pair takes its light half from the light+ // seed's palettes and its dark half from the dark seed's, so resolving+ // each mode must agree with the matching single-accent expansion.+ const tuple = defineTheme({+ name: 'tuple',+ color: {accent: [LIGHT_SEED, DARK_SEED]},+ });+ const fromLight = defineTheme({name: 'light', color: {accent: LIGHT_SEED}});+ const fromDark = defineTheme({name: 'dark', color: {accent: DARK_SEED}});++ const generatedKeys = Object.keys(+ expandColorScale({accent: [LIGHT_SEED, DARK_SEED]}),+ );+ const tupleLight = resolveThemeTokens(tuple, {mode: 'light'});+ const refLight = resolveThemeTokens(fromLight, {mode: 'light'});+ const tupleDark = resolveThemeTokens(tuple, {mode: 'dark'});+ const refDark = resolveThemeTokens(fromDark, {mode: 'dark'});+ for (const key of generatedKeys) {+ expect(tupleLight[key], `${key} (light)`).toBe(refLight[key]);+ expect(tupleDark[key], `${key} (dark)`).toBe(refDark[key]);+ }+ });++ it('differing seeds produce a dark half the light seed would not', () => {+ // Regression guard: the dark half must not silently reuse the light seed.+ const tuple = defineTheme({+ name: 'tuple-differs',+ color: {accent: [LIGHT_SEED, DARK_SEED]},+ });+ const single = defineTheme({+ name: 'single',+ color: {accent: LIGHT_SEED},+ });+ expect(+ resolveThemeTokens(tuple, {mode: 'dark'})['--color-accent'],+ ).not.toBe(resolveThemeTokens(single, {mode: 'dark'})['--color-accent']);+ });++ it('keeps the derived accent tokens as references with a tuple accent', () => {+ const tokens = expandColorScale({accent: [LIGHT_SEED, DARK_SEED]});+ expect(tokens['--color-text-accent']).toBe('var(--color-accent)');+ expect(tokens['--color-icon-accent']).toBe('var(--color-accent)');+ expect(tokens['--color-accent-muted']).toContain('var(--color-accent)');+ });++ it('honours neutralStyle with a tuple accent', () => {+ const warm = expandColorScale({+ accent: [LIGHT_SEED, DARK_SEED],+ neutralStyle: 'warm',+ });+ const cool = expandColorScale({+ accent: [LIGHT_SEED, DARK_SEED],+ neutralStyle: 'cool',+ });+ expect(warm['--color-neutral']).not.toBe(cool['--color-neutral']);+ });+});++describe('accent precedence — color config vs tokens overrides (#2279)', () => {+ const CONFIG_ACCENT: [string, string] = ['#B7410E', '#48CAE4'];+ const TOKEN_ACCENT: [string, string] = ['#AA0000', '#FF5555'];++ it('tokens["--color-accent"] wins over the color-generated accent', () => {+ const theme = defineTheme({+ name: 'precedence-base',+ color: {accent: CONFIG_ACCENT},+ tokens: {'--color-accent': TOKEN_ACCENT},+ });+ expect(theme.tokens['--color-accent']).toBe(+ `light-dark(${TOKEN_ACCENT[0]}, ${TOKEN_ACCENT[1]})`,+ );+ });++ it('reference tokens follow the tokens override at runtime', () => {+ const theme = defineTheme({+ name: 'precedence-refs',+ color: {accent: CONFIG_ACCENT},+ tokens: {'--color-accent': TOKEN_ACCENT},+ });+ const light = resolveThemeTokens(theme, {mode: 'light'});+ expect(light['--color-text-accent']).toBe(TOKEN_ACCENT[0]);+ expect(light['--color-icon-accent']).toBe(TOKEN_ACCENT[0]);+ const dark = resolveThemeTokens(theme, {mode: 'dark'});+ expect(dark['--color-text-accent']).toBe(TOKEN_ACCENT[1]);+ });++ it('baked --color-on-accent stays derived from the color.accent seed', () => {+ // Documented divergence: a tokens override of --color-accent does not+ // re-derive --color-on-accent, which is a baked contrast computation+ // against the color.accent seed. Consumers who override the accent via+ // tokens must override --color-on-accent too (or pass the tuple through+ // color.accent so the whole palette re-derives).+ const overridden = defineTheme({+ name: 'precedence-on-accent',+ color: {accent: CONFIG_ACCENT},+ tokens: {'--color-accent': TOKEN_ACCENT},+ });+ const generated = defineTheme({+ name: 'generated-on-accent',+ color: {accent: CONFIG_ACCENT},+ });+ expect(overridden.tokens['--color-on-accent']).toBe(+ generated.tokens['--color-on-accent'],+ );+ });++ it('an explicit --color-on-accent token wins over the generated one', () => {+ const theme = defineTheme({+ name: 'precedence-on-accent-explicit',+ color: {accent: CONFIG_ACCENT},+ tokens: {'--color-on-accent': '#FFFFFF'},+ });+ expect(theme.tokens['--color-on-accent']).toBe('#FFFFFF');+ });+});+describe('expandColorScale + defineTheme integration', () => {it('explicit token overrides win over generated values', () => {const theme = defineTheme({diff --git a/packages/core/src/theme/expandColorScale.ts b/packages/core/src/theme/expandColorScale.tsindex a1c439f7fe..7a77b89d52 100644--- a/packages/core/src/theme/expandColorScale.ts+++ b/packages/core/src/theme/expandColorScale.ts@@ -6,8 +6,8 @@* @output Token overrides for derivable color tokens* @position Theme utility; consumed by defineTheme.ts*- * Generates color token overrides from a single accent color using the- * HCT perceptual color model. Only produces tokens that meaningfully+ * Generates color token overrides from an accent seed using the HCT+ * perceptual color model. Only produces tokens that meaningfully* derive from the accent — status colors, categorical hues, and fixed* tokens (on-dark/on-light) fall through to colorDefaults.*@@ -15,11 +15,19 @@* ramp (seeded from the default accent's hue) while the accent tokens* themselves fall through to colorDefaults, same as the tokens above.*+ * `accent` also accepts a `[light, dark]` tuple (matching `TokenValue` in+ * defineTheme). A tuple seeds each color scheme from its own half: the+ * light side of every generated `light-dark()` pair derives from the light+ * accent's palettes, the dark side from the dark accent's. A plain string+ * seeds both sides identically, token for token the same output as before+ * tuples existed.+ ** WCAG contrast guarantees (asserted in expandColorScale.test.ts):* - Text tones are guaranteed >= 4.5:1 against their surfaces by tone* spacing alone — HCT tone is CIE L*, which fixes relative luminance* regardless of hue/chroma, so the fixed tone assignments hold for any- * accent/neutralStyle (WCAG 1.4.3).+ * accent/neutralStyle (WCAG 1.4.3), and each half of a tuple pairs with+ * surfaces derived from that same seed.* - --color-border-emphasized (form-control boundaries) is tone-bumped* until it reaches >= 3:1 against the generated surface (WCAG 1.4.11).* - --color-border, --color-skeleton, and --color-track are intentionally@@ -46,6 +54,9 @@ import {hexToHct, hctToHex, tonalPalette, hexWithAlpha} from './hct';* // Minimal — just a seed color* { accent: '#0064E0' }*+ * // Per-scheme seeds: light palettes from '#0064E0', dark from '#48CAE4'+ * { accent: ['#0064E0', '#48CAE4'] }+ ** // With customization* { accent: '#B7410E', neutralStyle: 'warm', contrast: 'high' }*@@ -55,14 +66,18 @@ import {hexToHct, hctToHex, tonalPalette, hexWithAlpha} from './hct';*/export interface ColorScaleConfig {/**- * Seed accent color as hex (#RRGGBB). Everything derives from this.+ * Seed accent color. Everything derives from this.+ *+ * Either a single hex (#RRGGBB) used for both color schemes, or a+ * `[light, dark]` hex tuple: the light scheme's palettes derive from+ * the light seed and the dark scheme's palettes from the dark seed.** Optional. When omitted, the neutral palettes are seeded from the* default accent's hue and the accent tokens (--color-accent,* --color-accent-muted, --color-on-accent) are not generated — they* fall through to colorDefaults.*/- accent?: string;+ accent?: string | [light: string, dark: string];/*** Neutral tone warmth. Controls how much of the seed's hue bleeds@@ -159,6 +174,11 @@ export function ensureContrastTone(* --color-on-dark/on-light) are NOT generated — they fall through* to colorDefaults.*+ * A `[light, dark]` tuple accent seeds each scheme separately: the light+ * half of every generated `light-dark()` pair comes from the light seed's+ * palettes, the dark half from the dark seed's. A string accent seeds both+ * halves from the same palettes, exactly as before tuples were supported.+ ** Without an `accent`, the accent tokens join that fall-through set: the* neutrals are seeded from the default accent's hue, and --color-accent,* --color-accent-muted and --color-on-accent keep their colorDefaults values.@@ -168,6 +188,9 @@ export function ensureContrastTone(* const tokens = expandColorScale({ accent: '#0064E0' });* // tokens['--color-accent'] === 'light-dark(#..., #...)'*+ * const perScheme = expandColorScale({ accent: ['#0064E0', '#48CAE4'] });+ * // light half derives from #0064E0, dark half from #48CAE4+ ** const neutralOnly = expandColorScale({ neutralStyle: 'warm' });* // neutralOnly['--color-accent'] === undefined* ```@@ -175,16 +198,33 @@ export function ensureContrastTone(export function expandColorScale(config: ColorScaleConfig): ColorScaleTokens {const {accent, neutralStyle = 'cool', contrast = 'standard'} = config;- const seed = hexToHct(accent ?? DEFAULT_ACCENT_SEED);- const seedHue = seed.hue;+ // Normalize to per-scheme seeds. A string accent (or an absent one) uses+ // the same seed for both halves, which keeps single-seed output identical+ // to the pre-tuple implementation.+ const [lightAccent, darkAccent] = Array.isArray(accent)+ ? accent+ : [accent, accent];++ const lightSeed = hexToHct(lightAccent ?? DEFAULT_ACCENT_SEED);+ const sameSeed = darkAccent === lightAccent;+ const darkSeed = sameSeed+ ? lightSeed+ : hexToHct(darkAccent ?? DEFAULT_ACCENT_SEED);- const primaryChroma = Math.max(seed.chroma, 48);const neutralChroma = NEUTRAL_CHROMA[neutralStyle] ?? 5;const neutralVariantChroma = NEUTRAL_VARIANT_CHROMA[neutralStyle] ?? 8;- const P = tonalPalette(seedHue, primaryChroma);- const N = tonalPalette(seedHue, neutralChroma);- const NV = tonalPalette(seedHue, neutralVariantChroma);+ // Palette naming: *L palettes feed the light (first) half of each ld()+ // pair below, *D palettes the dark (second) half. With a single seed the+ // D palettes alias the L ones.+ const PL = tonalPalette(lightSeed.hue, Math.max(lightSeed.chroma, 48));+ const NL = tonalPalette(lightSeed.hue, neutralChroma);+ const NVL = tonalPalette(lightSeed.hue, neutralVariantChroma);+ const PD = sameSeed+ ? PL+ : tonalPalette(darkSeed.hue, Math.max(darkSeed.chroma, 48));+ const ND = sameSeed ? NL : tonalPalette(darkSeed.hue, neutralChroma);+ const NVD = sameSeed ? NVL : tonalPalette(darkSeed.hue, neutralVariantChroma);const isHigh = contrast === 'high';@@ -209,19 +249,19 @@ export function expandColorScale(config: ColorScaleConfig): ColorScaleTokens {const borderEmphasizedStartDark = isHigh ? 50 : 30;const borderEmphasized = ld(ensureContrastTone(- seedHue,+ lightSeed.hue,neutralVariantChroma,borderEmphasizedStartLight,-1,- N[99],+ NL[99],NON_TEXT_MIN_CONTRAST,),ensureContrastTone(- seedHue,+ darkSeed.hue,neutralVariantChroma,borderEmphasizedStartDark,1,- N[10],+ ND[10],NON_TEXT_MIN_CONTRAST,),);@@ -234,7 +274,7 @@ export function expandColorScale(config: ColorScaleConfig): ColorScaleTokens {// seed above, so a supplied-but-malformed accent keeps its old behavior....(accent != null? {- '--color-accent': ld(P[40], P[80]),+ '--color-accent': ld(PL[40], PD[80]),// Derived accent tokens reference --color-accent instead of baking its// resolved hex, so a scoped override of the base token re-accents the// whole subtree at runtime. --color-on-accent stays baked: it is a@@ -243,65 +283,70 @@ export function expandColorScale(config: ColorScaleConfig): ColorScaleTokens {accentWithAlpha(0.2),accentWithAlpha(0.25),),- '--color-on-accent': ld(P[100], P[20]),+ '--color-on-accent': ld(PL[100], PD[20]),}: null),- '--color-neutral': ld(hexWithAlpha(N[10], 0.1), hexWithAlpha(N[90], 0.2)),- '--color-background-surface': ld(N[99], N[10]),- '--color-background-body': ld(N[95], N[5]),- '--color-overlay': ld(hexWithAlpha(N[10], 0.4), hexWithAlpha(N[10], 0.6)),+ '--color-neutral': ld(hexWithAlpha(NL[10], 0.1), hexWithAlpha(ND[90], 0.2)),+ '--color-background-surface': ld(NL[99], ND[10]),+ '--color-background-body': ld(NL[95], ND[5]),+ '--color-overlay': ld(hexWithAlpha(NL[10], 0.4), hexWithAlpha(ND[10], 0.6)),'--color-overlay-hover': ld(- hexWithAlpha(N[10], 0.05),- hexWithAlpha(N[100], 0.05),+ hexWithAlpha(NL[10], 0.05),+ hexWithAlpha(ND[100], 0.05),),'--color-overlay-pressed': ld(- hexWithAlpha(N[10], 0.1),- hexWithAlpha(N[100], 0.1),+ hexWithAlpha(NL[10], 0.1),+ hexWithAlpha(ND[100], 0.1),),'--color-background-muted': ld(- hexWithAlpha(N[10], 0.05),- hexWithAlpha(N[10], 0.5),+ hexWithAlpha(NL[10], 0.05),+ hexWithAlpha(ND[10], 0.5),),// Text- '--color-text-primary': ld(N[textPrimaryLightTone], N[textPrimaryDarkTone]),+ '--color-text-primary': ld(+ NL[textPrimaryLightTone],+ ND[textPrimaryDarkTone],+ ),'--color-text-secondary': ld(- NV[textSecondaryLightTone],- NV[textSecondaryDarkTone],+ NVL[textSecondaryLightTone],+ NVD[textSecondaryDarkTone],),- '--color-text-disabled': ld(NV[60], NV[40]),+ '--color-text-disabled': ld(NVL[60], NVD[40]),'--color-text-accent': 'var(--color-accent)',// Icon'--color-icon-accent': 'var(--color-accent)',- '--color-icon-primary': ld(N[textPrimaryLightTone], N[textPrimaryDarkTone]),+ '--color-icon-primary': ld(+ NL[textPrimaryLightTone],+ ND[textPrimaryDarkTone],+ ),'--color-icon-secondary': ld(- NV[textSecondaryLightTone],- NV[textSecondaryDarkTone],+ NVL[textSecondaryLightTone],+ NVD[textSecondaryDarkTone],),- '--color-icon-disabled': ld(NV[60], NV[40]),+ '--color-icon-disabled': ld(NVL[60], NVD[40]),// Surface variants- '--color-background-card': ld(N[99], N[10]),- '--color-background-popover': ld(N[99], N[20]),- '--color-background-inverted': ld(N[10], N[99]),+ '--color-background-card': ld(NL[99], ND[10]),+ '--color-background-popover': ld(NL[99], ND[20]),+ '--color-background-inverted': ld(NL[10], ND[99]),- // Border// Border// Decorative hairline — not a WCAG 1.4.11 boundary. High contrast// doubles the alpha so structural boundaries stay perceivable.'--color-border': ld(- hexWithAlpha(N[10], borderSubtleAlpha),- hexWithAlpha(N[95], borderSubtleAlpha),+ hexWithAlpha(NL[10], borderSubtleAlpha),+ hexWithAlpha(ND[95], borderSubtleAlpha),),'--color-border-emphasized': borderEmphasized,// Effects- '--color-skeleton': ld(NV[70], NV[30]),+ '--color-skeleton': ld(NVL[70], NVD[30]),// Channel-on-body surface (ProgressBar/Slider tracks, Switch off-state).// Defaults to the same NV[70]/NV[30] ramp stop as --color-skeleton.- '--color-track': ld(NV[70], NV[30]),- '--color-shadow': ld(hexWithAlpha(N[0], 0.1), hexWithAlpha(N[0], 0.3)),+ '--color-track': ld(NVL[70], NVD[30]),+ '--color-shadow': ld(hexWithAlpha(NL[0], 0.1), hexWithAlpha(ND[0], 0.3)),'--color-tint-hover': ld('black', 'white'),};}