Fix automatic readable text contrast for public and admin themes.
Local Build and Deploy / deploy (push) Successful in 55s
Local Build and Deploy / deploy (push) Successful in 55s
Derive admin/public text colors from WCAG contrast, unify ThemeVars CSS emission, and keep navbar overrides in sync with readable vars. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
9d4d409b77
commit
d7278c77f9
9 files changed
+205
-176
No files matched your search
@@ -130,6 +130,48 @@ describe("deriveAdminPalette", () => {
|
||||
expect(admin.canvas).not.toBe("#ff00ff");
|
||||
expect(admin.surface).not.toBe("#00ff00");
|
||||
});
|
||||
|
||||
it("repairs default light text when admin canvas is forced light", () => {
|
||||
const admin = deriveAdminPalette(
|
||||
{ color_primary: "#f59e0b" },
|
||||
{
|
||||
canvas: "#ffffff",
|
||||
surface: "#f8fafc",
|
||||
surfaceElevated: "#f1f5f9",
|
||||
sidebar: "#ffffff",
|
||||
},
|
||||
);
|
||||
expect(contrastRatio(admin.text, admin.canvas)).toBeGreaterThanOrEqual(4.5);
|
||||
expect(contrastRatio(admin.text, admin.surface)).toBeGreaterThanOrEqual(4.5);
|
||||
expect(contrastRatio(admin.muted, admin.surface)).toBeGreaterThanOrEqual(
|
||||
4.5,
|
||||
);
|
||||
expect(
|
||||
contrastRatio(admin.sidebarText, admin.sidebar),
|
||||
).toBeGreaterThanOrEqual(4.5);
|
||||
expect(
|
||||
contrastRatio(admin.accentForeground, admin.accent),
|
||||
).toBeGreaterThanOrEqual(4.5);
|
||||
});
|
||||
|
||||
it("repairs hostile admin text overrides on dark canvas", () => {
|
||||
const admin = deriveAdminPalette(
|
||||
{ color_primary: "#111827" },
|
||||
{
|
||||
canvas: "#0b0f19",
|
||||
surface: "#151b27",
|
||||
text: "#0b0f19",
|
||||
muted: "#111827",
|
||||
},
|
||||
);
|
||||
expect(contrastRatio(admin.text, admin.canvas)).toBeGreaterThanOrEqual(4.5);
|
||||
expect(contrastRatio(admin.muted, admin.surface)).toBeGreaterThanOrEqual(
|
||||
4.5,
|
||||
);
|
||||
expect(
|
||||
contrastRatio(admin.accentForeground, admin.accent),
|
||||
).toBeGreaterThanOrEqual(4.5);
|
||||
});
|
||||
});
|
||||
|
||||
describe("derivePublicForegrounds", () => {
|
||||
|
||||
Reference in new issue
Block a user