Skip to content

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

TypeScript

fix(theme-neutral): the selected fill is visible on every surface in both modes (#10093)

Cindy Zhang7f296f17ece4
diff --git a/.changeset/neutral-selected-fill.md b/.changeset/neutral-selected-fill.md
new file mode 100644
index 0000000000..908a97002c
--- /dev/null
+++ b/.changeset/neutral-selected-fill.md
@@ -0,0 +1,8 @@
+---
+'@astryxdesign/theme-neutral': patch
+'@astryxdesign/cli': patch
+---
+
+[fix] Under the Neutral theme, a selected row, a calendar range and the other selected fills on Neutral's surfaces are visible again, and highlighted code lines are stronger. `--color-accent-muted` matched the surface in dark mode and barely differed from the hover tint in light mode; it is now `#d4d4d4` in light and `#474747` in dark. In dark mode a selected Item, TreeListItem or checked CheckboxListItem row, a numbered Citation and a FileInput dropzone lift their secondary text so it stays readable on the fill; a dropzone's hint is slightly lighter at rest too. Neutral's code comments, operators and punctuation are slightly less muted so they stay readable on a highlighted line. The CLI's Neutral theme template carries the same values.
+
+@cixzhang
diff --git a/packages/cli/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts b/packages/cli/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts
index 54e673774e..878eac928e 100644
--- a/packages/cli/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts
+++ b/packages/cli/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts
@@ -15,8 +15,8 @@ export const neutralPaletteRefs = {
dark: {25: '#2b422b', 80: '#aad4a9', 85: '#bce0bb'},
},
neutral: {
- light: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 30: '#474747', 45: '#6a6a6a', 60: '#919191', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
- dark: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 15: '#262626', 20: '#303030', 35: '#525252', 65: '#9e9e9e', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
+ light: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 30: '#474747', 35: '#525252', 45: '#6a6a6a', 60: '#919191', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
+ dark: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 15: '#262626', 20: '#303030', 30: '#474747', 35: '#525252', 65: '#9e9e9e', 75: '#b9b9b9', 80: '#c6c6c6', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
},
orange: {
light: {25: '#622700', 30: '#733100', 75: '#ff9e55', 85: '#ffc7a1'},
diff --git a/packages/cli/assets/templates/themes/neutral/neutralTheme.ts b/packages/cli/assets/templates/themes/neutral/neutralTheme.ts
index ba07f2c263..bbb4d2ffe2 100644
--- a/packages/cli/assets/templates/themes/neutral/neutralTheme.ts
+++ b/packages/cli/assets/templates/themes/neutral/neutralTheme.ts
@@ -17,17 +17,17 @@ const neutralSyntax = defineSyntaxTheme({
tokens: {
keyword: [purple.light[30], purple.light[80]],
string: [green.light[30], green.light[80]],
- comment: [neutral.light[45], neutral.dark[65]],
+ comment: [neutral.light[35], neutral.dark[75]],
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]],
+ operator: [neutral.light[35], neutral.dark[75]],
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]],
+ punctuation: [neutral.light[35], neutral.dark[75]],
background: [neutral.light[100], neutral.dark[5]],
},
});
@@ -94,7 +94,7 @@ export const neutralTheme = defineTheme({
'--color-background-muted': [neutral.light[95], neutral.dark[10]],
'--color-accent': [neutral.light[10], neutral.dark[95]],
- '--color-accent-muted': [neutral.light[95], neutral.dark[15]],
+ '--color-accent-muted': [neutral.light[85], neutral.dark[30]],
'--color-neutral': [
withAlpha(neutral.light[0], '0F'),
withAlpha(neutral.dark[100], '1A'),
@@ -273,6 +273,32 @@ export const neutralTheme = defineTheme({
},
components: {
+ // In dark mode, secondary text falls under 4.5:1 on the selected fill
+ // and under its hover. Selected rows use the next stop that clears both.
+ item: {
+ selected: {
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
+ },
+ },
+ 'tree-list-item': {
+ selected: {
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
+ },
+ },
+ // A dropzone's hint sits on the same fill while a file is dragged over.
+ // That state has no target, so the dropzone takes the lift at rest too.
+ 'file-input': {
+ 'mode:dropzone': {
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
+ },
+ },
+ // A numbered citation is a pill on the same fill.
+ citation: {
+ 'variant:number': {
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
+ },
+ },
+
button: {
'variant:destructive': {
backgroundColor: 'var(--color-error-muted)',
diff --git a/packages/native/apple/Sources/Astryx/Theme/Generated/NeutralTheme.swift b/packages/native/apple/Sources/Astryx/Theme/Generated/NeutralTheme.swift
index dd903e17b5..653ed66ae4 100644
--- a/packages/native/apple/Sources/Astryx/Theme/Generated/NeutralTheme.swift
+++ b/packages/native/apple/Sources/Astryx/Theme/Generated/NeutralTheme.swift
@@ -10,7 +10,7 @@ extension Theme {
light: Tokens(
color: ColorTokens(
accent: Color(.sRGB, red: 0.10588235294117647, green: 0.10588235294117647, blue: 0.10588235294117647, opacity: 1),
- accentMuted: Color(.sRGB, red: 0.9450980392156862, green: 0.9450980392156862, blue: 0.9450980392156862, opacity: 1),
+ accentMuted: Color(.sRGB, red: 0.8313725490196079, green: 0.8313725490196079, blue: 0.8313725490196079, opacity: 1),
backgroundBlue: Color(.sRGB, red: 0.7254901960784313, green: 0.8431372549019608, blue: 1, opacity: 1),
backgroundBody: Color(.sRGB, red: 0.9450980392156862, green: 0.9450980392156862, blue: 0.9450980392156862, opacity: 1),
backgroundCard: Color(.sRGB, red: 1, green: 1, blue: 1, opacity: 1),
@@ -142,20 +142,20 @@ extension Theme {
success: Color(.sRGB, red: 0.09803921568627451, green: 0.5058823529411764, blue: 0, opacity: 1),
successMuted: Color(.sRGB, red: 0.7372549019607844, green: 0.8784313725490196, blue: 0.7333333333333333, opacity: 1),
syntaxAdded: Color(.sRGB, red: 0.7372549019607844, green: 0.8784313725490196, blue: 0.7333333333333333, opacity: 0.25098039215686274),
- syntaxAddedMarker: Color(.sRGB, red: 0.41568627450980394, green: 0.41568627450980394, blue: 0.41568627450980394, opacity: 1),
+ syntaxAddedMarker: Color(.sRGB, red: 0.3215686274509804, green: 0.3215686274509804, blue: 0.3215686274509804, opacity: 1),
syntaxAttribute: Color(.sRGB, red: 0.34509803921568627, green: 0.26666666666666666, blue: 0, opacity: 1),
syntaxBackground: Color(.sRGB, red: 1, green: 1, blue: 1, opacity: 1),
- syntaxComment: Color(.sRGB, red: 0.41568627450980394, green: 0.41568627450980394, blue: 0.41568627450980394, opacity: 1),
+ syntaxComment: Color(.sRGB, red: 0.3215686274509804, green: 0.3215686274509804, blue: 0.3215686274509804, opacity: 1),
syntaxConstant: Color(.sRGB, red: 0.45098039215686275, green: 0.19215686274509805, blue: 0, opacity: 1),
syntaxDiffHeader: Color(.sRGB, red: 0, green: 0, blue: 0, opacity: 0),
syntaxFunction: Color(.sRGB, red: 0, green: 0.27058823529411763, blue: 0.5490196078431373, opacity: 1),
syntaxKeyword: Color(.sRGB, red: 0.4196078431372549, green: 0.09411764705882353, blue: 0.48627450980392156, opacity: 1),
syntaxNumber: Color(.sRGB, red: 0.45098039215686275, green: 0.19215686274509805, blue: 0, opacity: 1),
- syntaxOperator: Color(.sRGB, red: 0.41568627450980394, green: 0.41568627450980394, blue: 0.41568627450980394, opacity: 1),
+ syntaxOperator: Color(.sRGB, red: 0.3215686274509804, green: 0.3215686274509804, blue: 0.3215686274509804, opacity: 1),
syntaxProperty: Color(.sRGB, red: 0, green: 0.3254901960784314, blue: 0.2823529411764706, opacity: 1),
- syntaxPunctuation: Color(.sRGB, red: 0.41568627450980394, green: 0.41568627450980394, blue: 0.41568627450980394, opacity: 1),
+ syntaxPunctuation: Color(.sRGB, red: 0.3215686274509804, green: 0.3215686274509804, blue: 0.3215686274509804, opacity: 1),
syntaxRemoved: Color(.sRGB, red: 1, green: 0.7686274509803922, blue: 0.7450980392156863, opacity: 0.25098039215686274),
- syntaxRemovedMarker: Color(.sRGB, red: 0.41568627450980394, green: 0.41568627450980394, blue: 0.41568627450980394, opacity: 1),
+ syntaxRemovedMarker: Color(.sRGB, red: 0.3215686274509804, green: 0.3215686274509804, blue: 0.3215686274509804, opacity: 1),
syntaxString: Color(.sRGB, red: 0.043137254901960784, green: 0.33725490196078434, blue: 0.08235294117647059, opacity: 1),
syntaxTag: Color(.sRGB, red: 0.5411764705882353, green: 0, blue: 0.06666666666666667, opacity: 1),
syntaxType: Color(.sRGB, red: 0.4196078431372549, green: 0.09411764705882353, blue: 0.48627450980392156, opacity: 1),
@@ -243,7 +243,7 @@ extension Theme {
dark: Tokens(
color: ColorTokens(
accent: Color(.sRGB, red: 0.9450980392156862, green: 0.9450980392156862, blue: 0.9450980392156862, opacity: 1),
- accentMuted: Color(.sRGB, red: 0.14901960784313725, green: 0.14901960784313725, blue: 0.14901960784313725, opacity: 1),
+ accentMuted: Color(.sRGB, red: 0.2784313725490196, green: 0.2784313725490196, blue: 0.2784313725490196, opacity: 1),
backgroundBlue: Color(.sRGB, red: 0.1450980392156863, green: 0.23529411764705882, blue: 0.35294117647058826, opacity: 1),
backgroundBody: Color(.sRGB, red: 0.10588235294117647, green: 0.10588235294117647, blue: 0.10588235294117647, opacity: 1),
backgroundCard: Color(.sRGB, red: 0.10588235294117647, green: 0.10588235294117647, blue: 0.10588235294117647, opacity: 1),
@@ -375,20 +375,20 @@ extension Theme {
success: Color(.sRGB, red: 0.39215686274509803, green: 0.6862745098039216, blue: 0.2980392156862745, opacity: 1),
successMuted: Color(.sRGB, red: 0.5647058823529412, green: 0.792156862745098, blue: 0.5647058823529412, opacity: 0.23921568627450981),
syntaxAdded: Color(.sRGB, red: 0.5647058823529412, green: 0.792156862745098, blue: 0.5647058823529412, opacity: 0.058823529411764705),
- syntaxAddedMarker: Color(.sRGB, red: 0.6196078431372549, green: 0.6196078431372549, blue: 0.6196078431372549, opacity: 1),
+ syntaxAddedMarker: Color(.sRGB, red: 0.7254901960784313, green: 0.7254901960784313, blue: 0.7254901960784313, opacity: 1),
syntaxAttribute: Color(.sRGB, red: 0.9333333333333333, green: 0.7686274509803922, blue: 0.2823529411764706, opacity: 1),
syntaxBackground: Color(.sRGB, red: 0.06666666666666667, green: 0.06666666666666667, blue: 0.06666666666666667, opacity: 1),
- syntaxComment: Color(.sRGB, red: 0.6196078431372549, green: 0.6196078431372549, blue: 0.6196078431372549, opacity: 1),
+ syntaxComment: Color(.sRGB, red: 0.7254901960784313, green: 0.7254901960784313, blue: 0.7254901960784313, opacity: 1),
syntaxConstant: Color(.sRGB, red: 1, green: 0.7019607843137254, blue: 0.49411764705882355, opacity: 1),
syntaxDiffHeader: Color(.sRGB, red: 0, green: 0, blue: 0, opacity: 0),
syntaxFunction: Color(.sRGB, red: 0.6313725490196078, green: 0.792156862745098, blue: 1, opacity: 1),
syntaxKeyword: Color(.sRGB, red: 0.9372549019607843, green: 0.6588235294117647, blue: 1, opacity: 1),
syntaxNumber: Color(.sRGB, red: 1, green: 0.7019607843137254, blue: 0.49411764705882355, opacity: 1),
- syntaxOperator: Color(.sRGB, red: 0.6196078431372549, green: 0.6196078431372549, blue: 0.6196078431372549, opacity: 1),
+ syntaxOperator: Color(.sRGB, red: 0.7254901960784313, green: 0.7254901960784313, blue: 0.7254901960784313, opacity: 1),
syntaxProperty: Color(.sRGB, red: 0.5647058823529412, green: 0.8431372549019608, blue: 0.7843137254901961, opacity: 1),
- syntaxPunctuation: Color(.sRGB, red: 0.6196078431372549, green: 0.6196078431372549, blue: 0.6196078431372549, opacity: 1),
+ syntaxPunctuation: Color(.sRGB, red: 0.7254901960784313, green: 0.7254901960784313, blue: 0.7254901960784313, opacity: 1),
syntaxRemoved: Color(.sRGB, red: 1, green: 0.596078431372549, blue: 0.5647058823529412, opacity: 0.058823529411764705),
- syntaxRemovedMarker: Color(.sRGB, red: 0.6196078431372549, green: 0.6196078431372549, blue: 0.6196078431372549, opacity: 1),
+ syntaxRemovedMarker: Color(.sRGB, red: 0.7254901960784313, green: 0.7254901960784313, blue: 0.7254901960784313, opacity: 1),
syntaxString: Color(.sRGB, red: 0.6431372549019608, green: 0.8392156862745098, blue: 0.6392156862745098, opacity: 1),
syntaxTag: Color(.sRGB, red: 1, green: 0.6823529411764706, blue: 0.6549019607843137, opacity: 1),
syntaxType: Color(.sRGB, red: 0.9372549019607843, green: 0.6588235294117647, blue: 1, opacity: 1),
diff --git a/packages/themes/neutral/neutral.spec.md b/packages/themes/neutral/neutral.spec.md
index 0b61f05499..53e1a4a72f 100644
--- a/packages/themes/neutral/neutral.spec.md
+++ b/packages/themes/neutral/neutral.spec.md
@@ -8,7 +8,11 @@ approved_by: rubyycheung
approved_at: 2026-10-17
review_triggers:
[tokens, palette-values, component-mappings, contrast, artifacts]
-verified_by: [scripts/check-badge-contrast.test.mjs]
+verified_by:
+ [
+ scripts/check-badge-contrast.test.mjs,
+ packages/themes/neutral/src/neutralTheme.test.ts,
+ ]
package: '@astryxdesign/theme-neutral'
source_theme: packages/themes/neutral/src/neutralTheme.ts
references:
@@ -96,6 +100,17 @@ accent, and Banner and the pale destructive Button use the portable overlay
and neutral roles; Neutral adds no component override for any of them. Every new mapping needs exact-head theme review and
rendered light/dark evidence; shared color alone is not enough.
+Neutral's selected fill, `--color-accent-muted`, is `neutral.light[85]` /
+`neutral.dark[30]` (`#d4d4d4` / `#474747`). Text on it reads at 4.5:1 or more
+in both modes. In dark mode Neutral lifts `--color-text-secondary` to
+`neutral.dark[80]` on a selected `item` or `tree-list-item` (a checked
+CheckboxListItem row reflects `selected` on its `item` target), on a
+`citation` with `variant:number`, and on a `file-input` with `mode:dropzone`,
+whose drag-over fill has no state target, so that text clears 4.5:1 at rest
+and under the hover overlay. Neutral's syntax `comment`, `operator` and
+`punctuation` colours are `neutral.light[35]` / `neutral.dark[75]`, so they
+read on a highlighted code line.
+
This work does not add component states. It intentionally excludes
`table-row-status`, which has no approved theming target, and SegmentedControl
geometry/shadow changes, which are reviewed independently.
diff --git a/packages/themes/neutral/src/neutralPaletteRefs.generated.ts b/packages/themes/neutral/src/neutralPaletteRefs.generated.ts
index 54e673774e..878eac928e 100644
--- a/packages/themes/neutral/src/neutralPaletteRefs.generated.ts
+++ b/packages/themes/neutral/src/neutralPaletteRefs.generated.ts
@@ -15,8 +15,8 @@ export const neutralPaletteRefs = {
dark: {25: '#2b422b', 80: '#aad4a9', 85: '#bce0bb'},
},
neutral: {
- light: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 30: '#474747', 45: '#6a6a6a', 60: '#919191', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
- dark: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 15: '#262626', 20: '#303030', 35: '#525252', 65: '#9e9e9e', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
+ light: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 30: '#474747', 35: '#525252', 45: '#6a6a6a', 60: '#919191', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
+ dark: {0: '#000000', 5: '#111111', 10: '#1b1b1b', 15: '#262626', 20: '#303030', 30: '#474747', 35: '#525252', 65: '#9e9e9e', 75: '#b9b9b9', 80: '#c6c6c6', 85: '#d4d4d4', 90: '#e2e2e2', 95: '#f1f1f1', 100: '#ffffff'},
},
orange: {
light: {25: '#622700', 30: '#733100', 75: '#ff9e55', 85: '#ffc7a1'},
diff --git a/packages/themes/neutral/src/neutralTheme.test.ts b/packages/themes/neutral/src/neutralTheme.test.ts
index 44ce365282..18978572a4 100644
--- a/packages/themes/neutral/src/neutralTheme.test.ts
+++ b/packages/themes/neutral/src/neutralTheme.test.ts
@@ -300,18 +300,187 @@ describe('neutral theme palette mappings', () => {
});
});
+// A wash of `color` at `alpha` (0-255) over `background`, as the browser
+// composites `--color-neutral`, the hover tint.
+function composite(color: string, alpha: number, background: string): string {
+ const channel = (hex: string, offset: number) =>
+ Number.parseInt(hex.slice(offset + 1, offset + 3), 16);
+ return `#${[0, 2, 4]
+ .map(offset =>
+ Math.round(
+ (channel(color, offset) * alpha +
+ channel(background, offset) * (255 - alpha)) /
+ 255,
+ )
+ .toString(16)
+ .padStart(2, '0'),
+ )
+ .join('')}`;
+}
+
+describe('neutral selected fill', () => {
+ // `--color-accent-muted` fills a selected row, a range, a highlighted line
+ // and a pressed preset. It must stand apart from every surface it sits on,
+ // and from the hover tint on that surface, in both modes.
+ const [, lightFill, darkFill] =
+ /^light-dark\((#[0-9a-f]{6}), (#[0-9a-f]{6})\)$/i.exec(
+ String(neutralTheme.tokens?.['--color-accent-muted']),
+ ) ?? [];
+ const modes = [
+ {
+ name: 'light',
+ fill: lightFill,
+ surface: neutralPalettes.neutral.light[100],
+ body: neutralPalettes.neutral.light[95],
+ tint: neutralPalettes.neutral.light[0],
+ alpha: 0x0f,
+ },
+ {
+ name: 'dark',
+ fill: darkFill,
+ surface: neutralPalettes.neutral.dark[15],
+ body: neutralPalettes.neutral.dark[10],
+ tint: neutralPalettes.neutral.dark[100],
+ alpha: 0x1a,
+ },
+ ];
+
+ it.each(modes)(
+ 'stands apart from the surface, the body and their hover tints in $name mode',
+ ({fill, surface, body, tint, alpha}) => {
+ for (const background of [
+ surface,
+ body,
+ composite(tint, alpha, surface),
+ composite(tint, alpha, body),
+ ]) {
+ expect(contrastRatio(fill, background)).toBeGreaterThanOrEqual(1.15);
+ }
+ },
+ );
+
+ // The text that sits on the fill keeps normal-text AA: a selected row's
+ // secondary text (scoped up on selected rows) and the muted syntax colours
+ // on a highlighted code line.
+ const pair = (value: unknown): [string, string] => {
+ const match = /^light-dark\((#[0-9a-f]{6}), (#[0-9a-f]{6})\)$/i.exec(
+ String(value),
+ );
+ if (match == null) {
+ throw new Error(`not a light-dark pair: ${String(value)}`);
+ }
+ return [match[1], match[2]];
+ };
+ const foregrounds = {
+ 'item selected --color-text-secondary': pair(
+ neutralTheme.components?.item?.selected?.['--color-text-secondary'],
+ ),
+ 'tree-list-item selected --color-text-secondary': pair(
+ neutralTheme.components?.['tree-list-item']?.selected?.[
+ '--color-text-secondary'
+ ],
+ ),
+ 'citation variant:number --color-text-secondary': pair(
+ neutralTheme.components?.citation?.['variant:number']?.[
+ '--color-text-secondary'
+ ],
+ ),
+ 'file-input mode:dropzone --color-text-secondary': pair(
+ neutralTheme.components?.['file-input']?.['mode:dropzone']?.[
+ '--color-text-secondary'
+ ],
+ ),
+ '--color-syntax-comment': pair(
+ neutralTheme.tokens['--color-syntax-comment'],
+ ),
+ '--color-syntax-operator': pair(
+ neutralTheme.tokens['--color-syntax-operator'],
+ ),
+ '--color-syntax-punctuation': pair(
+ neutralTheme.tokens['--color-syntax-punctuation'],
+ ),
+ };
+ // Every token colour reads on a highlighted line, not only the muted ones.
+ it.each(
+ [
+ 'keyword',
+ 'string',
+ 'comment',
+ 'number',
+ 'function',
+ 'type',
+ 'variable',
+ 'operator',
+ 'constant',
+ 'tag',
+ 'attribute',
+ 'property',
+ 'punctuation',
+ ].map(token => `--color-syntax-${token}`),
+ )('%s reads at 4.5:1 on a highlighted line in both modes', token => {
+ const [light, dark] = pair(neutralTheme.tokens[token]);
+ expect(contrastRatio(light, lightFill)).toBeGreaterThanOrEqual(4.5);
+ expect(contrastRatio(dark, darkFill)).toBeGreaterThanOrEqual(4.5);
+ });
+
+ // A selected row also shows the hover overlay over its fill
+ // (`--color-overlay-hover`: black at 0x0D in light, white at 0x0D in dark).
+ it.each([
+ 'item selected --color-text-secondary',
+ 'tree-list-item selected --color-text-secondary',
+ ] as const)('%s reads at 4.5:1 on the hovered fill', name => {
+ const [light, dark] = foregrounds[name];
+ const lightHovered = composite(
+ neutralPalettes.neutral.light[0],
+ 0x0d,
+ lightFill,
+ );
+ const darkHovered = composite(
+ neutralPalettes.neutral.dark[100],
+ 0x0d,
+ darkFill,
+ );
+ expect(contrastRatio(light, lightHovered)).toBeGreaterThanOrEqual(4.5);
+ expect(contrastRatio(dark, darkHovered)).toBeGreaterThanOrEqual(4.5);
+ });
+
+ it('scopes the lifted secondary text to selected rows, numbered citations and dropzones in the generated CSS', () => {
+ const css = generateThemeCSS(neutralTheme).component;
+ for (const target of ['item', 'tree-list-item']) {
+ expect(css).toMatch(
+ new RegExp(
+ `\\.astryx-${target}\\[data-selected="selected"\\][^{]*\\{[^}]*--color-text-secondary`,
+ ),
+ );
+ }
+ expect(css).toMatch(
+ /\.astryx-citation\[data-variant="number"\][^{]*\{[^}]*--color-text-secondary/,
+ );
+ expect(css).toMatch(
+ /\.astryx-file-input\[data-mode="dropzone"\][^{]*\{[^}]*--color-text-secondary/,
+ );
+ });
+ it.each(Object.entries(foregrounds))(
+ '%s reads at 4.5:1 on the fill in both modes',
+ (_, [light, dark]) => {
+ expect(contrastRatio(light, lightFill)).toBeGreaterThanOrEqual(4.5);
+ expect(contrastRatio(dark, darkFill)).toBeGreaterThanOrEqual(4.5);
+ },
+ );
+});
+
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],
+ neutralPalettes.neutral.light[35],
+ neutralPalettes.neutral.dark[75],
),
);
expect(
- contrastRatio(neutralPalettes.neutral.light[45], background),
+ contrastRatio(neutralPalettes.neutral.light[35], background),
).toBeGreaterThanOrEqual(4.5);
}
});
diff --git a/packages/themes/neutral/src/neutralTheme.ts b/packages/themes/neutral/src/neutralTheme.ts
index ba07f2c263..bbb4d2ffe2 100644
--- a/packages/themes/neutral/src/neutralTheme.ts
+++ b/packages/themes/neutral/src/neutralTheme.ts
@@ -17,17 +17,17 @@ const neutralSyntax = defineSyntaxTheme({
tokens: {
keyword: [purple.light[30], purple.light[80]],
string: [green.light[30], green.light[80]],
- comment: [neutral.light[45], neutral.dark[65]],
+ comment: [neutral.light[35], neutral.dark[75]],
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]],
+ operator: [neutral.light[35], neutral.dark[75]],
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]],
+ punctuation: [neutral.light[35], neutral.dark[75]],
background: [neutral.light[100], neutral.dark[5]],
},
});
@@ -94,7 +94,7 @@ export const neutralTheme = defineTheme({
'--color-background-muted': [neutral.light[95], neutral.dark[10]],
'--color-accent': [neutral.light[10], neutral.dark[95]],
- '--color-accent-muted': [neutral.light[95], neutral.dark[15]],
+ '--color-accent-muted': [neutral.light[85], neutral.dark[30]],
'--color-neutral': [
withAlpha(neutral.light[0], '0F'),
withAlpha(neutral.dark[100], '1A'),
@@ -273,6 +273,32 @@ export const neutralTheme = defineTheme({
},
components: {
+ // In dark mode, secondary text falls under 4.5:1 on the selected fill
+ // and under its hover. Selected rows use the next stop that clears both.
+ item: {
+ selected: {
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
+ },
+ },
+ 'tree-list-item': {
+ selected: {
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
+ },
+ },
+ // A dropzone's hint sits on the same fill while a file is dragged over.
+ // That state has no target, so the dropzone takes the lift at rest too.
+ 'file-input': {
+ 'mode:dropzone': {
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
+ },
+ },
+ // A numbered citation is a pill on the same fill.
+ citation: {
+ 'variant:number': {
+ '--color-text-secondary': `light-dark(${neutral.light[30]}, ${neutral.dark[80]})`,
+ },
+ },
+
button: {
'variant:destructive': {
backgroundColor: 'var(--color-error-muted)',
diff --git a/scripts/generate-neutral-palette-refs.test.mjs b/scripts/generate-neutral-palette-refs.test.mjs
index 58b5518f34..49afd83390 100644
--- a/scripts/generate-neutral-palette-refs.test.mjs
+++ b/scripts/generate-neutral-palette-refs.test.mjs
@@ -149,10 +149,10 @@ describe('Neutral selected palette ref generation', () => {
}
});
- it('projects exactly the 95 stops used by Neutral into both committed copies', () => {
+ it('projects exactly the 99 stops used by Neutral into both committed copies', () => {
const result = generateNeutralPaletteRefs({root: ROOT, check: true});
expect(result.problems).toEqual([]);
- expect(countSelectedRefs(result.selected)).toBe(95);
+ expect(countSelectedRefs(result.selected)).toBe(99);
for (const output of result.outputs) {
expect(fs.readFileSync(output, 'utf-8')).toBe(result.content);
}