M2.2: PHP highlighting, syntax colour tokens and editor.reveal
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f13a49064d
commit
6c75c08d70
25 changed files with 1044 additions and 33 deletions
|
|
@ -2,7 +2,9 @@
|
|||
* WCAG 2.1 contrast check of the built-in themes
|
||||
* (https://www.w3.org/TR/WCAG21/#contrast-minimum). Every token pair the
|
||||
* UI draws text with reaches AA: 4.5:1 for body text, 3:1 for non-text
|
||||
* marks (cursor, modified dot, settings switch knob; WCAG 1.4.11). The themes come from
|
||||
* marks (cursor, modified dot, settings switch knob; WCAG 1.4.11). Every
|
||||
* syntax colour (`--lt-syntax-*`) reaches 4.5:1 on the editor background
|
||||
* and on the active line. The themes come from
|
||||
* `themes.json`, a snapshot that the Rust test `ui_snapshot_is_current`
|
||||
* keeps equal to `lutra_engine::theme`.
|
||||
*/
|
||||
|
|
@ -42,6 +44,27 @@ const PAIRS: [string, string, number][] = [
|
|||
["tab-modified", "tab-active-bg", LARGE],
|
||||
];
|
||||
|
||||
/** Syntax token names (`--lt-syntax-<name>`), as `SYNTAX_TOKENS` in `theme.rs`. */
|
||||
export const SYNTAX = [
|
||||
"keyword",
|
||||
"string",
|
||||
"number",
|
||||
"comment",
|
||||
"variable",
|
||||
"function",
|
||||
"type",
|
||||
"constant",
|
||||
"tag",
|
||||
"attribute",
|
||||
"operator",
|
||||
] as const;
|
||||
|
||||
/** Every syntax token as text on the editor background and the active line. */
|
||||
const SYNTAX_PAIRS: [string, string, number][] = SYNTAX.flatMap((name): [string, string, number][] => [
|
||||
[`syntax-${name}`, "editor-bg", TEXT],
|
||||
[`syntax-${name}`, "editor-active-line-bg", TEXT],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Relative luminance of a `#rrggbb` colour (WCAG 2.1 definition).
|
||||
*
|
||||
|
|
@ -90,7 +113,15 @@ describe.each(themes)("theme $id", (theme) => {
|
|||
return value;
|
||||
};
|
||||
|
||||
it.each(PAIRS)("%s on %s reaches %d:1", (fg, bg, min) => {
|
||||
it("checks every syntax token it defines", () => {
|
||||
const defined = Object.keys(tokens)
|
||||
.filter((name) => name.startsWith("--lt-syntax-"))
|
||||
.map((name) => name.slice("--lt-syntax-".length))
|
||||
.sort();
|
||||
expect(defined).toEqual([...SYNTAX].sort());
|
||||
});
|
||||
|
||||
it.each([...PAIRS, ...SYNTAX_PAIRS])("%s on %s reaches %d:1", (fg, bg, min) => {
|
||||
expect(contrast(token(fg), token(bg))).toBeGreaterThanOrEqual(min);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,6 +25,17 @@
|
|||
"--lt-notice-bg": "#3a3025",
|
||||
"--lt-statusbar-bg": "#24211f",
|
||||
"--lt-statusbar-fg": "#b8afa6",
|
||||
"--lt-syntax-attribute": "#cdb87e",
|
||||
"--lt-syntax-comment": "#958d84",
|
||||
"--lt-syntax-constant": "#c4a0d6",
|
||||
"--lt-syntax-function": "#e6c46f",
|
||||
"--lt-syntax-keyword": "#d39a5c",
|
||||
"--lt-syntax-number": "#e3a1a8",
|
||||
"--lt-syntax-operator": "#b8afa6",
|
||||
"--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"
|
||||
}
|
||||
|
|
@ -55,6 +66,17 @@
|
|||
"--lt-notice-bg": "#e9dfd4",
|
||||
"--lt-statusbar-bg": "#ece7e0",
|
||||
"--lt-statusbar-fg": "#5a5149",
|
||||
"--lt-syntax-attribute": "#695d1a",
|
||||
"--lt-syntax-comment": "#6e665e",
|
||||
"--lt-syntax-constant": "#73479a",
|
||||
"--lt-syntax-function": "#7a5808",
|
||||
"--lt-syntax-keyword": "#965a22",
|
||||
"--lt-syntax-number": "#a03a4e",
|
||||
"--lt-syntax-operator": "#5a5149",
|
||||
"--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"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue