diff --git a/apps/app/src/react-app/domains/settings/appearance/theme-section.tsx b/apps/app/src/react-app/domains/settings/appearance/theme-section.tsx index 9f3b0cd72..ac547ce69 100644 --- a/apps/app/src/react-app/domains/settings/appearance/theme-section.tsx +++ b/apps/app/src/react-app/domains/settings/appearance/theme-section.tsx @@ -14,6 +14,11 @@ import { type ThemeMode = AppearanceViewProps["themeMode"]; +export const THEME_PREVIEW_CLASSES: Record<"light" | "dark", string> = { + light: "bg-white", + dark: "bg-black", +}; + interface ThemeSectionProps extends Pick {} @@ -69,14 +74,14 @@ function ThemePicker(props: ThemePickerProps) { value="light" label={t("settings.theme_light")} > - + {t("settings.theme_light")} - + {t("settings.theme_dark")} @@ -116,8 +121,8 @@ function ThemePreview(props: ThemePreviewProps) { > {props.value === "system" && (
-
-
+
+
)}
diff --git a/apps/app/tests/theme-preview.test.ts b/apps/app/tests/theme-preview.test.ts new file mode 100644 index 000000000..4ed0f9cef --- /dev/null +++ b/apps/app/tests/theme-preview.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, test } from "bun:test"; + +import tailwindConfig from "../tailwind.config"; +import { THEME_PREVIEW_CLASSES } from "../src/react-app/domains/settings/appearance/theme-section"; + +describe("theme picker previews", () => { + test("uses fixed light and dark preview colors", () => { + expect(THEME_PREVIEW_CLASSES.light).toBe("bg-white"); + expect(THEME_PREVIEW_CLASSES.dark).toBe("bg-black"); + }); + + test("uses colors defined by the Tailwind palette", () => { + for (const className of Object.values(THEME_PREVIEW_CLASSES)) { + const colorName = className.replace("bg-", ""); + + expect(Object.hasOwn(tailwindConfig.theme.colors, colorName)).toBe(true); + } + }); +});