1c78f19c93
Per review on #1715: the light-theme cap was a fixed absolute luminance (0.2) tuned for near-white backgrounds. On a mid-light shipped theme like light-poimandres (statusLineBg #7390aa, luminance ~0.55) that still left accents at only ~1.8-2.4:1. Theme now exposes statusLineLuminance + accentSurfaceLuminance; getSessionAccentHex takes the surface luminance and caps the accent to guarantee >=3:1 (WCAG AA large) against the actual surface, so near-white and mid-light light themes are both legible. Tests assert contrast across light + mid-light surfaces.
23 lines
1.1 KiB
TypeScript
23 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { getThemeByName } from "../src/modes/theme/theme";
|
|
|
|
describe("Theme.isLight", () => {
|
|
it("classifies built-in themes by their status-line surface", async () => {
|
|
// porcelain styles a dark chat bubble (userMessageBg) on an otherwise-light
|
|
// theme with a light status line. Session accents render on the status line,
|
|
// so it must read as light — classifying by userMessageBg got this wrong.
|
|
expect((await getThemeByName("porcelain"))?.isLight).toBe(true);
|
|
expect((await getThemeByName("light-catppuccin"))?.isLight).toBe(true);
|
|
expect((await getThemeByName("dark-catppuccin"))?.isLight).toBe(false);
|
|
});
|
|
|
|
it("exposes the status-line surface luminance for accent sizing", async () => {
|
|
const light = await getThemeByName("light-catppuccin");
|
|
const dark = await getThemeByName("dark-catppuccin");
|
|
// Light themes hand the real surface luminance to getSessionAccentHex...
|
|
expect(light?.accentSurfaceLuminance).toBeGreaterThan(0.5);
|
|
// ...dark themes pass undefined so accents stay vivid.
|
|
expect(dark?.accentSurfaceLuminance).toBeUndefined();
|
|
});
|
|
});
|