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.
This commit is contained in:
+23
-19
@@ -40,25 +40,22 @@ The Project Management plugin can keep a separate image for a board. The Backgro
|
||||
3. Edit the saved JSON file in a text editor.
|
||||
4. Choose **Install theme** and select the file.
|
||||
|
||||
The template contains one `colors` palette and the current `fonts`. A custom theme has one fixed palette, without separate light and dark versions.
|
||||
The template contains every color and font of the theme. A custom theme has one fixed mode: light or dark.
|
||||
|
||||
Example (a minimal theme file):
|
||||
A theme file can also be short. It gives only the colors that differ from its `base` theme. The base theme gives all other colors and its fonts.
|
||||
|
||||
Example (a short theme file that changes two colors of Harvest Moon):
|
||||
|
||||
```json
|
||||
{
|
||||
"schema": 2,
|
||||
"schema": 3,
|
||||
"id": "harbor",
|
||||
"name": "Harbor",
|
||||
"mode": "dark",
|
||||
"base": "harvest-moon",
|
||||
"colors": {
|
||||
"bg": "#141414",
|
||||
"bg-elevated": "#1c1c1c",
|
||||
"bg-active": "#2a2a2a",
|
||||
"border": "#454545",
|
||||
"text": "#e6e6e6",
|
||||
"text-dim": "#b0b0b0",
|
||||
"text-strong": "#ffffff",
|
||||
"accent": "#00c8ff",
|
||||
"selection": "#264f78"
|
||||
"link": "#5cd6ff"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -68,26 +65,33 @@ Example (a minimal theme file):
|
||||
| Field | Rule |
|
||||
| --- | --- |
|
||||
| File | JSON, smaller than 64 KiB |
|
||||
| `schema` | `2`. RuneStone also imports schema 1 files and converts them to one palette for the current appearance. |
|
||||
| `schema` | `3`. RuneStone also imports schema 1 and 2 files and converts them. A schema 1 file gives the palette of the current appearance. |
|
||||
| `id` | Starts with a lowercase letter. Lowercase letters, numbers, and hyphens. Up to 64 characters. A theme with the same ID replaces the installed theme. |
|
||||
| `name` | Up to 80 characters |
|
||||
| `colors` | Must contain `bg`, `text`, and `accent`. Each value is a hexadecimal color with 3, 4, 6, or 8 digits. |
|
||||
| `fonts` | Optional. Font stacks for `ui`, `prose`, `heading`, and `mono`, such as `"mono": "Cascadia Mono, monospace"`. |
|
||||
| `mode` | `light` or `dark` |
|
||||
| `base` | Optional. The ID of a built-in theme that has a palette in `mode`: `default` (RuneStone), `claude`, `sakura`, `harvest-moon`, `crimson-pilot`, or `silver-serpent`. Without `base`, RuneStone is the base. |
|
||||
| `colors` | The colors that differ from the base theme. Each value is a hexadecimal color with 3, 4, 6, or 8 digits. |
|
||||
| `fonts` | Optional. Font stacks for `ui`, `prose`, `heading`, and `mono`, such as `"mono": "Cascadia Mono, monospace"`. Without a stack, the base theme gives it. |
|
||||
|
||||
An unknown key or a color that is not valid stops the installation with an error.
|
||||
If you omit an optional color, RuneStone uses the color of the base appearance. If you omit `fonts`, the theme uses the normal fonts.
|
||||
Some colors come from other colors when neither the file nor the base theme gives them. For example, `link` and `focus` come from `accent`.
|
||||
Font stacks name fonts that are installed on the computer. A theme file cannot install fonts or contain scripts, style rules, or plugin code.
|
||||
|
||||
### Color keys
|
||||
|
||||
| Keys | Use |
|
||||
| --- | --- |
|
||||
| `bg`, `bg-elevated`, `bg-active`, `border` | Surfaces and borders |
|
||||
| `bg`, `bg-elevated`, `bg-active`, `border` | The page, side panes and menus, hover fills, and borders |
|
||||
| `text`, `text-dim`, `text-strong` | Normal, secondary, and prominent text |
|
||||
| `accent`, `accent-2`, `selection` | Links, accents, and editor selection |
|
||||
| `accent`, `accent-2`, `accent-dim`, `accent-deep` | Theme colors for active states, indicators, and icons |
|
||||
| `link`, `focus`, `on-accent` | Link text, keyboard focus outlines, and text on an accent fill |
|
||||
| `selection`, `item-selection-bg`, `line-highlight`, `highlight`, `scrim` | Text selection, selected rows, the current line in Source, highlighted text, and the backdrop behind dialogs |
|
||||
| `error`, `warn`, `warn-hot`, `ok`, `special` | Status and special content |
|
||||
| `syntax-parameter`, `syntax-keyword`, `syntax-local`, `syntax-static`, `syntax-instance`, `syntax-global` | Code identifiers and keywords |
|
||||
| `syntax-string`, `syntax-number`, `syntax-comment`, `syntax-type`, `syntax-function` | Code values, comments, types, and functions |
|
||||
| `syntax-keyword`, `syntax-string`, `syntax-number`, `syntax-comment`, `syntax-type`, `syntax-function` | Code keywords, values, comments, types, and functions |
|
||||
| `syntax-property`, `syntax-variable`, `syntax-constant`, `syntax-punctuation`, `syntax-heading` | Code properties, variables, constants, punctuation, and Markdown headings |
|
||||
| `ansi-black` to `ansi-white`, `ansi-bright-black` to `ansi-bright-white` | The 16 terminal colors: black, red, green, yellow, blue, magenta, cyan, and white, and a bright variant of each |
|
||||
|
||||
Schema 1 and 2 files used other names for some code colors. RuneStone converts them: `syntax-local` to `syntax-variable`, `syntax-instance` to `syntax-property`, and `syntax-global` to `syntax-constant` and `syntax-punctuation`. Source never used `syntax-parameter` and `syntax-static`, so RuneStone ignores them.
|
||||
|
||||
Before you share a theme, check text, links, focus outlines, selections, and surfaces with a background image.
|
||||
Keep informative text and symbols opaque. See the [functional color requirements](../ui-color.md).
|
||||
|
||||
Reference in New Issue
Block a user