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:
Knotty Wyvern
2026-10-28 17:25:51 -07:00
parent a34c1a5dce
commit 35f39e93f3
10 changed files with 63 additions and 47 deletions
@@ -132,7 +132,7 @@ await runSmoke('appearance/characterThemes', async ({ browser }) => {
assert.equal(selectedRow.selected, 'true');
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).
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');
await main.screenshot({ path: path.join(output, `${theme}-${mode}-file-selection.png`) });
await main.getByRole('textbox', { name: 'Writing editor', exact: true }).evaluate(node => {
+1 -1
View File
@@ -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.
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");
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.equal(await page.evaluate(() => document.documentElement.dataset.theme), "dark");
await page.screenshot({ path: path.join(output, "custom-theme-short.png") });
+4 -1
View File
@@ -3,6 +3,7 @@ import assert from 'node:assert/strict';
import { test } from 'node:test';
import { BUILTIN_THEMES } from '../../../src/lib/theme/themes/index.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. */
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. */
function roles(theme: string) {
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 panelOnWhite = mix(elevated, '#ffffff', 0.82);
const foregrounds = {
+1 -19
View File
@@ -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 { 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! })));
for (const variant of variants) {
@@ -23,24 +16,13 @@ for (const variant of variants) {
for (const rule of RULES) {
const results = findings.filter(finding => finding.rule === rule.id);
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})`);
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, []);
});
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', () => {
for (const variant of variants) {
for (const role of BASE_ROLES) assert.match(variant.colors[role] ?? '', /^#[0-9a-f]{6}$/, `${variant.key}: ${role}`);