From 80d3c8fe5ce31bfc24329669d3a5785b99669944 Mon Sep 17 00:00:00 2001 From: kunaltaydetayde7552-ship-it Date: Sun, 29 Nov 2026 18:48:04 +0530 Subject: [PATCH] fix(viewer): add missing code-editor syntax colors for solarized and gruvbox themes Ensure the JSON debug tab and expression editor syntax tokens are clearly legible across Solarized, Solarized Dark, and Gruvbox Light themes by defining the missing code-editor CSS custom properties. Fixes #3298 Signed-off-by: kunaltaydetayde7552-ship-it --- .../perspective-viewer/src/themes/gruvbox.css | 6 ++ .../src/themes/solarized-dark.css | 6 ++ .../src/themes/solarized.css | 6 ++ .../js/settings_panel/debug_panel.spec.ts | 71 +++++++++++++++++++ 4 files changed, 89 insertions(+) diff --git a/rust/perspective-viewer/src/themes/gruvbox.css b/rust/perspective-viewer/src/themes/gruvbox.css index 10fd1545c6..c20d7ca7c5 100644 --- a/rust/perspective-viewer/src/themes/gruvbox.css +++ b/rust/perspective-viewer/src/themes/gruvbox.css @@ -58,6 +58,12 @@ perspective-viewer [theme="Gruvbox Light"] { --psp-status-icon--initializing--color: var(--theme-yellow); --psp-status-icon--psp-error--color: var(--theme-red); + --psp-code-editor--symbol--color: var(--theme-fg0); + --psp-code-editor--literal--color: var(--theme-alt-blue); + --psp-code-editor--operator--color: var(--theme-alt-green); + --psp-code-editor--comment--color: var(--theme-gray); + --psp-code-editor--column--color: var(--theme-alt-purple); + /* perspective-viewer-gruvbox-light--datagrid */ --psp-datagrid--pos-cell--color: var(--theme-blue); --psp-datagrid--neg-cell--color: var(--theme-red); diff --git a/rust/perspective-viewer/src/themes/solarized-dark.css b/rust/perspective-viewer/src/themes/solarized-dark.css index 6281129cdf..94197ad4b7 100644 --- a/rust/perspective-viewer/src/themes/solarized-dark.css +++ b/rust/perspective-viewer/src/themes/solarized-dark.css @@ -69,6 +69,12 @@ perspective-viewer [theme="Solarized Dark"] { --psp-inactive--border-color: var(--psp-inactive--color); --psp--background-color: #073642; + --psp-code-editor--symbol--color: #93a1a1; + --psp-code-editor--literal--color: #268bd2; + --psp-code-editor--operator--color: #859900; + --psp-code-editor--comment--color: #657b83; + --psp-code-editor--column--color: #2aa198; + /* perspective-viewer-solarized-dark--webgl */ --psp-charts--treemap--labels: white; --psp-charts--treemap--hover-highlight: white; diff --git a/rust/perspective-viewer/src/themes/solarized.css b/rust/perspective-viewer/src/themes/solarized.css index 5e6535d435..219bf7469a 100644 --- a/rust/perspective-viewer/src/themes/solarized.css +++ b/rust/perspective-viewer/src/themes/solarized.css @@ -37,6 +37,12 @@ perspective-viewer [theme="Solarized"] { --psp-column-type--date--color: #2aa198; --psp-column-type--boolean--color: #b58900; + --psp-code-editor--symbol--color: #586e75; + --psp-code-editor--literal--color: #268bd2; + --psp-code-editor--operator--color: #859900; + --psp-code-editor--comment--color: #93a1a1; + --psp-code-editor--column--color: #6c71c4; + /* perspective-viewer-solarized--datagrid */ --psp-datagrid--pos-cell--color: #268bd2 !important; --psp-datagrid--neg-cell--color: #cb4b16 !important; diff --git a/rust/perspective-viewer/test/js/settings_panel/debug_panel.spec.ts b/rust/perspective-viewer/test/js/settings_panel/debug_panel.spec.ts index dc5b824aa2..7ba4c610f2 100644 --- a/rust/perspective-viewer/test/js/settings_panel/debug_panel.spec.ts +++ b/rust/perspective-viewer/test/js/settings_panel/debug_panel.spec.ts @@ -126,4 +126,75 @@ test.describe("DebugPanel validation", () => { "State", ]); }); + + test("all themes define non-transparent code editor syntax colors in the debug panel", async ({ + page, + }) => { + await page.evaluate(async () => { + await new Promise((resolve, reject) => { + const link = document.createElement("link"); + link.rel = "stylesheet"; + link.href = + "/node_modules/@perspective-dev/viewer/dist/css/themes.css"; + link.onload = resolve; + link.onerror = reject; + document.head.appendChild(link); + }); + + const viewer = document.querySelector("perspective-viewer")! as any; + await viewer.resetThemes(); + }); + + const themes: string[] = await page.evaluate(async () => { + const viewer = document.querySelector("perspective-viewer")! as any; + return await viewer.getThemes(); + }); + + expect(themes).toContain("Solarized"); + expect(themes).toContain("Solarized Dark"); + expect(themes).toContain("Gruvbox Light"); + + for (const theme of ["Solarized", "Solarized Dark", "Gruvbox Light"]) { + const colors = await page.evaluate(async (themeName) => { + const viewer = document.querySelector( + "perspective-viewer", + )! as any; + await viewer.restore({ theme: themeName }); + const editor = viewer.shadowRoot!.querySelector( + "#debug-panel-editor #editor", + )!; + const style = window.getComputedStyle(editor); + return { + symbol: style + .getPropertyValue("--psp-code-editor--symbol--color") + .trim(), + literal: style + .getPropertyValue("--psp-code-editor--literal--color") + .trim(), + operator: style + .getPropertyValue("--psp-code-editor--operator--color") + .trim(), + comment: style + .getPropertyValue("--psp-code-editor--comment--color") + .trim(), + column: style + .getPropertyValue("--psp-code-editor--column--color") + .trim(), + }; + }, theme); + + for (const [key, value] of Object.entries(colors)) { + expect(value, `${theme} missing valid ${key} color`).not.toBe( + "", + ); + expect(value, `${theme} has transparent ${key} color`).not.toBe( + "transparent", + ); + expect( + value, + `${theme} has transparent rgba ${key} color`, + ).not.toBe("rgba(0, 0, 0, 0)"); + } + } + }); });