Check text and code on the selection fill

Source draws search matches and selection matches with the item
selection fill, behind code. No rule checked that surface. In four core
palettes, code colors were 3.8:1 to 4.3:1 on it, and dim text in a
selected row was 4.0:1 in two light palettes.

- The text rule also checks the item selection fill over bg-elevated.
  The syntax rule also checks the fill over bg (UI-046).
- The derived fill is the accent at 12%, not 20%. RuneStone, Claude,
  and custom themes without their own fill use it. Sakura and the
  character themes set their own fill and pass.
- Matches keep their underline, and selected rows keep their outline.

pnpm check passes. pnpm test: 446 of 446 pass. Full smoke suite: 92
passed, 2 known. Three tests failed one time while Vite compiled the
changed modules, and passed on retry and 3 of 3 times alone.
This commit is contained in:
Knotty Wyvern
2026-10-28 17:36:43 -07:00
parent 35f39e93f3
commit d160568249
5 changed files with 24 additions and 6 deletions
+4 -2
View File
@@ -21,6 +21,8 @@ export const SURFACES = {
'line-highlight': colors => composite(colors['line-highlight'], opaque(colors.bg)),
highlight: colors => composite(mix(colors.highlight, '#0000', 0.3), opaque(colors.bg)),
'item-selection': colors => composite(colors['item-selection-bg'], composite(colors['bg-elevated'], opaque(colors.bg))),
// Source draws search matches and selection matches with the item selection fill, behind code.
match: colors => composite(colors['item-selection-bg'], opaque(colors.bg)),
accent: colors => composite(colors.accent, opaque(colors.bg)),
} satisfies Record<string, (colors: ResolvedColors) => string>;
export type Surface = keyof typeof SURFACES;
@@ -41,10 +43,10 @@ export type Rule = ContrastRule | DistinctRule | VarietyRule | LightestRule;
export const DISTINCT_DISTANCE = 0.1;
export const RULES: readonly Rule[] = [
{ id: 'text', kind: 'contrast', foregrounds: ['text', 'text-dim', 'text-strong'], surfaces: ['bg', 'bg-elevated', 'bg-active', 'selection'], min: 4.5 },
{ id: 'text', kind: 'contrast', foregrounds: ['text', 'text-dim', 'text-strong'], surfaces: ['bg', 'bg-elevated', 'bg-active', 'selection', 'item-selection'], min: 4.5 },
{ id: 'accent-text', kind: 'contrast', foregrounds: ['accent', 'accent-2', 'link'], surfaces: ['bg', 'bg-elevated', 'bg-active'], min: 4.5 },
{ id: 'status-text', kind: 'contrast', foregrounds: ['error', 'warn', 'ok'], surfaces: ['bg', 'bg-elevated'], min: 4.5 },
{ id: 'syntax', kind: 'contrast', foregrounds: SYNTAX, surfaces: ['bg', 'bg-active', 'line-highlight'], min: 4.5 },
{ id: 'syntax', kind: 'contrast', foregrounds: SYNTAX, surfaces: ['bg', 'bg-active', 'line-highlight', 'match'], min: 4.5 },
{ id: 'ansi', kind: 'contrast', foregrounds: ANSI, surfaces: ['bg'], min: 4.5 },
{ id: 'focus', kind: 'contrast', foregrounds: ['focus'], surfaces: ['bg', 'bg-elevated', 'bg-active'], min: 3 },
{ id: 'on-accent', kind: 'contrast', foregrounds: ['on-accent'], surfaces: ['accent'], min: 4.5 },