An open source design system that's fully customizable and agent ready
TypeScript
fix(theme): the stock theme's dark-mode accent is darker, so white button text meets 4.5:1 (#9818)
Cindy Zhang504ee1863e56
diff --git a/.changeset/stock-dark-accent-contrast.md b/.changeset/stock-dark-accent-contrast.mdnew file mode 100644index 0000000000..619ff6118b--- /dev/null+++ b/.changeset/stock-dark-accent-contrast.md@@ -0,0 +1,8 @@+---+'@astryxdesign/core': patch+'@astryxdesign/cli': patch+---++[fix] The stock theme's dark-mode accent (`--color-accent`) is now `#0171E3` instead of `#2694FE`, so white text on an accent fill, such as a primary Button's label at rest, meets 4.5:1 (4.70:1, was 3.11:1). Hovered and pressed primary Buttons improve too (about 4.36:1 and 4.03:1, from under 3:1) but stay under 4.5:1. Light mode keeps `#0064E0`. Everything else painted with `--color-accent` in dark mode also darkens: accent fills, focus rings and accent icons. MetadataList's "Show more", Table's sort rank and DateRangeInput's applied preset now use `--color-text-accent`, so their text stays readable on dark surfaces. The theme template that `astryx theme template` writes uses the same dark accent, and the generated color token docs list it. To keep the previous look, a theme can set `'--color-accent': ['#0064E0', '#2694FE']`.++@cixzhangdiff --git a/docs/architecture/theme-tokens.md b/docs/architecture/theme-tokens.mdindex 0bbb5cb740..c05fe23c8f 100644--- a/docs/architecture/theme-tokens.md+++ b/docs/architecture/theme-tokens.md@@ -36,7 +36,17 @@ deciding_specs: [spec:AST-006/DEC-1, spec:AST-006/DEC-5]{"scope": "global","triggers": {- "tokens": ["INV1", "INV3", "INV4", "INV6", "INV8", "INV9", "INV10", "INV11"]+ "tokens": [+ "INV1",+ "INV3",+ "INV4",+ "INV6",+ "INV8",+ "INV9",+ "INV10",+ "INV11",+ "INV12"+ ]}}```@@ -196,6 +206,9 @@ then have contradictory winners.status text role; like every Tailwind key, these alias the tokens and add noCSS variable.+- **INV12 — The stock accent pair meets 4.5:1.** `--color-on-accent` on+ `--color-accent` meets 4.5:1 in light and dark mode in Core's defaults.+This record does not own:- the `defineTheme` input shape, generated scales, or precedence;@@ -298,5 +311,6 @@ decision).| INV9 | `tokens.test.ts` (core defaults), `SpacingRootFontSize.a11y.chromium.spec.ts` (real-Chromium root font size), each overriding theme's `*Theme.spacing.test.ts`, `check-cli-theme-bundle.test.mjs` (bundled copies byte-equal to the packages), `theme-concentricity.test.ts` (playground ramp read in rem) | A spacing step in `px` that no theme documents as its exception: a core default, a theme override, a bundled copy, or a generated ramp step || INV10 | `tokens.test.ts` name check over Astryx's own `colorDefaults` and `domainTokenDefaults` only | A colour token Astryx defines fits none of the five shapes || INV11 | `scripts/check-muted-status-contrast.test.mjs` (resolves global and Banner pale-surface role pairs), `scripts/check-badge-contrast.test.mjs` (resolves Core Badge defaults plus theme overrides), `scripts/check-status-text-contrast.test.mjs` (resolves `--color-on-<status>` on each strong fill, and `--color-text-<status>`, `--color-icon-<status>`, and `--color-border-<status>` against the surface and card tokens and checks that each status fill and text colour is chromatic in every first-party theme), `neutralTheme.test.ts` (pins reviewed role values and pairings), `tailwind-theme.test.ts` (pins the status utilities, including the released base ones), forced-colors assertions in the Badge, StatusDot, and Banner tests, and theme alias-generation tests | A status role is missing, mispaired, grey, routed to the wrong public utility, or falls below its contrast threshold in light or dark mode, a status fill loses its border in forced-colors mode, or a released status fill or utility changes value without a recorded reason |+| INV12 | `packages/core/src/theme/contrast.test.ts` "the stock accent pair meets 4.5:1 in the light/dark theme" (current values: light `#0064E0`, dark `#0171E3`, label `#FFFFFF`) | The stock `--color-on-accent` on `--color-accent` falls below 4.5:1 in light or dark mode || Released token compatibility | Type checking plus representative package/source builds | A released CSS variable or typed token name disappears without an explicit migration decision || Visual defaults | Real Chromium examples in light, dark, status, and high-contrast contexts | A changed default produces unreadable or semantically inconsistent output |diff --git a/docs/specs/components/Button/Button.spec.md b/docs/specs/components/Button/Button.spec.mdindex abd2f106d4..96d9a97b8e 100644--- a/docs/specs/components/Button/Button.spec.md+++ b/docs/specs/components/Button/Button.spec.md@@ -210,6 +210,9 @@ Consumer migration instructions belong in consumer docs and release notes.`width` or a theme icon-only aspect that makes a Button narrower than 24 CSSpixels leaves its target size to that caller or theme.+Implementation gap: Button's hover and pressed overlays on the dark accent give+its label 4.35:1 and 4.02:1, under 4.5:1.+## Design relationships| Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |diff --git a/docs/specs/components/DateRangeInput/DateRangeInput.spec.md b/docs/specs/components/DateRangeInput/DateRangeInput.spec.mdindex 7fa8d3b706..e132c4dc9f 100644--- a/docs/specs/components/DateRangeInput/DateRangeInput.spec.md+++ b/docs/specs/components/DateRangeInput/DateRangeInput.spec.md@@ -125,6 +125,9 @@ No new performance or resource constraint is introduced.a range-span constraint is disabled and stays focusable (`spec:AST-085`); themestate reflection does not replace that behavior.+Implementation gap: in dark mode the applied preset's label on its muted accent+fill measures 3.88:1 on the popover surface, under 4.5:1.+## Design relationships| Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |diff --git a/packages/cli/assets/docs/tree/tokens-color.doc.mjs b/packages/cli/assets/docs/tree/tokens-color.doc.mjsindex 6838bec5f0..df492d10f9 100644--- a/packages/cli/assets/docs/tree/tokens-color.doc.mjs+++ b/packages/cli/assets/docs/tree/tokens-color.doc.mjs@@ -86,7 +86,7 @@ export const docs = {["--color-accent","#0064E0",- "#2694FE"+ "#0171E3"],["--color-accent-muted",diff --git a/packages/cli/assets/theme.template.ts b/packages/cli/assets/theme.template.tsindex 0c484f1f55..d55fc91816 100644--- a/packages/cli/assets/theme.template.ts+++ b/packages/cli/assets/theme.template.ts@@ -248,7 +248,7 @@ export const myTheme = defineTheme({// palette.neutral.light[100],// palette.neutral.dark[15],// ],- '--color-accent': ['#0064E0', '#2694FE'],+ '--color-accent': ['#0064E0', '#0171E3'],// Changing an accent means owning its on-colour: this is the label that// sits on top of the fill above, in each mode.'--color-on-accent': ['#FFFFFF', '#FFFFFF'],diff --git a/packages/core/api-report.md b/packages/core/api-report.mdindex 49edb3a493..496618e758 100644--- a/packages/core/api-report.md+++ b/packages/core/api-report.md@@ -3179,7 +3179,7 @@ const WIDTH_BREAKPOINT_NAMES: readonly ["sm", "md", "lg", "xl", "2xl"]const borderDefaults: { readonly '--border-width': "1px" }const borderVars: stylex.VarGroup<Readonly<{ readonly '--border-width': "1px" }>, symbol>const colorDefaults: object- --color-accent: 'light-dark(#0064E0, #2694FE)'+ --color-accent: 'light-dark(#0064E0, #0171E3)'--color-accent-muted: 'light-dark(#0082FB33, #0082FB3F)'--color-on-accent: 'light-dark(#FFFFFF, #FFFFFF)'--color-neutral: 'light-dark(rgba(5, 54, 89, 0.1), rgba(223, 226, 229, 0.2))'@@ -3277,7 +3277,7 @@ const colorDefaults: object--color-border-yellow: 'light-dark(#C58600, #B47700)'--color-icon-yellow: 'light-dark(#FBC02D, #FFEE58)'--color-text-yellow: 'light-dark(#753F07, #FBCE03)'-const colorVars: stylex.VarGroup<Readonly<{ readonly '--color-accent': "light-dark(#0064E0, #2694FE)"; readonly '--color-accent-muted': "light-dark(#0082FB33, #0082FB3F)"; reado … #a042f923+const colorVars: stylex.VarGroup<Readonly<{ readonly '--color-accent': "light-dark(#0064E0, #0171E3)"; readonly '--color-accent-muted': "light-dark(#0082FB33, #0082FB3F)"; reado … #a042f923const dataTokenDefaults: object--color-data-categorical-blue: 'light-dark(#0171E3, #0171E3)'--color-data-categorical-orange: 'light-dark(#EB6E00, #EB6E00)'diff --git a/packages/core/src/DateRangeInput/DateRangeInput.tsx b/packages/core/src/DateRangeInput/DateRangeInput.tsxindex 725ded6637..7b062c33e6 100644--- a/packages/core/src/DateRangeInput/DateRangeInput.tsx+++ b/packages/core/src/DateRangeInput/DateRangeInput.tsx@@ -238,7 +238,7 @@ const styles = stylex.create({},presetButtonActive: {backgroundColor: colorVars['--color-accent-muted'],- color: colorVars['--color-accent'],+ color: colorVars['--color-text-accent'],},presetButtonDisabled: {color: colorVars['--color-text-disabled'],diff --git a/packages/core/src/MetadataList/MetadataList.tsx b/packages/core/src/MetadataList/MetadataList.tsxindex 64db0e21b8..0255569267 100644--- a/packages/core/src/MetadataList/MetadataList.tsx+++ b/packages/core/src/MetadataList/MetadataList.tsx@@ -158,7 +158,7 @@ const styles = stylex.create({default: 'pointer',':is(:disabled,[aria-disabled="true"])': 'default',},- color: colorVars['--color-accent'],+ color: colorVars['--color-text-accent'],fontSize: typeScaleVars['--text-body-size'],lineHeight: typeScaleVars['--text-body-leading'],fontWeight: fontWeightVars['--font-weight-medium'],diff --git a/packages/core/src/Table/plugins/sortable/useTableSortable.tsx b/packages/core/src/Table/plugins/sortable/useTableSortable.tsxindex ca23e27e8f..30c8695a1b 100644--- a/packages/core/src/Table/plugins/sortable/useTableSortable.tsx+++ b/packages/core/src/Table/plugins/sortable/useTableSortable.tsx@@ -168,7 +168,7 @@ const sortStyles = stylex.create({fontSize: 10,// eslint-disable-next-line @astryx/no-hardcoded-styles -- no token for lineHeight:1 (tight badge)lineHeight: '1',- color: colorVars['--color-accent'],+ color: colorVars['--color-text-accent'],},});diff --git a/packages/core/src/theme/contrast.test.ts b/packages/core/src/theme/contrast.test.tsindex 3fbd80c02d..8b911aa750 100644--- a/packages/core/src/theme/contrast.test.ts+++ b/packages/core/src/theme/contrast.test.ts@@ -3,6 +3,7 @@import {describe, it, expect} from 'vitest';import {relativeLuminance, compositeOver, contrastRatio} from './contrast';import {parseColor} from '../utils/color';+import {resolveThemeToken} from './tokens';describe('relativeLuminance', () => {it('is 0 for black and 1 for white', () => {@@ -92,3 +93,13 @@ describe('compositeOver', () => {expect(out.a).toBe(1);});});++describe('the stock accent pair', () => {+ // --color-on-accent is the label on every --color-accent fill, such as a+ // primary Button's, which is normal-size text (WCAG 1.4.3: 4.5:1).+ it.each(['light', 'dark'] as const)('meets 4.5:1 in the %s theme', mode => {+ const accent = resolveThemeToken(null, '--color-accent', {mode});+ const onAccent = resolveThemeToken(null, '--color-on-accent', {mode});+ expect(contrastRatio(onAccent, accent)).toBeGreaterThanOrEqual(4.5);+ });+});diff --git a/packages/core/src/theme/expandColorScale.test.ts b/packages/core/src/theme/expandColorScale.test.tsindex 0262523954..32515060c0 100644--- a/packages/core/src/theme/expandColorScale.test.ts+++ b/packages/core/src/theme/expandColorScale.test.ts@@ -12,7 +12,7 @@ import {parseColor, formatColor} from '../utils/color';/** Light-mode half of colorDefaults['--color-accent'] — the hue an accent-less config seeds from. */const DEFAULT_ACCENT = '#0064E0';-const DEFAULT_ACCENT_DARK = '#2694FE';+const DEFAULT_ACCENT_DARK = '#0171E3';/** The three tokens that only exist when a seed accent is supplied. */const ACCENT_TOKENS = [diff --git a/packages/core/src/theme/tokens.stylex.ts b/packages/core/src/theme/tokens.stylex.tsindex 80acab6307..ec6ecd40da 100644--- a/packages/core/src/theme/tokens.stylex.ts+++ b/packages/core/src/theme/tokens.stylex.ts@@ -24,7 +24,7 @@ import * as stylex from '@stylexjs/stylex';export const colorDefaults = {// Core semantic- '--color-accent': 'light-dark(#0064E0, #2694FE)',+ '--color-accent': 'light-dark(#0064E0, #0171E3)','--color-accent-muted': 'light-dark(#0082FB33, #0082FB3F)','--color-on-accent': 'light-dark(#FFFFFF, #FFFFFF)','--color-neutral':diff --git a/packages/native/apple/Sources/Astryx/Theme/Generated/DefaultTheme.swift b/packages/native/apple/Sources/Astryx/Theme/Generated/DefaultTheme.swiftindex 92c709ac29..275c9080e9 100644--- a/packages/native/apple/Sources/Astryx/Theme/Generated/DefaultTheme.swift+++ b/packages/native/apple/Sources/Astryx/Theme/Generated/DefaultTheme.swift@@ -242,7 +242,7 @@ extension Theme {),dark: Tokens(color: ColorTokens(- accent: Color(.sRGB, red: 0.14901960784313725, green: 0.5803921568627451, blue: 0.996078431372549, opacity: 1),+ accent: Color(.sRGB, red: 0.00392156862745098, green: 0.44313725490196076, blue: 0.8901960784313725, opacity: 1),accentMuted: Color(.sRGB, red: 0, green: 0.5098039215686274, blue: 0.984313725490196, opacity: 0.24705882352941178),backgroundBlue: Color(.sRGB, red: 0.00392156862745098, green: 0.44313725490196076, blue: 0.8901960784313725, opacity: 0.2),backgroundBody: Color(.sRGB, red: 0.06666666666666667, green: 0.06666666666666667, blue: 0.07058823529411765, opacity: 1),