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:
Knotty Wyvern
2026-10-28 15:50:45 -07:00
parent af68d92969
commit 5bd616d7fd
55 changed files with 928 additions and 355 deletions
+4 -4
View File
@@ -469,8 +469,8 @@
.live-writer :global(.writer-strong) { font-weight: 600; color: var(--rs-text-strong); }
.live-writer :global(.writer-emphasis) { font-style: italic; }
.live-writer :global(.writer-strike), .live-writer :global(.writer-completed) { text-decoration: line-through; color: var(--rs-text-dim); }
.live-writer :global(.writer-link) { color: var(--rs-accent); text-decoration: underline; text-underline-offset: 3px; }
.live-writer :global(.writer-link-source) { color: var(--rs-accent); }
.live-writer :global(.writer-link) { color: var(--rs-link); text-decoration: underline; text-underline-offset: 3px; }
.live-writer :global(.writer-link-source) { color: var(--rs-link); }
.live-writer :global(.writer-link-target) { text-decoration: underline; text-underline-offset: 3px; }
.live-writer :global(.writer-inline-code), .live-writer :global(.writer-code-source) { font-family: var(--rs-font-mono); font-size: .9em; }
.live-writer :global(.writer-inline-code) { background: var(--rs-bg-elevated); border-radius: 3px; }
@@ -479,8 +479,8 @@
.live-writer :global(.writer-code-last) { padding-bottom: 10px; border-bottom: 1px solid var(--rs-border); border-radius: 0 0 var(--rs-control-radius) var(--rs-control-radius); }
.live-writer :global(.writer-code-fence) { color: var(--rs-text-dim); }
.live-writer :global(.writer-code-copy) { top: 4px; border-radius: var(--rs-control-radius); }
.live-writer :global(.writer-code-copy:focus-visible) { outline: 1px solid var(--rs-accent); outline-offset: -2px; }
.live-writer :global(.writer-highlight) { background: #e7c56a38; color: var(--rs-text-strong); }
.live-writer :global(.writer-code-copy:focus-visible) { outline: 1px solid var(--rs-focus); outline-offset: -2px; }
.live-writer :global(.writer-highlight) { background: color-mix(in srgb, var(--rs-highlight) 22%, transparent); color: var(--rs-text-strong); }
.live-writer :global(.writer-math) { font-family: var(--rs-font-mono); font-style: italic; }
.live-writer :global(.writer-comment) { color: var(--rs-text-dim); background: var(--rs-bg-active); }
.live-writer :global(.writer-divider-line) { display: flex; align-items: center; }
+2 -2
View File
@@ -4,7 +4,7 @@
.live-writer .rs-heading-toggle { top: .7em; }
.rs-heading-toggle { position: absolute; inset-inline-start: -30px; top: 0; width: 28px; height: 28px; padding: 6px; border: 0; border-radius: var(--rs-control-radius); color: var(--rs-text-dim); background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
.rs-heading-toggle:hover, .rs-heading-toggle:focus-visible { color: var(--rs-text); background: var(--rs-bg-active); }
.rs-heading-toggle:focus-visible { outline: 1px solid var(--rs-accent); outline-offset: 1px; }
.rs-heading-toggle:focus-visible { outline: 1px solid var(--rs-focus); outline-offset: 1px; }
.rs-heading-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rs-heading-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.rs-heading-collapsed::after { content: " …"; color: var(--rs-text-dim); font-weight: normal; }
@@ -16,4 +16,4 @@
.reading .md-footnotes li { padding-inline-start: .3em; }
.reading .md-footnotes li > p:last-of-type { display: inline; }
.reading .md-footnote-back { margin-inline-start: .4em; }
.reading .md-footnote-ref a:focus-visible, .reading .md-footnote-back:focus-visible { outline: 1px solid var(--rs-accent); outline-offset: 3px; border-radius: var(--rs-control-radius); }
.reading .md-footnote-ref a:focus-visible, .reading .md-footnote-back:focus-visible { outline: 1px solid var(--rs-focus); outline-offset: 3px; border-radius: var(--rs-control-radius); }
+3 -3
View File
@@ -11,11 +11,11 @@
.md-image-frame:hover .md-image-actions, .md-image-frame:focus-within .md-image-actions { opacity: 1; }
.image-action { position: relative; display: inline-grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; padding: 6px; color: var(--rs-text); border: 0; border-radius: 4px; background: transparent; cursor: pointer; }
.image-action:hover, .image-action:focus-visible { background: var(--rs-bg-active); color: var(--rs-text-strong); }
.image-action:focus-visible { outline: 2px solid var(--rs-accent); outline-offset: 1px; }
.image-action:focus-visible { outline: 2px solid var(--rs-focus); outline-offset: 1px; }
.image-action:disabled { opacity: .4; cursor: default; }
.image-lightbox { position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #090a0de8; color: var(--rs-text); }
.image-lightbox { position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--rs-image-viewer-bg); color: var(--rs-text); }
.image-lightbox[open] { display: flex; flex-direction: column; }
.image-lightbox::backdrop { background: #0009; }
.image-lightbox::backdrop { background: var(--rs-scrim); }
.image-lightbox-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--rs-bg-elevated); z-index: 1; }
.image-lightbox-name { margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-lightbox-scale { min-width: 44px; text-align: center; font-size: 12px; }
+3 -3
View File
@@ -2,8 +2,8 @@
.note-title-button { position: relative; display: inline-flex; align-items: center; gap: 12px; max-width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; overflow-wrap: anywhere; cursor: text; }
.note-title-button .action-icon { opacity: .45; }
.note-title-button:hover .action-icon, .note-title-button:focus-visible .action-icon { opacity: 1; color: var(--rs-accent); }
.note-title-button:focus-visible { outline: 1px solid var(--rs-accent); outline-offset: 4px; border-radius: 3px; }
.note-title-button:focus-visible { outline: 1px solid var(--rs-focus); outline-offset: 4px; border-radius: 3px; }
.note-title-input { box-sizing: border-box; width: 100%; min-width: 0; padding: 0; border: 0; border-radius: 2px; outline: 1px solid var(--rs-accent); outline-offset: 4px; background: transparent; color: inherit; font: inherit; }
.note-title-input[aria-invalid] { outline-color: var(--rs-danger, #e57878); }
.note-title-error { margin: -.8em 0 1em; color: var(--rs-danger, #e57878); font: 13px/1.5 var(--rs-font-ui); }
.note-title-input[aria-invalid] { outline-color: var(--rs-error); }
.note-title-error { margin: -.8em 0 1em; color: var(--rs-error); font: 13px/1.5 var(--rs-font-ui); }
.note-title-button[hidden], .note-title-input[hidden], .note-title-error[hidden] { display: none; }
+6 -6
View File
@@ -13,20 +13,20 @@ const syntax = (role: string, fallback: string) => `var(--rs-syntax-${role}, ${f
/** Syntax colors come from the theme tokens, so a theme change needs no editor update. */
const sourceHighlight = HighlightStyle.define([
{ tag: [tags.keyword, tags.modifier, tags.operatorKeyword, tags.controlKeyword, tags.definitionKeyword, tags.moduleKeyword, tags.tagName], color: syntax("keyword", "var(--rs-accent)") },
{ tag: tags.heading, color: syntax("keyword", "var(--rs-accent)"), fontWeight: "600" },
{ tag: tags.heading, color: syntax("heading", "var(--rs-accent)"), fontWeight: "600" },
{ tag: [tags.string, tags.special(tags.string), tags.regexp, tags.attributeValue, tags.url, tags.monospace], color: syntax("string", "var(--rs-ok)") },
{ tag: [tags.number, tags.bool, tags.null, tags.atom, tags.unit], color: syntax("number", "var(--rs-special)") },
{ tag: tags.comment, color: syntax("comment", "var(--rs-text-dim)") },
{ tag: [tags.typeName, tags.className, tags.namespace], color: syntax("type", "var(--rs-accent-2)") },
{ tag: [tags.function(tags.variableName), tags.function(tags.propertyName), tags.macroName], color: syntax("function", "var(--rs-accent-2)") },
{ tag: [tags.propertyName, tags.attributeName], color: syntax("instance", "var(--rs-accent-2)") },
{ tag: [tags.standard(tags.variableName), tags.self, tags.special(tags.variableName)], color: syntax("global", "var(--rs-text-dim)") },
{ tag: tags.variableName, color: syntax("local", "var(--rs-text)") },
{ tag: [tags.punctuation, tags.operator, tags.meta, tags.processingInstruction], color: syntax("global", "var(--rs-text-dim)") },
{ tag: [tags.propertyName, tags.attributeName], color: syntax("property", "var(--rs-accent-2)") },
{ tag: [tags.standard(tags.variableName), tags.self, tags.special(tags.variableName)], color: syntax("constant", "var(--rs-text-dim)") },
{ tag: tags.variableName, color: syntax("variable", "var(--rs-text)") },
{ tag: [tags.punctuation, tags.operator, tags.meta, tags.processingInstruction], color: syntax("punctuation", "var(--rs-text-dim)") },
{ tag: tags.emphasis, fontStyle: "italic" },
{ tag: tags.strong, fontWeight: "600" },
{ tag: tags.strikethrough, textDecoration: "line-through" },
{ tag: tags.link, color: "var(--rs-accent)", textDecoration: "underline" },
{ tag: tags.link, color: "var(--rs-link)", textDecoration: "underline" },
{ tag: tags.invalid, color: "var(--rs-error)" },
]);