mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-07 00:07:29 +00:00
Solarized Light/Dark and One Light/Dark ship as theme plugins (plugins/theme-solarized, plugins/theme-one) with complete UI tokens, editor schemes and terminal colours, and the original palettes' MIT notices. Installing a plugin now also copies its LICENSE/NOTICE/COPYING. Theme handling that benefits every plugin theme: - The last plugin theme is restored before first paint (splash, workbench); the native window background follows the theme. - HSL / color-mix() / var() colours are resolved to RGB for native windows, the Settings window and Mermaid. - Mermaid, the terminal and editor schemes follow switches between two themes of the same kind. - An explicitly chosen editor scheme wins over a plugin theme's editor colours. Supersedes #85. Co-authored-by: bghtyu <3931591+bghtyu@users.noreply.github.com> Claude-Session: https://claude.ai/code/session_01VUYsdXA2nkF5v6zsC93dpn
45 lines
1.8 KiB
TypeScript
45 lines
1.8 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { rememberStartupTheme, STARTUP_THEME_KEY, windowBackgroundColor, windowBackgroundHex } from "./theme";
|
|
|
|
const mockFrame = (token: string, resolved = "") =>
|
|
vi
|
|
.spyOn(globalThis, "getComputedStyle")
|
|
.mockReturnValue({ getPropertyValue: () => token, color: resolved } as unknown as CSSStyleDeclaration);
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
localStorage.clear();
|
|
});
|
|
|
|
describe("window background", () => {
|
|
it("resolves the frame to Tauri's RGBA tuple instead of passing CSS hsl() or mixes", () => {
|
|
mockFrame("#26282c");
|
|
expect(windowBackgroundColor()).toEqual([38, 40, 44, 255]);
|
|
mockFrame("hsl(230, 1%, 92%)", "rgb(234, 234, 235)");
|
|
expect(windowBackgroundColor()).toEqual([234, 234, 235, 255]);
|
|
expect(windowBackgroundHex()).toBe("#eaeaeb");
|
|
mockFrame("color-mix(in srgb, #8040bf 80%, transparent)", "color(srgb 0.5 0.25 0.75 / 0.8)");
|
|
expect(windowBackgroundColor()).toEqual([128, 64, 191, 204]);
|
|
expect(windowBackgroundHex()).toBe("#8040bfcc");
|
|
mockFrame("", "");
|
|
expect(windowBackgroundColor()).toBeNull();
|
|
expect(windowBackgroundHex()).toBeNull();
|
|
});
|
|
|
|
it("remembers the base and the resolved splash colours for the next window", () => {
|
|
const root = document.documentElement;
|
|
root.dataset.theme = "light";
|
|
const values: Record<string, string> = { "--bg-frame": "#eee8d5", "--fg-muted": "#657b83", "--accent": "#268bd2" };
|
|
vi.spyOn(globalThis, "getComputedStyle").mockReturnValue({
|
|
getPropertyValue: (n: string) => values[n] ?? "",
|
|
} as unknown as CSSStyleDeclaration);
|
|
rememberStartupTheme(root);
|
|
expect(JSON.parse(localStorage.getItem(STARTUP_THEME_KEY)!)).toEqual({
|
|
theme: "light",
|
|
frame: "#eee8d5",
|
|
fg: "#657b83",
|
|
accent: "#268bd2",
|
|
});
|
|
});
|
|
});
|