feat(design): Matrix toned down to moss, text on an accent fill held to --accent-fg
The lime accent was the loudest of the four (OKLCH L 0.85, C 0.21) and read as neon; the owner chose the moss variant at Midnight's lightness with near-neutral greys, and the Matrix backdrops follow it. Fixed white/black parts on a solid accent fill (two switch knobs, three play buttons, the Up next pill) now use --accent-fg, and theme.contract.test.ts refuses a fixed white or black next to a solid bg-accent.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { hexContrast, hueGap, mixHex } from "./colorMath";
|
||||
import { SCHEMES } from "./theme";
|
||||
@@ -40,6 +40,23 @@ it("styles exactly the schemes the app offers", () => {
|
||||
expect(css).toMatch(/--edge-strong:\s*color-mix\(in srgb, var\(--fg\) 55%, var\(--bg\)\)/);
|
||||
});
|
||||
|
||||
// The 4.5:1 above only holds for text that USES --accent-fg: a fixed white or black on a solid accent
|
||||
// fill passes on one scheme and fails on the next (white on the old Matrix lime was 1.5:1).
|
||||
it("text on a solid accent fill uses --accent-fg", () => {
|
||||
const root = new URL("../", import.meta.url);
|
||||
const offenders: string[] = [];
|
||||
for (const f of readdirSync(root, { recursive: true, encoding: "utf8" })) {
|
||||
if (!f.endsWith(".tsx")) continue;
|
||||
readFileSync(new URL(f.replace(/\\/g, "/"), root), "utf8")
|
||||
.split("\n")
|
||||
.forEach((line, i) => {
|
||||
if (/\bbg-accent(?![\w/-])/.test(line) && /\b(text|bg)-(white|black)\b/.test(line))
|
||||
offenders.push(`${f}:${i + 1}`);
|
||||
});
|
||||
}
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
|
||||
describe.each(SCHEMES.map((s) => s.id))("scheme %s", (id) => {
|
||||
it.each(MODES)("%s: backdrop rule and file", (mode) => {
|
||||
const file = `backdrops/${mode === "light" ? "light/" : ""}${id}.svg`;
|
||||
|
||||
@@ -10,7 +10,7 @@ export const SCHEMES: { id: Scheme; name: string; swatch: string }[] = [
|
||||
{ id: "midnight", name: "Midnight", swatch: "#6d8cff" },
|
||||
{ id: "forest", name: "Forest", swatch: "#22d3ee" },
|
||||
{ id: "slate", name: "Slate", swatch: "#e879f9" },
|
||||
{ id: "matrix", name: "Matrix", swatch: "#a3e635" },
|
||||
{ id: "matrix", name: "Matrix", swatch: "#86a05a" },
|
||||
];
|
||||
|
||||
export interface ThemePrefs {
|
||||
|
||||
Reference in New Issue
Block a user