Redesign the character palettes from the reference cards
Phase 5a-4. The owner chose candidate B of each palette. - Harvest Moon uses copper from Holo's tail as the accent, cream from the tail tip, and red-brown surfaces. - Crimson Pilot uses plugsuit red as the accent, orange hair, blue eyes, and the yellow dress. Borders are a low-chroma wine. Error is a light rose red, so it differs from the accent. - Silver Serpent uses silver from the grey eyes as the accent, Slytherin emerald as the second accent, and charcoal surfaces. - All eight built-in palettes pass every readability rule. The known-failure list in contrast.spec.ts is gone. - characterPalettes.spec.ts measures text selection as the app draws it, at most 65% opaque over the page (UI-029). - Docs: UI-045, and the character references in ui-color.md. pnpm check passes. pnpm test: 446 of 446 pass. Full smoke suite: 95 passed, 2 known.
This commit is contained in:
@@ -849,3 +849,24 @@ Native shell, background image, and desktop acceptance remain open.
|
|||||||
- Evidence: The comparison sheets and `readability.md` in `output/phase-5a/5a-3/` in the main checkout. `tests/unit/theme/contrast.spec.ts` lists no failures for these palettes.
|
- Evidence: The comparison sheets and `readability.md` in `output/phase-5a/5a-3/` in the main checkout. `tests/unit/theme/contrast.spec.ts` lists no failures for these palettes.
|
||||||
- Replaces / replaced by: None.
|
- Replaces / replaced by: None.
|
||||||
- Limits: Browser checks use desktop service mocks. Native desktop acceptance remains open.
|
- Limits: Browser checks use desktop service mocks. Native desktop acceptance remains open.
|
||||||
|
|
||||||
|
### UI-045 — Character palettes from the reference cards
|
||||||
|
|
||||||
|
- Type: Rule change
|
||||||
|
- Date: 2026-10-28
|
||||||
|
- Status: Implemented for user review
|
||||||
|
- Decision source: The approved Phase 5a plan, stage 5a-4, and the reference cards 0344ab0f (Holo), abada65c (Asuka), and 6d09b547 (Malfoid). The owner chose candidate B of each palette on 2026-10-28.
|
||||||
|
- Previous rule: Crimson Pilot used a saturated red for every border, and its accent and error were nearly the same red. In Harvest Moon, the accent and the warn color were both amber. In Silver Serpent, the accent and the ok color were both green. Harvest Moon and Silver Serpent errors were below 4.5:1 on panels.
|
||||||
|
- New rule: A character color goes to the accents, the selection, and the syntax roles. Surfaces and borders get low-chroma tints of the character. Each status color differs from the accent. Every character palette passes all readability rules.
|
||||||
|
- Harvest Moon (Tail): copper from the tail `#f38c48` as the accent, cream from the tail tip as the second accent, red from the eyes for numbers, and red-brown surfaces. Every identity role stays warm.
|
||||||
|
- Crimson Pilot (Plugsuit): plugsuit red `#ff564e` as the accent, orange hair as the second accent, blue eyes for types, the yellow dress for strings, wine surfaces, and a navy selection. Error is a light rose red `#ff8cc1`, so it differs from the accent.
|
||||||
|
- Silver Serpent (Silver): silver from the grey eyes `#bfd4e7` as the accent, Slytherin emerald as the second accent, platinum hair for strings, and charcoal surfaces from the robes.
|
||||||
|
- Method: A script measured the main hue clusters of the reference images, without white backgrounds, the Gryffindor scarf image, and the casual clothes image. The clusters include skin and backgrounds, so each color is an adaptation, not a sample. Text roles keep their hue and change only lightness to reach 4.5:1.
|
||||||
|
- Test change: `tests/unit/theme/characterPalettes.spec.ts` measures text selection as the app draws it, at most 65% opaque over the page ([UI-029](#ui-029--text-selection-transparency)). It measured the raw selection color before. The known-failure list in `contrast.spec.ts` is gone, because no palette fails a rule.
|
||||||
|
- Reason: Status colors stand out from the frame. Each theme keeps the colors of its character.
|
||||||
|
- Scope: Harvest Moon, Crimson Pilot, and Silver Serpent.
|
||||||
|
- Shared implementation: `themes/harvestMoon.ts`, `themes/crimsonPilot.ts`, and `themes/silverSerpent.ts`.
|
||||||
|
- Visible changes: The colors of the three palettes. File, table, and search-match selections keep the selection color at 65%, as before.
|
||||||
|
- 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.
|
||||||
|
|||||||
+4
-2
@@ -47,6 +47,8 @@ Plugins use the same tokens. [Theme tokens](plugin-development.md#theme-tokens)
|
|||||||
- RuneStone takes its accent from the rune glow of the app icon (`src-tauri/icons/icon.png`). Claude takes its colors from the Anthropic brand guide. Sakura takes its colors from the palette image in its data file.
|
- RuneStone takes its accent from the rune glow of the app icon (`src-tauri/icons/icon.png`). Claude takes its colors from the Anthropic brand guide. Sakura takes its colors from the palette image in its data file.
|
||||||
- A text role keeps the hue of its reference color. Change only its lightness until it reaches the readability minimum, and call the result an adaptation.
|
- A text role keeps the hue of its reference color. Change only its lightness until it reaches the readability minimum, and call the result an adaptation.
|
||||||
- Harvest Moon (Holo) uses the current fan art. Removed images do not count for later palette decisions.
|
- Harvest Moon (Holo) uses the current fan art. Removed images do not count for later palette decisions.
|
||||||
|
- Crimson Pilot (Asuka) and Silver Serpent (Malfoid) use their reference cards. For Malfoid, the books win over fan art, so the eyes are grey.
|
||||||
|
- A character color goes to the accents, the selection, and the syntax roles. Surfaces and borders get low-chroma tints of the character, so status colors stay visible.
|
||||||
- Take the colors of the character. Exclude scenery, lighting, alternate clothing, and unrelated details.
|
- 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.
|
- The trading screenshot and the Bloomberg example show clear information and state distinctions. They do not ask for a terminal-like appearance.
|
||||||
|
|
||||||
@@ -84,8 +86,8 @@ Each surface is the color that the app draws: a translucent role is composited o
|
|||||||
| `light-page` | In a light palette, `bg` is lighter than `bg-elevated` and `bg-active` | — |
|
| `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`.
|
`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.
|
Every built-in palette passes every rule. A palette that fails a rule fails the test.
|
||||||
`tests/unit/theme/characterPalettes.spec.ts` adds the checks of each character palette, for example over image tints.
|
`tests/unit/theme/characterPalettes.spec.ts` adds the checks of each character palette, for example over image tints. It measures text selection as the app draws it: at most 65% opaque over the page.
|
||||||
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.
|
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.
|
When contrast fails, change the foreground, background, surface, or role before you reduce color strength.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -190,7 +190,7 @@ Decisions: [UI-005](design-decisions.md#ui-005--heading-spacing).
|
|||||||
- A saved choice for a removed palette returns to RuneStone and keeps its mode and background settings. A renamed palette keeps its colors and backgrounds.
|
- A saved choice for a removed palette returns to RuneStone and keeps its mode and background settings. A renamed palette keeps its colors and backgrounds.
|
||||||
- The theme preview includes code colors.
|
- The theme preview includes code colors.
|
||||||
|
|
||||||
Decisions: [UI-009](design-decisions.md#ui-009--character-theme-appearances), [UI-012](design-decisions.md#ui-012--retain-three-stronger-character-themes), [UI-018](design-decisions.md#ui-018--named-palettes-and-local-fonts), [UI-023](design-decisions.md#ui-023--separate-theme-font-roles), [UI-024](design-decisions.md#ui-024--assertive-functional-color-by-default), [UI-044](design-decisions.md#ui-044--core-palettes-and-the-lightest-page).
|
Decisions: [UI-009](design-decisions.md#ui-009--character-theme-appearances), [UI-012](design-decisions.md#ui-012--retain-three-stronger-character-themes), [UI-018](design-decisions.md#ui-018--named-palettes-and-local-fonts), [UI-023](design-decisions.md#ui-023--separate-theme-font-roles), [UI-024](design-decisions.md#ui-024--assertive-functional-color-by-default), [UI-044](design-decisions.md#ui-044--core-palettes-and-the-lightest-page), [UI-045](design-decisions.md#ui-045--character-palettes-from-the-reference-cards).
|
||||||
|
|
||||||
### Surfaces over images
|
### Surfaces over images
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import type { BuiltinTheme } from './index.ts';
|
import type { BuiltinTheme } from './index.ts';
|
||||||
|
|
||||||
// Asuka Langley Soryu (Neon Genesis Evangelion).
|
// Asuka Langley Soryu (Neon Genesis Evangelion), from card abada65c. Plugsuit (stage 5a-4): plugsuit red is the accent,
|
||||||
|
// orange hair is the second accent, blue eyes mark types, and the yellow dress marks strings. Surfaces and borders are
|
||||||
|
// low-chroma wine, and the selection is navy. Error is a light rose red, so it differs from the red accent.
|
||||||
export const crimsonPilot = {
|
export const crimsonPilot = {
|
||||||
id: 'crimson-pilot' as const,
|
id: 'crimson-pilot' as const,
|
||||||
name: 'Crimson Pilot',
|
name: 'Crimson Pilot',
|
||||||
@@ -8,12 +10,13 @@ export const crimsonPilot = {
|
|||||||
fonts: { ui: 'Bahnschrift, "Trebuchet MS", Arial, sans-serif', prose: '"Segoe UI", "Helvetica Neue", Arial, sans-serif', heading: 'Bahnschrift, "Trebuchet MS", Arial, sans-serif' },
|
fonts: { ui: 'Bahnschrift, "Trebuchet MS", Arial, sans-serif', prose: '"Segoe UI", "Helvetica Neue", Arial, sans-serif', heading: 'Bahnschrift, "Trebuchet MS", Arial, sans-serif' },
|
||||||
variants: {
|
variants: {
|
||||||
dark: {
|
dark: {
|
||||||
bg: '#210b10', 'bg-elevated': '#341018', 'bg-active': '#461620', border: '#d93840',
|
bg: '#1b0d0e', 'bg-elevated': '#261415', 'bg-active': '#3c2224', border: '#4d2e30',
|
||||||
text: '#f4ece1', 'text-dim': '#e0b48e', 'text-strong': '#ffffff',
|
text: '#f1e9e3', 'text-dim': '#ccb0a7', 'text-strong': '#fefbf8',
|
||||||
accent: '#ff5b50', 'accent-2': '#ff9b18', selection: '#122b45', 'item-selection-bg': '#122b45a6',
|
accent: '#ff564e', 'accent-2': '#fe9052', selection: '#0d2e55', 'item-selection-bg': '#0d2e55a6',
|
||||||
error: '#f44747', 'warn-hot': '#d68a00', warn: '#cca700', ok: '#89d185', special: '#c792ea',
|
error: '#ff8cc1', 'warn-hot': '#fea92f', warn: '#f2de3c', ok: '#5cdc78', special: '#56acf0',
|
||||||
'syntax-keyword': '#ff5b50', 'syntax-variable': '#f4ece1', 'syntax-property': '#efb278', 'syntax-constant': '#83dc52', 'syntax-punctuation': '#83dc52', 'syntax-string': '#ffe066', 'syntax-number': '#ff8a3d',
|
'syntax-keyword': '#fe564e', 'syntax-string': '#f5db59', 'syntax-number': '#fe9052', 'syntax-comment': '#bfa49b',
|
||||||
'syntax-comment': '#e0b48e', 'syntax-type': '#64c9ff', 'syntax-function': '#559fff',
|
'syntax-type': '#56acf0', 'syntax-function': '#85cff3', 'syntax-property': '#ecb69f', 'syntax-variable': '#f1e9e3',
|
||||||
|
'syntax-constant': '#faab3f', 'syntax-punctuation': '#b69690', 'syntax-heading': '#fe564e',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} satisfies BuiltinTheme;
|
} satisfies BuiltinTheme;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import type { BuiltinTheme } from './index.ts';
|
import type { BuiltinTheme } from './index.ts';
|
||||||
|
|
||||||
// Holo (Spice and Wolf), from the current fan art: copper hair, brown tail, cream fur, and red eyes and apple.
|
// Holo (Spice and Wolf), from the current fan art on card 0344ab0f. Tail (stage 5a-4): copper from the tail is the accent,
|
||||||
// Amber carries active and selected states. Green scenery is outside this palette.
|
// cream from the tail tip is the second accent, and red from the eyes marks numbers. Surfaces are low-chroma red-brown.
|
||||||
|
// Every identity role stays warm. Green scenery is outside this palette.
|
||||||
export const harvestMoon = {
|
export const harvestMoon = {
|
||||||
id: 'harvest-moon' as const,
|
id: 'harvest-moon' as const,
|
||||||
name: 'Harvest Moon',
|
name: 'Harvest Moon',
|
||||||
@@ -9,12 +10,13 @@ export const harvestMoon = {
|
|||||||
fonts: { ui: 'Candara, "Trebuchet MS", "Segoe UI", sans-serif', prose: 'Constantia, Georgia, "Times New Roman", serif', heading: 'Constantia, Georgia, "Times New Roman", serif' },
|
fonts: { ui: 'Candara, "Trebuchet MS", "Segoe UI", sans-serif', prose: 'Constantia, Georgia, "Times New Roman", serif', heading: 'Constantia, Georgia, "Times New Roman", serif' },
|
||||||
variants: {
|
variants: {
|
||||||
dark: {
|
dark: {
|
||||||
bg: '#251b17', 'bg-elevated': '#382820', 'bg-active': '#40291c', border: '#ae744a',
|
bg: '#1c0f0a', 'bg-elevated': '#261611', 'bg-active': '#3c241c', border: '#4f3228',
|
||||||
text: '#eee3d1', 'text-dim': '#d3aa8b', 'text-strong': '#fff4df',
|
text: '#f4e6d2', 'text-dim': '#cfb09d', 'text-strong': '#fff7eb',
|
||||||
accent: '#ffb52e', 'accent-2': '#ff6740', selection: '#482714', 'item-selection-bg': '#482714a6',
|
accent: '#f38c48', 'accent-2': '#f5e2c0', selection: '#522814', 'item-selection-bg': '#522814a6',
|
||||||
error: '#f44747', 'warn-hot': '#d68a00', warn: '#cca700', ok: '#89d185', special: '#c792ea',
|
error: '#ff5260', 'warn-hot': '#f8a13f', warn: '#f2d935', ok: '#5edb81', special: '#f3625d',
|
||||||
'syntax-keyword': '#ff6740', 'syntax-variable': '#eee3d1', 'syntax-property': '#e5ae7e', 'syntax-constant': '#ff8d55', 'syntax-punctuation': '#ff8d55', 'syntax-string': '#ffc45b', 'syntax-number': '#ffffff',
|
'syntax-keyword': '#f38c48', 'syntax-string': '#f6d389', 'syntax-number': '#fa6863', 'syntax-comment': '#bc9e8a',
|
||||||
'syntax-comment': '#d3aa8b', 'syntax-type': '#ffe19a', 'syntax-function': '#ffb52e',
|
'syntax-type': '#fbbd6e', 'syntax-function': '#f5e2c0', 'syntax-property': '#eaae93', 'syntax-variable': '#f4e6d2',
|
||||||
|
'syntax-constant': '#feb16a', 'syntax-punctuation': '#b99683', 'syntax-heading': '#f38c48',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} satisfies BuiltinTheme;
|
} satisfies BuiltinTheme;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import type { BuiltinTheme } from './index.ts';
|
import type { BuiltinTheme } from './index.ts';
|
||||||
|
|
||||||
// "Malfoid", a fan creation: Draco Malfoy written as a female character. The books win over fan art.
|
// "Malfoid", a fan creation: Draco Malfoy written as a female character, from card 6d09b547. The books win over fan art,
|
||||||
|
// so the eyes are grey. Silver (stage 5a-4): silver from the eyes is the accent, Slytherin emerald is the second accent,
|
||||||
|
// platinum hair marks strings, and the surfaces are the charcoal of the robes.
|
||||||
export const silverSerpent = {
|
export const silverSerpent = {
|
||||||
id: 'silver-serpent' as const,
|
id: 'silver-serpent' as const,
|
||||||
name: 'Silver Serpent',
|
name: 'Silver Serpent',
|
||||||
@@ -8,12 +10,13 @@ export const silverSerpent = {
|
|||||||
fonts: { ui: 'Corbel, "Segoe UI", "Helvetica Neue", Arial, sans-serif', prose: '"Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif', heading: '"Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif' },
|
fonts: { ui: 'Corbel, "Segoe UI", "Helvetica Neue", Arial, sans-serif', prose: '"Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif', heading: '"Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif' },
|
||||||
variants: {
|
variants: {
|
||||||
dark: {
|
dark: {
|
||||||
bg: '#151c1b', 'bg-elevated': '#1d3029', 'bg-active': '#223a32', border: '#528f74',
|
bg: '#141619', 'bg-elevated': '#1c1e21', 'bg-active': '#2b3034', border: '#3b4046',
|
||||||
text: '#e3e7eb', 'text-dim': '#bec8ce', 'text-strong': '#fff5d5',
|
text: '#e5e8ec', 'text-dim': '#b3b8be', 'text-strong': '#fcf9ea',
|
||||||
accent: '#36e395', 'accent-2': '#c5d5e2', selection: '#13533a', 'item-selection-bg': '#13533aa6',
|
accent: '#bfd4e7', 'accent-2': '#31d78c', selection: '#0c6944', 'item-selection-bg': '#0c6944a6',
|
||||||
error: '#f44747', 'warn-hot': '#d68a00', warn: '#cca700', ok: '#89d185', special: '#c792ea',
|
error: '#ff645f', 'warn-hot': '#fd923e', warn: '#fec84b', ok: '#5cdc78', special: '#fb9989',
|
||||||
'syntax-keyword': '#36e395', 'syntax-variable': '#e3e7eb', 'syntax-property': '#f4c6ae', 'syntax-constant': '#edc45f', 'syntax-punctuation': '#edc45f', 'syntax-string': '#a7e7c4', 'syntax-number': '#ffb79b',
|
'syntax-keyword': '#31d78c', 'syntax-string': '#f0de99', 'syntax-number': '#fda293', 'syntax-comment': '#b2b7bd',
|
||||||
'syntax-comment': '#bec8ce', 'syntax-type': '#ffffff', 'syntax-function': '#61dfbb',
|
'syntax-type': '#c5dbee', 'syntax-function': '#5addc7', 'syntax-property': '#a4c2dc', 'syntax-variable': '#e5e8ec',
|
||||||
|
'syntax-constant': '#f2c86c', 'syntax-punctuation': '#b2b7bd', 'syntax-heading': '#31d78c',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} satisfies BuiltinTheme;
|
} satisfies BuiltinTheme;
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ await runSmoke('appearance/characterThemes', async ({ browser }) => {
|
|||||||
assert.equal(selectedRow.selected, 'true');
|
assert.equal(selectedRow.selected, 'true');
|
||||||
assert.equal(selectedRow.selection, applied.selection, 'File selection uses the same warm selection color');
|
assert.equal(selectedRow.selection, applied.selection, 'File selection uses the same warm selection color');
|
||||||
// Selection fills use the capped a6 (0.65) alpha (src/lib/theme/appearance.ts:197-203).
|
// Selection fills use the capped a6 (0.65) alpha (src/lib/theme/appearance.ts:197-203).
|
||||||
const warmFill = 'rgba(72, 39, 20, 0.65)';
|
const warmFill = 'rgba(82, 40, 20, 0.65)';
|
||||||
assert.equal(selectedRow.fill, warmFill, 'The selected file paints the warm fill');
|
assert.equal(selectedRow.fill, warmFill, 'The selected file paints the warm fill');
|
||||||
await main.screenshot({ path: path.join(output, `${theme}-${mode}-file-selection.png`) });
|
await main.screenshot({ path: path.join(output, `${theme}-${mode}-file-selection.png`) });
|
||||||
await main.getByRole('textbox', { name: 'Writing editor', exact: true }).evaluate(node => {
|
await main.getByRole('textbox', { name: 'Writing editor', exact: true }).evaluate(node => {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ await runSmoke(name, async ({ page }) => {
|
|||||||
// A short schema 3 file takes the missing colors and fonts from its base theme. An earlier theme ID names the base.
|
// A short schema 3 file takes the missing colors and fonts from its base theme. An earlier theme ID names the base.
|
||||||
await importTheme({ schema: 3, id: "short", name: "Short theme", mode: "dark", base: "holo", colors: { accent: "#00c8ff" } });
|
await importTheme({ schema: 3, id: "short", name: "Short theme", mode: "dark", base: "holo", colors: { accent: "#00c8ff" } });
|
||||||
await page.waitForFunction(() => document.documentElement.dataset.palette === "custom:short");
|
await page.waitForFunction(() => document.documentElement.dataset.palette === "custom:short");
|
||||||
assert.deepEqual([await background(), await token("accent"), await token("link"), await token("syntax-keyword")], ["#251b17", "#00c8ff", "#00c8ff", "#ff6740"]);
|
assert.deepEqual([await background(), await token("accent"), await token("link"), await token("syntax-keyword")], ["#1c0f0a", "#00c8ff", "#00c8ff", "#f38c48"]);
|
||||||
assert.match(await token("font-ui"), /Candara/);
|
assert.match(await token("font-ui"), /Candara/);
|
||||||
assert.equal(await page.evaluate(() => document.documentElement.dataset.theme), "dark");
|
assert.equal(await page.evaluate(() => document.documentElement.dataset.theme), "dark");
|
||||||
await page.screenshot({ path: path.join(output, "custom-theme-short.png") });
|
await page.screenshot({ path: path.join(output, "custom-theme-short.png") });
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import assert from 'node:assert/strict';
|
|||||||
import { test } from 'node:test';
|
import { test } from 'node:test';
|
||||||
import { BUILTIN_THEMES } from '../../../src/lib/theme/themes/index.ts';
|
import { BUILTIN_THEMES } from '../../../src/lib/theme/themes/index.ts';
|
||||||
import { SYNTAX_ROLES, resolveColors } from '../../../src/lib/theme/roles.ts';
|
import { SYNTAX_ROLES, resolveColors } from '../../../src/lib/theme/roles.ts';
|
||||||
|
import { SURFACES, appliedColors } from '../../../src/lib/theme/contrast.ts';
|
||||||
|
|
||||||
/** Every role of a dark character palette, with the derived roles. */
|
/** Every role of a dark character palette, with the derived roles. */
|
||||||
function characterTheme(theme: string) {
|
function characterTheme(theme: string) {
|
||||||
@@ -26,7 +27,9 @@ function contrast(foreground: string, background: string) {
|
|||||||
/** Named foreground groups and surfaces of a palette. Image surfaces are tinted over a white image. */
|
/** Named foreground groups and surfaces of a palette. Image surfaces are tinted over a white image. */
|
||||||
function roles(theme: string) {
|
function roles(theme: string) {
|
||||||
const palette = characterTheme(theme)!;
|
const palette = characterTheme(theme)!;
|
||||||
const { bg, 'bg-elevated': elevated, 'bg-active': active, 'text-dim': dim, text, 'text-strong': strong, accent, selection } = palette;
|
const { bg, 'bg-elevated': elevated, 'bg-active': active, 'text-dim': dim, text, 'text-strong': strong, accent } = palette;
|
||||||
|
// The app draws text selection at most 65% opaque over the page (UI-029).
|
||||||
|
const selection = SURFACES.selection(appliedColors(palette));
|
||||||
const editorOnWhite = mix(bg, '#ffffff', 0.9);
|
const editorOnWhite = mix(bg, '#ffffff', 0.9);
|
||||||
const panelOnWhite = mix(elevated, '#ffffff', 0.82);
|
const panelOnWhite = mix(elevated, '#ffffff', 0.82);
|
||||||
const foregrounds = {
|
const foregrounds = {
|
||||||
|
|||||||
@@ -9,13 +9,6 @@ import { BASE_ROLES, resolveColors, type Mode } from '../../../src/lib/theme/rol
|
|||||||
import { RULES, checkTheme } from '../../../src/lib/theme/contrast.ts';
|
import { RULES, checkTheme } from '../../../src/lib/theme/contrast.ts';
|
||||||
import { composite, contrast, distance, formatHex, mix, parseHex } from '../../../src/lib/theme/color.ts';
|
import { composite, contrast, distance, formatHex, mix, parseHex } from '../../../src/lib/theme/color.ts';
|
||||||
|
|
||||||
// Rules that a palette fails today. Stage 5a-4 redesigns these palettes and removes each entry.
|
|
||||||
const KNOWN_FAILURES: Record<string, readonly string[]> = {
|
|
||||||
'harvest-moon/dark': ['status-text', 'status-distinct'],
|
|
||||||
'crimson-pilot/dark': ['status-distinct'],
|
|
||||||
'silver-serpent/dark': ['status-text', 'status-distinct'],
|
|
||||||
};
|
|
||||||
|
|
||||||
const variants = BUILTIN_THEMES.flatMap(theme => Object.entries(theme.variants).map(([mode, colors]) => ({ key: `${theme.id}/${mode}`, mode: mode as Mode, colors: colors! })));
|
const variants = BUILTIN_THEMES.flatMap(theme => Object.entries(theme.variants).map(([mode, colors]) => ({ key: `${theme.id}/${mode}`, mode: mode as Mode, colors: colors! })));
|
||||||
|
|
||||||
for (const variant of variants) {
|
for (const variant of variants) {
|
||||||
@@ -23,24 +16,13 @@ for (const variant of variants) {
|
|||||||
for (const rule of RULES) {
|
for (const rule of RULES) {
|
||||||
const results = findings.filter(finding => finding.rule === rule.id);
|
const results = findings.filter(finding => finding.rule === rule.id);
|
||||||
if (!results.length) continue;
|
if (!results.length) continue;
|
||||||
const known = KNOWN_FAILURES[variant.key]?.includes(rule.id);
|
|
||||||
const failures = results.filter(finding => !finding.pass).map(finding => `${finding.subject}: ${finding.value.toFixed(2)} (minimum ${finding.min})`);
|
const failures = results.filter(finding => !finding.pass).map(finding => `${finding.subject}: ${finding.value.toFixed(2)} (minimum ${finding.min})`);
|
||||||
test(`${variant.key} passes the ${rule.id} rule`, known ? { todo: 'Known palette failure. Stage 5a-4 redesigns this palette.' } : {}, () => {
|
test(`${variant.key} passes the ${rule.id} rule`, () => {
|
||||||
assert.deepEqual(failures, []);
|
assert.deepEqual(failures, []);
|
||||||
});
|
});
|
||||||
if (known) test(`${variant.key} still fails the known ${rule.id} rule`, () => {
|
|
||||||
assert(failures.length > 0, `Remove ${rule.id} from KNOWN_FAILURES['${variant.key}'].`);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test('Each known failure names a built-in variant and a rule', () => {
|
|
||||||
for (const [key, rules] of Object.entries(KNOWN_FAILURES)) {
|
|
||||||
assert(variants.some(variant => variant.key === key), key);
|
|
||||||
for (const rule of rules) assert(RULES.some(item => item.id === rule), `${key}: ${rule}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Every built-in variant gives all base roles as hex colors', () => {
|
test('Every built-in variant gives all base roles as hex colors', () => {
|
||||||
for (const variant of variants) {
|
for (const variant of variants) {
|
||||||
for (const role of BASE_ROLES) assert.match(variant.colors[role] ?? '', /^#[0-9a-f]{6}$/, `${variant.key}: ${role}`);
|
for (const role of BASE_ROLES) assert.match(variant.colors[role] ?? '', /^#[0-9a-f]{6}$/, `${variant.key}: ${role}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user