diff --git a/apps/loopover-ui/src/components/site/api/try-it.tsx b/apps/loopover-ui/src/components/site/api/try-it.tsx index 910cdd28a9..4244a0bf75 100644 --- a/apps/loopover-ui/src/components/site/api/try-it.tsx +++ b/apps/loopover-ui/src/components/site/api/try-it.tsx @@ -250,7 +250,7 @@ export function TryIt({ op, server }: { op: OpenApiOperation; server: string }) onChange={(e) => setBody(e.target.value)} rows={6} spellCheck={false} - className="w-full rounded-token border border-border bg-[oklch(0.13_0.005_260)] p-3 font-mono text-[12px] text-foreground focus:border-mint/40 focus:outline-none" + className="w-full rounded-token border border-border bg-surface-code p-3 font-mono text-[12px] text-foreground focus:border-mint/40 focus:outline-none" /> )} @@ -338,7 +338,7 @@ export function TryIt({ op, server }: { op: OpenApiOperation; server: string }) -
+          
             {result.body}
           
diff --git a/apps/loopover-ui/src/components/site/app-panels/maintainer-panel.tsx b/apps/loopover-ui/src/components/site/app-panels/maintainer-panel.tsx index f8a7c99aeb..f39ede8879 100644 --- a/apps/loopover-ui/src/components/site/app-panels/maintainer-panel.tsx +++ b/apps/loopover-ui/src/components/site/app-panels/maintainer-panel.tsx @@ -855,7 +855,7 @@ export function PreviewResult({ sanitized -
+        
           {preview.previewComment ?? "No public comment would be posted for this scenario."}
         
diff --git a/apps/loopover-ui/src/components/site/control-primitives.tsx b/apps/loopover-ui/src/components/site/control-primitives.tsx index 68cc377f07..c3c1ebe0f6 100644 --- a/apps/loopover-ui/src/components/site/control-primitives.tsx +++ b/apps/loopover-ui/src/components/site/control-primitives.tsx @@ -120,7 +120,7 @@ export function DiffBlock({ return (
diff --git a/apps/loopover-ui/src/components/site/surface-code-token.test.ts b/apps/loopover-ui/src/components/site/surface-code-token.test.ts new file mode 100644 index 0000000000..9dc568da02 --- /dev/null +++ b/apps/loopover-ui/src/components/site/surface-code-token.test.ts @@ -0,0 +1,39 @@ +import { readFileSync } from "node:fs"; +import { describe, expect, it } from "vitest"; + +// #6820: `bg-[oklch(0.13_0.005_260)]` (the always-dark code-surface color) was copy-pasted across +// 4 call sites in 3 unrelated files with no shared token. These lock in the `bg-surface-code` +// utility (backed by `--surface-code` in theme.css) as the one place that color is now defined. +const THEME_CSS_PATH = "../../packages/loopover-ui-kit/src/theme.css"; +const CALL_SITES = [ + "src/components/site/control-primitives.tsx", + "src/components/site/app-panels/maintainer-panel.tsx", + "src/components/site/api/try-it.tsx", +]; + +describe("surface-code design token (#6820)", () => { + it("defines --surface-code once and maps it through @theme inline", () => { + const css = readFileSync(THEME_CSS_PATH, "utf8"); + expect(css).toContain("--surface-code: oklch(0.13 0.005 260);"); + expect(css).toContain("--color-surface-code: var(--surface-code);"); + }); + + it("is not redefined inside the .dark block, so it renders identically in both themes", () => { + const css = readFileSync(THEME_CSS_PATH, "utf8"); + const darkBlockStart = css.indexOf(".dark {"); + const darkBlockEnd = css.indexOf("\n}", darkBlockStart); + const darkBlock = css.slice(darkBlockStart, darkBlockEnd); + expect(darkBlockStart).toBeGreaterThan(-1); + expect(darkBlock).not.toContain("--surface-code"); + }); + + it.each(CALL_SITES)( + "uses the shared bg-surface-code utility, not a raw literal, in %s", + (path) => { + const source = readFileSync(path, "utf8"); + expect(source).toContain("bg-surface-code"); + expect(source).not.toContain("oklch(0.13_0.005_260)"); + expect(source).not.toContain("oklch(0.13 0.005 260)"); + }, + ); +}); diff --git a/packages/loopover-ui-kit/src/theme.css b/packages/loopover-ui-kit/src/theme.css index 0ea706932d..889829f443 100644 --- a/packages/loopover-ui-kit/src/theme.css +++ b/packages/loopover-ui-kit/src/theme.css @@ -89,6 +89,7 @@ --color-sidebar-ring: var(--sidebar-ring); --color-surface: var(--surface); --color-surface-2: var(--surface-2); + --color-surface-code: var(--surface-code); --color-mint: var(--mint); --color-mint-soft: var(--mint-soft); --color-aurora: var(--aurora); @@ -111,6 +112,9 @@ --background: oklch(0.985 0.004 110); --surface: oklch(0.972 0.005 110); --surface-2: oklch(0.955 0.006 110); + /* Always-dark code surface (terminal/diff/try-it blocks) — intentionally not redefined in .dark, + so it renders identically in both themes instead of drifting with --surface. */ + --surface-code: oklch(0.13 0.005 260); --card: oklch(1 0 0); --card-foreground: oklch(0.18 0.01 110); --popover: oklch(1 0 0);