feat(settings): preview theme and UI fonts on hover
This commit is contained in:
8 files changed
+194
-17
No files matched your search
@@ -108,6 +108,33 @@ describe("useTheme on Linux", () => {
|
||||
expect(setTheme).toHaveBeenLastCalledWith("light");
|
||||
});
|
||||
|
||||
it("previews a palette without persisting it and restores the saved palette when cancelled", async () => {
|
||||
const theme = await loadTheme("light");
|
||||
theme.setThemePalette("pearl");
|
||||
await flushDynamicImport();
|
||||
setTheme.mockClear();
|
||||
|
||||
theme.previewThemePalette("cobalt");
|
||||
|
||||
expect(theme.themePalette.value).toBe("cobalt");
|
||||
expect(document.documentElement.classList.contains("theme-cobalt")).toBe(true);
|
||||
expect(window.localStorage.getItem("dbx-theme-palette")).toBe("pearl");
|
||||
expect(setTheme).not.toHaveBeenCalled();
|
||||
|
||||
theme.clearThemePalettePreview();
|
||||
|
||||
expect(theme.themePalette.value).toBe("pearl");
|
||||
expect(document.documentElement.classList.contains("theme-cobalt")).toBe(false);
|
||||
expect(window.localStorage.getItem("dbx-theme-palette")).toBe("pearl");
|
||||
|
||||
theme.previewThemePalette("sage");
|
||||
theme.setThemePalette("sage");
|
||||
theme.clearThemePalettePreview();
|
||||
|
||||
expect(theme.themePalette.value).toBe("sage");
|
||||
expect(window.localStorage.getItem("dbx-theme-palette")).toBe("sage");
|
||||
});
|
||||
|
||||
it("injects custom UI colors as inline CSS variables and removes them when leaving the custom palette", async () => {
|
||||
const theme = await loadTheme();
|
||||
theme.setThemePalette("custom");
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { useUiFontFamilyPreview } from "@/composables/useUiFontFamilyPreview";
|
||||
|
||||
describe("useUiFontFamilyPreview", () => {
|
||||
beforeEach(() => {
|
||||
useUiFontFamilyPreview().clearUiFontFamilyPreview();
|
||||
});
|
||||
|
||||
it("keeps a temporary font preview separate from the saved setting", () => {
|
||||
const preview = useUiFontFamilyPreview();
|
||||
|
||||
preview.previewUiFontFamily("'Preview Sans', sans-serif");
|
||||
expect(preview.uiFontFamilyPreview.value).toBe("'Preview Sans', sans-serif");
|
||||
|
||||
preview.clearUiFontFamilyPreview();
|
||||
expect(preview.uiFontFamilyPreview.value).toBeNull();
|
||||
});
|
||||
|
||||
it("ignores empty font values", () => {
|
||||
const preview = useUiFontFamilyPreview();
|
||||
|
||||
preview.previewUiFontFamily(" ");
|
||||
expect(preview.uiFontFamilyPreview.value).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user