H5: banner-aligned themes, diagnostic and VCS tokens
Both themes follow the README banner without taking it over: calm, near-neutral surfaces (cream-tinted light, faintly plum-tinted dark), the raspberry only as the accent, retuned syntax colours and the terminal on the editor surface. Approved by the owner from before/after screenshots. New tokens `--lt-diag-error|warning|info|hint` (lint underlines, gutter, tooltips, Problems icons) and `--lt-vcs-added|modified|deleted|untracked| ignored|conflicted` (for M4.4), listed in `theme::DIAGNOSTIC_TOKENS` and `theme::VCS_TOKENS`. Completion kind icons take the syntax colour of their kind. The contrast test checks every new colour (4.5:1 text, 3:1 icons) in both themes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e73bdbbbbc
commit
9801a346b6
13 changed files with 345 additions and 175 deletions
|
|
@ -6,12 +6,17 @@
|
|||
* syntax colour (`--lt-syntax-*`) reaches 4.5:1 on the editor background
|
||||
* and on the active line. The terminal's text, cursor and every ANSI colour
|
||||
* that shows as text reach AA on the terminal background (M3.6); the colour
|
||||
* meant to vanish into it is exempt per theme (`TERMINAL_EXEMPT`). The
|
||||
* meant to vanish into it is exempt per theme (`TERMINAL_EXEMPT`). Every
|
||||
* diagnostic severity (`--lt-diag-*`) and version-control status
|
||||
* (`--lt-vcs-*`) colour reaches 4.5:1 on the editor background, the active
|
||||
* line and the window background, and every completion kind icon colour
|
||||
* reaches 3:1 on the popup and its selected row (H5). The
|
||||
* themes come from
|
||||
* `themes.json`, a snapshot that the Rust test `ui_snapshot_is_current`
|
||||
* keeps equal to `lutra_engine::theme`.
|
||||
*/
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { KIND_COLOURS } from "../../src/components/editor/assist/icons";
|
||||
import themes from "./themes.json";
|
||||
|
||||
/** Minimum ratio for normal-size text (AA). */
|
||||
|
|
@ -68,6 +73,29 @@ const SYNTAX_PAIRS: [string, string, number][] = SYNTAX.flatMap((name): [string,
|
|||
[`syntax-${name}`, "editor-active-line-bg", TEXT],
|
||||
]);
|
||||
|
||||
/** Diagnostic severity names (`--lt-diag-<name>`), as `DIAGNOSTIC_TOKENS` in `theme.rs`. */
|
||||
export const DIAGNOSTIC = ["error", "warning", "info", "hint"] as const;
|
||||
|
||||
/** Version-control status names (`--lt-vcs-<name>`), as `VCS_TOKENS` in `theme.rs`. */
|
||||
export const VCS = ["added", "modified", "deleted", "untracked", "ignored", "conflicted"] as const;
|
||||
|
||||
/** Backgrounds the diagnostic and status colours are drawn on as text or marks. */
|
||||
const STATUS_BACKGROUNDS = ["editor-bg", "editor-active-line-bg", "bg"] as const;
|
||||
|
||||
/** Every diagnostic and status colour on each of its backgrounds. */
|
||||
const STATUS_PAIRS: [string, string, number][] = [
|
||||
...DIAGNOSTIC.map((name) => `diag-${name}`),
|
||||
...VCS.map((name) => `vcs-${name}`),
|
||||
].flatMap((fg) => STATUS_BACKGROUNDS.map((bg): [string, string, number] => [fg, bg, TEXT]));
|
||||
|
||||
/** Every completion kind icon colour on the popup and its selected row. */
|
||||
const KIND_PAIRS: [string, string, number][] = [...new Set(Object.values(KIND_COLOURS))].flatMap(
|
||||
(fg): [string, string, number][] => [
|
||||
[fg, "bg", LARGE],
|
||||
[fg, "editor-selection-bg", LARGE],
|
||||
],
|
||||
);
|
||||
|
||||
/** ANSI colour names, as in `TERMINAL_TOKENS` in `theme.rs`. */
|
||||
const ANSI = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] as const;
|
||||
|
||||
|
|
@ -153,12 +181,22 @@ describe.each(themes)("theme $id", (theme) => {
|
|||
expect(defined).toEqual([...SYNTAX].sort());
|
||||
});
|
||||
|
||||
it("checks every diagnostic and status token it defines", () => {
|
||||
const defined = (prefix: string): string[] =>
|
||||
Object.keys(tokens)
|
||||
.filter((name) => name.startsWith(prefix))
|
||||
.map((name) => name.slice(prefix.length))
|
||||
.sort();
|
||||
expect(defined("--lt-diag-")).toEqual([...DIAGNOSTIC].sort());
|
||||
expect(defined("--lt-vcs-")).toEqual([...VCS].sort());
|
||||
});
|
||||
|
||||
it("checks every terminal ANSI token it defines", () => {
|
||||
const defined = Object.keys(tokens).filter((name) => name.startsWith("--lt-terminal-ansi-"));
|
||||
expect(defined).toHaveLength(ANSI.length * 2);
|
||||
});
|
||||
|
||||
it.each([...PAIRS, ...SYNTAX_PAIRS, ...terminalPairs(theme.id)])("%s on %s reaches %d:1", (fg, bg, min) => {
|
||||
it.each([...PAIRS, ...SYNTAX_PAIRS, ...STATUS_PAIRS, ...KIND_PAIRS, ...terminalPairs(theme.id)])("%s on %s reaches %d:1", (fg, bg, min) => {
|
||||
expect(contrast(token(fg), token(bg))).toBeGreaterThanOrEqual(min);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue