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:
@@ -392,6 +392,36 @@ Only one enabled plugin can own each key. The host removes contributions before
|
||||
|
||||
A terminal contribution must stop its controls and native sessions before its cleanup finishes.
|
||||
|
||||
### Theme tokens
|
||||
|
||||
Style plugin views with the host CSS custom properties. The host sets them on the root element for the current theme.
|
||||
Do not hard-code colors, and do not choose colors from a theme ID.
|
||||
|
||||
| Token | Use |
|
||||
| --- | --- |
|
||||
| `--rs-bg` | The page: document and editor surfaces |
|
||||
| `--rs-bg-elevated` | Side panes, menus, cards, and dialogs |
|
||||
| `--rs-bg-active` | Hover and pressed fills |
|
||||
| `--rs-border` | Dividers and control borders |
|
||||
| `--rs-text`, `--rs-text-dim`, `--rs-text-strong` | Body text, secondary text, and headings |
|
||||
| `--rs-accent`, `--rs-accent-2` | Theme identity: active states, indicators, and icons |
|
||||
| `--rs-link` | Link and action text |
|
||||
| `--rs-focus` | Keyboard focus outlines |
|
||||
| `--rs-on-accent` | Text and icons on an accent fill |
|
||||
| `--rs-selection`, `--rs-selection-text` | Text selection. The fill is at most 65% opaque. |
|
||||
| `--rs-item-selection-bg`, `--rs-item-selection-border` | Selected rows, cards, and cells |
|
||||
| `--rs-highlight` | Highlighted text |
|
||||
| `--rs-scrim` | The backdrop behind a dialog |
|
||||
| `--rs-error`, `--rs-warn`, `--rs-warn-hot`, `--rs-ok` | Status. Show an icon or text with each status color. |
|
||||
| `--rs-special` | One more distinct color, for example for numbers |
|
||||
| `--rs-syntax-*` | Code colors. [Functional color](ui-color.md#roles-and-tokens) lists the roles. |
|
||||
| `--rs-ansi-black` to `--rs-ansi-white`, `--rs-ansi-bright-black` to `--rs-ansi-bright-white` | The 16 terminal colors. Each keeps its ANSI hue in every theme. |
|
||||
|
||||
[Interface design](ui-design.md#shared-components-and-tokens) lists the size, menu, settings, and tooltip tokens.
|
||||
|
||||
The root element also has `data-theme` (`light` or `dark`) and `data-palette` (the theme ID). Use `data-theme` for differences between light and dark.
|
||||
The window sends a `runestone-theme-changed` event after each theme change. A plugin that copies token values, for example into a canvas or a terminal, reads them again on that event.
|
||||
|
||||
## Use the SDK instead of native calls
|
||||
|
||||
Do not call `invoke`, `listen`, or other `@tauri-apps/api` functions from a plugin. Do not read the private files of other plugins.
|
||||
|
||||
Reference in New Issue
Block a user