The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as NodeFS from "node:fs"; |
| 2 | import * as NodePath from "node:path"; |
| 3 | import { describe, expect, it } from "vite-plus/test"; |
| 4 | |
| 5 | import { customThemeNames, renderUniwindThemesCSS } from "./generate-uniwind-themes.mts"; |
| 6 | |
| 7 | describe("generate mobile Uniwind themes", () => { |
| 8 | it("gives every theme the same variables and a fixed Clerk palette for its appearance", () => { |
| 9 | const css = |
| 10 | NodeFS.readFileSync(NodePath.resolve(import.meta.dirname, "../global.css"), "utf8") + |
| 11 | renderUniwindThemesCSS(); |
| 12 | const themes = new Map<string, Map<string, string>>( |
| 13 | ["light", "dark", ...customThemeNames].map((name) => [name, new Map()]), |
| 14 | ); |
| 15 | for (const [, name, body] of css.matchAll(/@variant ([\w-]+) \{([^}]+)\}/gu)) { |
| 16 | const variables = themes.get(name!); |
| 17 | for (const [, variable, value] of body!.matchAll(/(--[\w-]+):\s*([^;]+);/gu)) { |
| 18 | variables?.set(variable!, value!.trim().toLowerCase()); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | const lightVariables = themes.get("light")!; |
| 23 | for (const [name, variables] of themes) { |
| 24 | expect([...variables.keys()].sort(), name).toEqual([...lightVariables.keys()].sort()); |
| 25 | const isDark = name === "dark" || name.endsWith("-dark"); |
| 26 | expect( |
| 27 | Object.fromEntries( |
| 28 | [...variables].filter(([variable]) => variable.startsWith("--color-clerk-")), |
| 29 | ), |
| 30 | name, |
| 31 | ).toEqual({ |
| 32 | "--color-clerk-page": isDark ? "#0a0a0a" : "#fcfcfc", |
| 33 | "--color-clerk-foreground": isDark ? "#f5f5f5" : "#27272a", |
| 34 | "--color-clerk-foreground-muted": isDark ? "#818181" : "#71717b", |
| 35 | "--color-clerk-border": isDark ? "#191919" : "#e4e4e7", |
| 36 | "--color-clerk-danger": isDark ? "#ff6467" : "#c10007", |
| 37 | }); |
| 38 | } |
| 39 | }); |
| 40 | }); |