diff --git a/docs/design-decisions.md b/docs/design-decisions.md index 42b2056..656cd62 100644 --- a/docs/design-decisions.md +++ b/docs/design-decisions.md @@ -870,3 +870,19 @@ Native shell, background image, and desktop acceptance remain open. - Evidence: The comparison sheets and `readability.md` in `output/phase-5a/5a-4/` in the main checkout. - Replaces / replaced by: The palette values of [UI-012](#ui-012--retain-three-stronger-character-themes). Its theme set and names remain. - Limits: Browser checks use desktop service mocks. Native desktop acceptance remains open. The KnottyWyvern Portal still uses the earlier Harvest Moon colors. + +### UI-046 — Readable matches and selected rows + +- Type: Rule change +- Date: 2026-10-28 +- Status: Implemented for user review +- Decision source: A gap found in stage 5a-4. The owner approved the fix on 2026-10-28. +- Previous rule: `--rs-item-selection-bg` came from the accent at 20%. Source draws search matches and selection matches with this fill behind code, and no rule checked that surface. In four core palettes, syntax colors were 3.8:1 to 4.3:1 on it. In RuneStone Light and Claude Light, dim text was 4.0:1 to 4.2:1 on the file selection fill. +- New rule: The `text` rule also checks the item selection fill over `bg-elevated`. The `syntax` rule also checks the item selection fill over `bg`. The derived fill is the accent at 12%. +- Reason: Code inside a search match and dim text in a selected row stay readable. The selection outline keeps the boundary visible. +- Scope: Every theme that does not set its own `item-selection-bg`: RuneStone, Claude, and custom themes. Sakura and the character themes set their own fill and pass. +- Shared implementation: `roles.ts` (the derivation), `contrast.ts` (the `match` surface), and the root default in `tokens.css`. +- Visible changes: Selected rows, table cells, Settings navigation, and Source matches have a lighter fill in RuneStone and Claude. +- Evidence: `tests/unit/theme/contrast.spec.ts` applies the new checks to every built-in palette. Screenshots are in `output/phase-5a/5a-4/match-fill/` in the main checkout. +- Replaces / replaced by: None. +- Limits: Browser checks use desktop service mocks. Native desktop acceptance remains open. diff --git a/docs/ui-color.md b/docs/ui-color.md index 67017e8..776305d 100644 --- a/docs/ui-color.md +++ b/docs/ui-color.md @@ -72,10 +72,10 @@ Each surface is the color that the app draws: a translucent role is composited o | Rule | Check | Minimum | | --- | --- | --- | -| `text` | `text`, `text-dim`, and `text-strong` on `bg`, `bg-elevated`, `bg-active`, and `selection` | 4.5:1 | +| `text` | `text`, `text-dim`, and `text-strong` on `bg`, `bg-elevated`, `bg-active`, `selection`, and the item selection fill over `bg-elevated` | 4.5:1 | | `accent-text` | `accent`, `accent-2`, and `link` on `bg`, `bg-elevated`, and `bg-active` | 4.5:1 | | `status-text` | `error`, `warn`, and `ok` on `bg` and `bg-elevated` | 4.5:1 | -| `syntax` | Each syntax role on `bg`, `bg-active`, and `line-highlight` | 4.5:1 | +| `syntax` | Each syntax role on `bg`, `bg-active`, `line-highlight`, and the item selection fill over `bg` (search and selection matches in Source) | 4.5:1 | | `ansi` | Red, green, yellow, blue, magenta, and cyan terminal colors, and their bright variants, on `bg` | 4.5:1 | | `focus` | `focus` on `bg`, `bg-elevated`, and `bg-active` | 3:1 | | `on-accent` | `on-accent` on `accent` | 4.5:1 | diff --git a/src/lib/theme/contrast.ts b/src/lib/theme/contrast.ts index 504dd45..6731a28 100644 --- a/src/lib/theme/contrast.ts +++ b/src/lib/theme/contrast.ts @@ -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>; 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 }, diff --git a/src/lib/theme/roles.ts b/src/lib/theme/roles.ts index 069a9c3..de9b307 100644 --- a/src/lib/theme/roles.ts +++ b/src/lib/theme/roles.ts @@ -41,7 +41,7 @@ const DERIVED: Record, Derive> = { link: colors => colors.accent, focus: colors => colors.accent, 'on-accent': colors => readableOn(colors.accent), - 'item-selection-bg': colors => mix(colors.accent, '#0000', 0.2), + 'item-selection-bg': colors => mix(colors.accent, '#0000', 0.12), 'line-highlight': (_, mode) => mode === 'light' ? '#0000000d' : '#ffffff0d', highlight: () => '#edc65b', scrim: () => '#00000088', diff --git a/src/lib/theme/tokens.css b/src/lib/theme/tokens.css index 5e64970..8486f44 100644 --- a/src/lib/theme/tokens.css +++ b/src/lib/theme/tokens.css @@ -44,7 +44,7 @@ --rs-image-menu-backdrop: blur(18px) saturate(1.2); --rs-menu-shadow: 0 8px 30px #0006; --rs-item-selection-radius: var(--rs-control-radius); - --rs-item-selection-bg: color-mix(in srgb, var(--rs-accent) 20%, transparent); + --rs-item-selection-bg: color-mix(in srgb, var(--rs-accent) 12%, transparent); --rs-item-selection-border: var(--rs-accent); --rs-item-selection-width: 2px; --rs-bg: #151617;