дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
feat(themes): Solarized and One theme plugins (#92)
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 <[email protected]> Claude-Session: https://claude.ai/code/session_01VUYsdXA2nkF5v6zsC93dpn
Цей коміт міститься в:
1 джерело
9d8280104f
коміт
24330192c0
43 files changed
+2035
-180
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { parseColor, resolveTokenColor, toHex, toRgb } from "./cssColor";
|
||||
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
describe("css colours", () => {
|
||||
it("parses hex, rgb() and color(srgb) and formats them back", () => {
|
||||
expect(parseColor("#eee8d5")).toEqual([238, 232, 213, 1]);
|
||||
expect(parseColor("#fff8")).toEqual([255, 255, 255, 0x88 / 255]);
|
||||
expect(parseColor("rgb(33, 37, 43)")).toEqual([33, 37, 43, 1]);
|
||||
expect(parseColor("rgba(0 0 0 / 50%)")).toEqual([0, 0, 0, 0.5]);
|
||||
expect(parseColor("color(srgb 0.5 0.25 0.75 / 0.8)")).toEqual([127.5, 63.75, 191.25, 0.8]);
|
||||
expect(parseColor("hsl(220, 13%, 15%)")).toBeNull();
|
||||
expect(toHex([33, 37, 43, 1])).toBe("#21252b");
|
||||
expect(toHex([127.5, 63.75, 191.25, 0.8])).toBe("#8040bfcc");
|
||||
expect(toRgb([33, 37, 43, 1])).toBe("rgb(33, 37, 43)");
|
||||
expect(toRgb([0, 0, 0, 0.5])).toBe("rgba(0, 0, 0, 0.5)");
|
||||
});
|
||||
|
||||
it("resolves tokens written as hsl(), color-mix() or var() through the browser", () => {
|
||||
const root = document.documentElement;
|
||||
const tokens: Record<string, string> = { "--hex": "#073642", "--hsl": "hsl(220, 13%, 15%)", "--none": "" };
|
||||
vi.spyOn(globalThis, "getComputedStyle").mockImplementation(
|
||||
(el) =>
|
||||
(el === root
|
||||
? { getPropertyValue: (n: string) => tokens[n] ?? "" }
|
||||
: {
|
||||
color: (el as HTMLElement).style.color === "var(--hsl)" ? "rgb(33, 37, 43)" : "",
|
||||
}) as unknown as CSSStyleDeclaration,
|
||||
);
|
||||
expect(resolveTokenColor("--hex", root)).toEqual([7, 54, 66, 1]);
|
||||
expect(resolveTokenColor("--hsl", root)).toEqual([33, 37, 43, 1]);
|
||||
expect(resolveTokenColor("--none", root)).toBeNull();
|
||||
// The probe element is removed again.
|
||||
expect(root.querySelector("span[hidden]")).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Заблокувати користувача