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);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -77,8 +77,8 @@ describe("applyTheme", () => {
|
|||
expect(root.dataset.theme).toBe("lutra-light");
|
||||
|
||||
applyTheme(byId("lutra-dark"));
|
||||
expect(root.style.getPropertyValue("--lt-bg")).toBe("#1f1d1b");
|
||||
expect(root.style.getPropertyValue("--lt-editor-selection-bg")).toBe("#513f2c");
|
||||
expect(root.style.getPropertyValue("--lt-bg")).toBe("#1e1b1e");
|
||||
expect(root.style.getPropertyValue("--lt-editor-selection-bg")).toBe("#4c2d3d");
|
||||
expect(root.style.colorScheme).toBe("dark");
|
||||
});
|
||||
});
|
||||
|
|
@ -121,7 +121,7 @@ describe("startTheme", () => {
|
|||
media.change(true);
|
||||
await flushPromises();
|
||||
expect(root.dataset.theme).toBe("lutra-dark");
|
||||
expect(root.style.getPropertyValue("--lt-bg")).toBe("#1f1d1b");
|
||||
expect(root.style.getPropertyValue("--lt-bg")).toBe("#1e1b1e");
|
||||
|
||||
stop();
|
||||
expect(media.handlers.size).toBe(0);
|
||||
|
|
@ -135,7 +135,7 @@ describe("startTheme", () => {
|
|||
expect(emit).toBeDefined();
|
||||
emit?.({ payload: { kind: "themeChanged", ...byId("lutra-light") } });
|
||||
expect(root.dataset.theme).toBe("lutra-light");
|
||||
expect(root.style.getPropertyValue("--lt-notice-bg")).toBe("#e9dfd4");
|
||||
expect(root.style.getPropertyValue("--lt-notice-bg")).toBe("#eedcdc");
|
||||
emit?.({ payload: { kind: "treeChanged", dir: "" } });
|
||||
expect(root.dataset.theme).toBe("lutra-light");
|
||||
stop();
|
||||
|
|
|
|||
|
|
@ -4,60 +4,70 @@
|
|||
"id": "lutra-dark",
|
||||
"labelKey": "theme.lutraDark",
|
||||
"tokens": {
|
||||
"--lt-accent": "#d39a5c",
|
||||
"--lt-bg": "#1f1d1b",
|
||||
"--lt-border": "#34302c",
|
||||
"--lt-editor-active-line-bg": "#232221",
|
||||
"--lt-editor-bg": "#191817",
|
||||
"--lt-editor-cursor": "#d39a5c",
|
||||
"--lt-editor-gutter-bg": "#191817",
|
||||
"--lt-editor-gutter-fg": "#9a928a",
|
||||
"--lt-editor-match-bg": "#3a2f23",
|
||||
"--lt-editor-selection-bg": "#513f2c",
|
||||
"--lt-error": "#ef7b6c",
|
||||
"--lt-fg": "#e6e1da",
|
||||
"--lt-fg-muted": "#9a928a",
|
||||
"--lt-accent": "#e27ba6",
|
||||
"--lt-bg": "#1e1b1e",
|
||||
"--lt-border": "#362f35",
|
||||
"--lt-diag-error": "#f2836b",
|
||||
"--lt-diag-hint": "#9e9499",
|
||||
"--lt-diag-info": "#8fb0e8",
|
||||
"--lt-diag-warning": "#e6b450",
|
||||
"--lt-editor-active-line-bg": "#221f22",
|
||||
"--lt-editor-bg": "#181618",
|
||||
"--lt-editor-cursor": "#e27ba6",
|
||||
"--lt-editor-gutter-bg": "#181618",
|
||||
"--lt-editor-gutter-fg": "#9e9499",
|
||||
"--lt-editor-match-bg": "#3a2632",
|
||||
"--lt-editor-selection-bg": "#4c2d3d",
|
||||
"--lt-error": "#f2836b",
|
||||
"--lt-fg": "#ebe5dc",
|
||||
"--lt-fg-muted": "#9e9499",
|
||||
"--lt-font-mono": "ui-monospace, \"Cascadia Code\", Menlo, Consolas, monospace",
|
||||
"--lt-font-size-editor": "14px",
|
||||
"--lt-font-size-small": "12px",
|
||||
"--lt-font-size-ui": "13px",
|
||||
"--lt-font-ui": "system-ui, -apple-system, \"Segoe UI\", Roboto, Ubuntu, sans-serif",
|
||||
"--lt-notice-bg": "#3a3025",
|
||||
"--lt-statusbar-bg": "#24211f",
|
||||
"--lt-statusbar-fg": "#b8afa6",
|
||||
"--lt-notice-bg": "#382632",
|
||||
"--lt-statusbar-bg": "#231f23",
|
||||
"--lt-statusbar-fg": "#bdb3b8",
|
||||
"--lt-syntax-attribute": "#cdb87e",
|
||||
"--lt-syntax-comment": "#958d84",
|
||||
"--lt-syntax-constant": "#c4a0d6",
|
||||
"--lt-syntax-comment": "#978e93",
|
||||
"--lt-syntax-constant": "#b9a5e2",
|
||||
"--lt-syntax-function": "#e6c46f",
|
||||
"--lt-syntax-keyword": "#d39a5c",
|
||||
"--lt-syntax-number": "#e3a1a8",
|
||||
"--lt-syntax-operator": "#b8afa6",
|
||||
"--lt-syntax-keyword": "#d98aab",
|
||||
"--lt-syntax-number": "#e8a87c",
|
||||
"--lt-syntax-operator": "#bdb3b8",
|
||||
"--lt-syntax-string": "#a9bd7e",
|
||||
"--lt-syntax-tag": "#e08b70",
|
||||
"--lt-syntax-type": "#7fbac6",
|
||||
"--lt-syntax-variable": "#d8bba6",
|
||||
"--lt-tab-active-bg": "#191817",
|
||||
"--lt-tab-modified": "#d39a5c",
|
||||
"--lt-terminal-ansi-black": "#2e2b28",
|
||||
"--lt-syntax-variable": "#dcc6b2",
|
||||
"--lt-tab-active-bg": "#181618",
|
||||
"--lt-tab-modified": "#e27ba6",
|
||||
"--lt-terminal-ansi-black": "#2e2a2e",
|
||||
"--lt-terminal-ansi-blue": "#8fa8e0",
|
||||
"--lt-terminal-ansi-bright-black": "#9a928a",
|
||||
"--lt-terminal-ansi-bright-black": "#9e9499",
|
||||
"--lt-terminal-ansi-bright-blue": "#aebff0",
|
||||
"--lt-terminal-ansi-bright-cyan": "#a2d3dc",
|
||||
"--lt-terminal-ansi-bright-green": "#c2d69a",
|
||||
"--lt-terminal-ansi-bright-magenta": "#dbbde8",
|
||||
"--lt-terminal-ansi-bright-magenta": "#f0a6c6",
|
||||
"--lt-terminal-ansi-bright-red": "#f59a8d",
|
||||
"--lt-terminal-ansi-bright-white": "#f5f1ec",
|
||||
"--lt-terminal-ansi-bright-white": "#f7f2ea",
|
||||
"--lt-terminal-ansi-bright-yellow": "#f2d88e",
|
||||
"--lt-terminal-ansi-cyan": "#7fbac6",
|
||||
"--lt-terminal-ansi-green": "#a9bd7e",
|
||||
"--lt-terminal-ansi-magenta": "#c4a0d6",
|
||||
"--lt-terminal-ansi-magenta": "#e27ba6",
|
||||
"--lt-terminal-ansi-red": "#ef7b6c",
|
||||
"--lt-terminal-ansi-white": "#d0c9c1",
|
||||
"--lt-terminal-ansi-white": "#d3cbc4",
|
||||
"--lt-terminal-ansi-yellow": "#e6c46f",
|
||||
"--lt-terminal-bg": "#191817",
|
||||
"--lt-terminal-cursor": "#d39a5c",
|
||||
"--lt-terminal-fg": "#e6e1da",
|
||||
"--lt-terminal-selection-bg": "#513f2c"
|
||||
"--lt-terminal-bg": "#181618",
|
||||
"--lt-terminal-cursor": "#e27ba6",
|
||||
"--lt-terminal-fg": "#ebe5dc",
|
||||
"--lt-terminal-selection-bg": "#4c2d3d",
|
||||
"--lt-vcs-added": "#9cc27a",
|
||||
"--lt-vcs-conflicted": "#f26d82",
|
||||
"--lt-vcs-deleted": "#d4908a",
|
||||
"--lt-vcs-ignored": "#8f878b",
|
||||
"--lt-vcs-modified": "#8fb0e8",
|
||||
"--lt-vcs-untracked": "#e3a464"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -65,60 +75,70 @@
|
|||
"id": "lutra-light",
|
||||
"labelKey": "theme.lutraLight",
|
||||
"tokens": {
|
||||
"--lt-accent": "#965a22",
|
||||
"--lt-bg": "#f4f1ec",
|
||||
"--lt-border": "#ddd6cd",
|
||||
"--lt-editor-active-line-bg": "#f1efed",
|
||||
"--lt-editor-bg": "#fbfaf8",
|
||||
"--lt-editor-cursor": "#965a22",
|
||||
"--lt-editor-gutter-bg": "#fbfaf8",
|
||||
"--lt-editor-gutter-fg": "#6b625a",
|
||||
"--lt-editor-match-bg": "#ece2d8",
|
||||
"--lt-editor-selection-bg": "#e5d7c9",
|
||||
"--lt-accent": "#a32c66",
|
||||
"--lt-bg": "#f3efe3",
|
||||
"--lt-border": "#ddd5c4",
|
||||
"--lt-diag-error": "#b23a29",
|
||||
"--lt-diag-hint": "#675d61",
|
||||
"--lt-diag-info": "#2f5aa8",
|
||||
"--lt-diag-warning": "#865500",
|
||||
"--lt-editor-active-line-bg": "#f3f0e8",
|
||||
"--lt-editor-bg": "#fbf9f3",
|
||||
"--lt-editor-cursor": "#a32c66",
|
||||
"--lt-editor-gutter-bg": "#fbf9f3",
|
||||
"--lt-editor-gutter-fg": "#675d61",
|
||||
"--lt-editor-match-bg": "#f2e1e3",
|
||||
"--lt-editor-selection-bg": "#ecd6dc",
|
||||
"--lt-error": "#b23a29",
|
||||
"--lt-fg": "#2a2622",
|
||||
"--lt-fg-muted": "#6b625a",
|
||||
"--lt-fg": "#2a2427",
|
||||
"--lt-fg-muted": "#675d61",
|
||||
"--lt-font-mono": "ui-monospace, \"Cascadia Code\", Menlo, Consolas, monospace",
|
||||
"--lt-font-size-editor": "14px",
|
||||
"--lt-font-size-small": "12px",
|
||||
"--lt-font-size-ui": "13px",
|
||||
"--lt-font-ui": "system-ui, -apple-system, \"Segoe UI\", Roboto, Ubuntu, sans-serif",
|
||||
"--lt-notice-bg": "#e9dfd4",
|
||||
"--lt-statusbar-bg": "#ece7e0",
|
||||
"--lt-statusbar-fg": "#5a5149",
|
||||
"--lt-notice-bg": "#eedcdc",
|
||||
"--lt-statusbar-bg": "#ebe5d5",
|
||||
"--lt-statusbar-fg": "#554c50",
|
||||
"--lt-syntax-attribute": "#695d1a",
|
||||
"--lt-syntax-comment": "#6e665e",
|
||||
"--lt-syntax-constant": "#73479a",
|
||||
"--lt-syntax-comment": "#6b6367",
|
||||
"--lt-syntax-constant": "#5e489e",
|
||||
"--lt-syntax-function": "#7a5808",
|
||||
"--lt-syntax-keyword": "#965a22",
|
||||
"--lt-syntax-number": "#a03a4e",
|
||||
"--lt-syntax-operator": "#5a5149",
|
||||
"--lt-syntax-keyword": "#9a2d61",
|
||||
"--lt-syntax-number": "#9c4519",
|
||||
"--lt-syntax-operator": "#554c50",
|
||||
"--lt-syntax-string": "#4e6a24",
|
||||
"--lt-syntax-tag": "#a5432a",
|
||||
"--lt-syntax-type": "#24697a",
|
||||
"--lt-syntax-variable": "#7f4a34",
|
||||
"--lt-tab-active-bg": "#fbfaf8",
|
||||
"--lt-tab-modified": "#965a22",
|
||||
"--lt-terminal-ansi-black": "#2a2622",
|
||||
"--lt-tab-active-bg": "#fbf9f3",
|
||||
"--lt-tab-modified": "#a32c66",
|
||||
"--lt-terminal-ansi-black": "#2a2427",
|
||||
"--lt-terminal-ansi-blue": "#2f55a4",
|
||||
"--lt-terminal-ansi-bright-black": "#6b625a",
|
||||
"--lt-terminal-ansi-bright-black": "#675d61",
|
||||
"--lt-terminal-ansi-bright-blue": "#233f7f",
|
||||
"--lt-terminal-ansi-bright-cyan": "#1a5260",
|
||||
"--lt-terminal-ansi-bright-green": "#3b5418",
|
||||
"--lt-terminal-ansi-bright-magenta": "#5a3480",
|
||||
"--lt-terminal-ansi-bright-magenta": "#7c1f4d",
|
||||
"--lt-terminal-ansi-bright-red": "#8f2a1c",
|
||||
"--lt-terminal-ansi-bright-white": "#f4f1ec",
|
||||
"--lt-terminal-ansi-bright-white": "#f3efe3",
|
||||
"--lt-terminal-ansi-bright-yellow": "#5f4404",
|
||||
"--lt-terminal-ansi-cyan": "#24697a",
|
||||
"--lt-terminal-ansi-green": "#4e6a24",
|
||||
"--lt-terminal-ansi-magenta": "#73479a",
|
||||
"--lt-terminal-ansi-magenta": "#a32c66",
|
||||
"--lt-terminal-ansi-red": "#b23a29",
|
||||
"--lt-terminal-ansi-white": "#ddd6cd",
|
||||
"--lt-terminal-ansi-white": "#ddd5c4",
|
||||
"--lt-terminal-ansi-yellow": "#7a5808",
|
||||
"--lt-terminal-bg": "#fbfaf8",
|
||||
"--lt-terminal-cursor": "#965a22",
|
||||
"--lt-terminal-fg": "#2a2622",
|
||||
"--lt-terminal-selection-bg": "#e5d7c9"
|
||||
"--lt-terminal-bg": "#fbf9f3",
|
||||
"--lt-terminal-cursor": "#a32c66",
|
||||
"--lt-terminal-fg": "#2a2427",
|
||||
"--lt-terminal-selection-bg": "#ecd6dc",
|
||||
"--lt-vcs-added": "#3d7526",
|
||||
"--lt-vcs-conflicted": "#b01f45",
|
||||
"--lt-vcs-deleted": "#a3463b",
|
||||
"--lt-vcs-ignored": "#71686c",
|
||||
"--lt-vcs-modified": "#2f5aa8",
|
||||
"--lt-vcs-untracked": "#93560c"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue