From 787b4d8185a22ce09088e9ff8179ff0b723e6ecb Mon Sep 17 00:00:00 2001 From: G-R3 Date: Tue, 27 Oct 2026 16:33:16 -0400 Subject: [PATCH] fix(web): theme palette test matches the single design --- apps/web/src/themePalette.browser.test.ts | 39 ++++++++++------------- apps/web/src/themePalette.ts | 13 +++----- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/apps/web/src/themePalette.browser.test.ts b/apps/web/src/themePalette.browser.test.ts index 51136eb7af5cc..4204b069780c9 100644 --- a/apps/web/src/themePalette.browser.test.ts +++ b/apps/web/src/themePalette.browser.test.ts @@ -25,31 +25,26 @@ describe("standard painted theme colors", () => { it("match the chip surfaces index.css paints", () => { const root = document.documentElement; try { - for (const redesign of [false, true, false]) { - root.toggleAttribute("data-redesign", redesign); - for (const appearance of ["light", "dark"] as const) { - root.classList.toggle("dark", appearance === "dark"); - const colors = getStandardPaintedThemeColors(appearance, redesign); - const canvas = paintedChannels("--background"); - for (const [variable, role] of [ - ["--background", "canvas"], - ["--card", "surface"], - ["--surface-raised", "surfaceRaised"], - ["--message-surface", "messageSurface"], - ] as const) { - const expected = toRgb(colors[role])!; - const painted = paintedChannels(variable, canvas); - [expected.r, expected.g, expected.b].forEach((channel, index) => { - expect( - Math.abs(channel * 255 - painted[index]!), - `${appearance} ${role}`, - ).toBeLessThan(1.5); - }); - } + for (const appearance of ["light", "dark"] as const) { + root.classList.toggle("dark", appearance === "dark"); + const colors = getStandardPaintedThemeColors(appearance); + const canvas = paintedChannels("--background"); + for (const [variable, role] of [ + ["--background", "canvas"], + ["--card", "surface"], + ["--surface-raised", "surfaceRaised"], + ["--message-surface", "messageSurface"], + ] as const) { + const expected = toRgb(colors[role])!; + const painted = paintedChannels(variable, canvas); + [expected.r, expected.g, expected.b].forEach((channel, index) => { + expect(Math.abs(channel * 255 - painted[index]!), `${appearance} ${role}`).toBeLessThan( + 1.5, + ); + }); } } } finally { - root.removeAttribute("data-redesign"); root.classList.remove("dark"); } }); diff --git a/apps/web/src/themePalette.ts b/apps/web/src/themePalette.ts index 4aaa6062b7481..0d66e1773b6a0 100644 --- a/apps/web/src/themePalette.ts +++ b/apps/web/src/themePalette.ts @@ -400,21 +400,17 @@ export function getStandardThemeColors(appearance: ThemeAppearance): ThemeColors return (standardLightThemeColors ??= decodeThemeColors(T3_CODE_LIGHT_THEME_COLORS)); } -// index.css paints the light bubble a step darker than the shared palette mobile uses. +// index.css paints these surfaces differently from the shared palette mobile uses. const STANDARD_WEB_PAINTED_COLORS: Record> = { light: { messageSurface: "#ebebed" }, - dark: {}, + dark: { canvas: "#000000", messageSurface: "#1e1e1e" }, }; /** The standard theme as index.css paints it, for solves that measure the page. */ -export function getStandardPaintedThemeColors( - appearance: ThemeAppearance, - redesign = false, -): ThemeColors { +export function getStandardPaintedThemeColors(appearance: ThemeAppearance): ThemeColors { return { ...getStandardThemeColors(appearance), ...STANDARD_WEB_PAINTED_COLORS[appearance], - ...(redesign && appearance === "dark" ? { canvas: "#000000", messageSurface: "#1e1e1e" } : {}), }; } @@ -1636,8 +1632,7 @@ export function applyThemePalette(theme: ThemePreference, appearance?: ThemeAppe for (const variable of Object.values(APP_THEME_VARIABLES)) { root.style.removeProperty(variable); } - // The redesign's lighter dark bubble is the stricter surface, so this ink also covers legacy UI. - applyContextChipVariables(root, getStandardPaintedThemeColors(appearance ?? "light", true)); + applyContextChipVariables(root, getStandardPaintedThemeColors(appearance ?? "light")); } export function resolveThemeAppearance(