Files
RuneStone/docs/ui-color.md
T
Knotty Wyvern 5bd616d7fd Give themes named color roles, theme data files, and file format 3
Phase 5a-1 and 5a-2.

- roles.ts names 51 color roles. One derivation rule fills the roles
  that a theme does not give, for all themes. tokens.css keeps only the
  root defaults, without theme blocks.
- Each built-in theme is one data file in src/lib/theme/themes/. No code
  outside the theme data names a theme ID. characterThemes.ts is gone.
- New roles: link, focus, on-accent, highlight, scrim, the syntax roles,
  and 16 terminal (ANSI) roles. Stray colors in components use the roles.
- contrast.ts checks each theme against the readability rules of
  docs/ui-color.md. The tests mark the known palette failures as todo,
  and a second test fails when a known failure starts to pass.
- Theme files use schema 3 with a mode and an optional built-in base.
  A short file gets the missing colors and fonts from the base. Schema 1
  and 2 files still import. Old syntax names convert on import.
- Docs: ui-color.md, plugin-development.md (theme tokens), ui-design.md,
  guides/themes.md, and UI-041 and UI-042 in design-decisions.md.

The applied colors stay the same for every built-in theme, except three
small changes: the conflict line uses the warn color, the Write
highlight uses the highlight role, and two dialog backdrops use the
scrim role.

pnpm check passes. pnpm test: 447 pass, 31 todo, 0 fail. Full smoke
suite: 93 passed, 2 known. appearance/palettes read the old syntax
names and passed 3 of 3 times after the fix. workspace/manageTemplates
failed one time and passed on retry.
2026-10-28 15:50:45 -07:00

105 lines
7.6 KiB
Markdown

# Functional color
[Interface design](ui-design.md) · [Design decisions](design-decisions.md)
This guide sets the color rules for RuneStone and its plugins, for human developers and agents.
Agents also apply the user-level `ui-functional-color` skill. This guide adds the project roles, references, thresholds, and evidence.
## Default
- Start accents, priority, status, selection outlines, syntax, and important data with vivid, distinct candidates. Full saturation and full HSV value are normal options.
- Pick the stronger candidate when readability, meaning, and distinction stay correct.
- Do not soften a color only to look quiet, refined, professional, premium, minimal, or cohesive. A softer choice needs a concrete reason and before-and-after evidence.
- A quiet layout comes from spacing, hierarchy, and the amount of color on screen. It does not need a faded palette.
- Existing muted values are not an approved soft design.
- Keep informative text and symbols opaque.
## Roles and tokens
A theme is data. Each built-in theme is one file in `src/lib/theme/themes/`, with one palette for each mode that it offers.
`src/lib/theme/roles.ts` lists the color roles. Each role is the CSS token `--rs-<role>`.
A theme gives the base roles. One rule for all themes fills each other role from the base roles, unless the theme gives a value.
No code outside the theme data names a theme ID. `tests/unit/theme/contrast.spec.ts` checks this.
Correct a wrong color in the theme data or in the derivation rule. Do not add local saturation or opacity overrides.
| Role | Tokens | Requirement |
| --- | --- | --- |
| Theme identity | `--rs-accent`, `--rs-accent-2` | Keep the characteristic hues of the reference at their strength. |
| Status | `--rs-error`, `--rs-warn`, `--rs-warn-hot`, `--rs-ok` | Use clear, assertive colors. Pair color with a shape or text. |
| Priority (Project Management) | `--pm-priority-color` in the plugin `src/style.css` | Full saturation and value, with opaque symbols and readable text. |
| Links and actions | `--rs-link` (from `--rs-accent` unless the theme sets it) | Keep actionable text distinct and readable on its actual surface. |
| Text on an accent fill | `--rs-on-accent` (black or white, whichever is more readable) | Readable text and icons on accent buttons and badges. |
| Focus | `--rs-focus` (from `--rs-accent` unless the theme sets it) | A visible outline on every surface. |
| Selection | `--rs-item-selection-*`, `--rs-selection`, `--rs-selection-text` | Show a clear state change and boundary. Content inside the selection stays readable. |
| Highlighted text | `--rs-highlight` | A fill that keeps the text readable. |
| Syntax | `--rs-syntax-*`, one for each role in `SYNTAX_ROLES` | Give each meaning a distinct color. A palette has at least 7 distinct syntax colors. |
| Terminal | `--rs-ansi-*` and `--rs-ansi-bright-*`, one for each color in `ANSI_COLORS` | Each color keeps its ANSI hue in every theme. Blue stays blue, also in a red theme. |
| Surfaces and dividers | `--rs-bg`, `--rs-bg-elevated`, `--rs-bg-active`, `--rs-border`, `--rs-line-highlight`, `--rs-scrim`, `--rs-image-*` tints | Support the content. Choose their strength by function. |
| Disabled states | Role tokens of the control | Keep labels readable. Do not apply disabled opacity to enabled content. |
Do not fade a whole badge, row, or container when only its background needs transparency.
Plugins use the same tokens. [Theme tokens](plugin-development.md#theme-tokens) lists them for plugin authors.
## Theme references
- Read the current reference cards, and obey the source priority that the user gives.
- Harvest Moon (Holo) uses the current fan art. Removed images do not count for later palette decisions.
- Take the colors of the character. Exclude scenery, lighting, alternate clothing, and unrelated details.
- The trading screenshot and the Bloomberg example show clear information and state distinctions. They do not ask for a terminal-like appearance.
## Known failures
The October 13 review found these problems. The values record that correction. They are not quotas for future themes.
| Palette | Problem | Correction |
| --- | --- | --- |
| Harvest Moon (Holo) | Marsh green and pink roles did not match the identity. | Warm copper, chestnut, amber, and red |
| Crimson Pilot (Asuka) | Repeated green and similar cyan roles | Red, orange, yellow, and blue carry distinct meanings. |
| Silver Serpent (Malfoid) | Sage accent and near-gray syntax | Emerald accent, saturation from about 29% to 76% |
| Priority marks | Too dark to draw attention | Full saturation and value, with readable text |
The [October 13 menu and color review](archive/menu-audit-2026-10-13.md) holds the measurements and the image-surface limits.
## Readability rules
`src/lib/theme/contrast.ts` holds these rules. `tests/unit/theme/contrast.spec.ts` applies them to every built-in palette. The theme editor can show the same results.
Each surface is the color that the app draws: a translucent role is composited onto `bg`. Text selection is at most 65% opaque.
| Rule | Check | Minimum |
| --- | --- | --- |
| `text` | `text`, `text-dim`, and `text-strong` on `bg`, `bg-elevated`, `bg-active`, and `selection` | 4.5:1 |
| `accent-text` | `accent` 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 |
| `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 |
| `highlight` | `text` on highlighted text | 4.5:1 |
| `selection-outline` | `accent` on the item selection fill over `bg-elevated` | 3:1 |
| `status-distinct` | OKLab distance between `accent`, `error`, `warn`, and `ok`, in pairs | 0.1 |
| `syntax-variety` | Distinct syntax colors | 7 |
| `light-page` | In a light palette, `bg` is lighter than `bg-elevated` and `bg-active` | — |
`accent` on `selection` is exempt from the 4.5:1 text check. Run the tests with `pnpm test`.
The test lists the failures of current palettes as `todo`. A palette change removes its entries. The test fails when a listed rule passes, so the list cannot go stale.
`tests/unit/theme/characterPalettes.spec.ts` adds the checks of each character palette, for example over image tints.
Over a user image, contrast depends on the composite surface. Measure the 82% and 90% tints over the image that the change uses. Do not claim contrast over every possible image or overlay.
When contrast fails, change the foreground, background, surface, or role before you reduce color strength.
## Evidence for review
Record the evidence that the `ui-functional-color` skill lists for each changed role. For RuneStone, also record:
- The shared token and the affected controls.
- Each named palette and appearance that uses the token.
- Contrast on the actual composite surface, including image tints, overlays, and selected states.
- Screenshots at normal scale of the content, code, menus, and priority marks where the token appears.
- For a softer choice, the stronger candidate and the requirement or measured problem that rejected it.
- Checks that you could not run. Browser mocks do not replace native desktop checks.
Correct unexplained muting, or record it as unresolved, before the work moves to Review.
A deliberate departure needs an exception entry in the [design decision log](design-decisions.md). The entry alone does not authorize it.
Decision: [UI-024](design-decisions.md#ui-024--assertive-functional-color-by-default).