Skip to content

Commit 5808469

Browse files
fix(web): chip palette test follows the single design (#26131)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 570d4b0 commit 5808469

2 files changed

Lines changed: 21 additions & 34 deletions

File tree

‎apps/web/src/themePalette.browser.test.ts‎

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,26 @@ describe("standard painted theme colors", () => {
2525
it("match the chip surfaces index.css paints", () => {
2626
const root = document.documentElement;
2727
try {
28-
for (const redesign of [false, true, false]) {
29-
root.toggleAttribute("data-redesign", redesign);
30-
for (const appearance of ["light", "dark"] as const) {
31-
root.classList.toggle("dark", appearance === "dark");
32-
const colors = getStandardPaintedThemeColors(appearance, redesign);
33-
const canvas = paintedChannels("--background");
34-
for (const [variable, role] of [
35-
["--background", "canvas"],
36-
["--card", "surface"],
37-
["--surface-raised", "surfaceRaised"],
38-
["--message-surface", "messageSurface"],
39-
] as const) {
40-
const expected = toRgb(colors[role])!;
41-
const painted = paintedChannels(variable, canvas);
42-
[expected.r, expected.g, expected.b].forEach((channel, index) => {
43-
expect(
44-
Math.abs(channel * 255 - painted[index]!),
45-
`${appearance} ${role}`,
46-
).toBeLessThan(1.5);
47-
});
48-
}
28+
for (const appearance of ["light", "dark"] as const) {
29+
root.classList.toggle("dark", appearance === "dark");
30+
const colors = getStandardPaintedThemeColors(appearance);
31+
const canvas = paintedChannels("--background");
32+
for (const [variable, role] of [
33+
["--background", "canvas"],
34+
["--card", "surface"],
35+
["--surface-raised", "surfaceRaised"],
36+
["--message-surface", "messageSurface"],
37+
] as const) {
38+
const expected = toRgb(colors[role])!;
39+
const painted = paintedChannels(variable, canvas);
40+
[expected.r, expected.g, expected.b].forEach((channel, index) => {
41+
expect(Math.abs(channel * 255 - painted[index]!), `${appearance} ${role}`).toBeLessThan(
42+
1.5,
43+
);
44+
});
4945
}
5046
}
5147
} finally {
52-
root.removeAttribute("data-redesign");
5348
root.classList.remove("dark");
5449
}
5550
});

‎apps/web/src/themePalette.ts‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -403,19 +403,12 @@ export function getStandardThemeColors(appearance: ThemeAppearance): ThemeColors
403403
// index.css paints the light bubble a step darker than the shared palette mobile uses.
404404
const STANDARD_WEB_PAINTED_COLORS: Record<ThemeAppearance, Partial<ThemeColors>> = {
405405
light: { messageSurface: "#ebebed" },
406-
dark: {},
406+
dark: { canvas: "#000000", messageSurface: "#1e1e1e" },
407407
};
408408

409409
/** The standard theme as index.css paints it, for solves that measure the page. */
410-
export function getStandardPaintedThemeColors(
411-
appearance: ThemeAppearance,
412-
redesign = false,
413-
): ThemeColors {
414-
return {
415-
...getStandardThemeColors(appearance),
416-
...STANDARD_WEB_PAINTED_COLORS[appearance],
417-
...(redesign && appearance === "dark" ? { canvas: "#000000", messageSurface: "#1e1e1e" } : {}),
418-
};
410+
export function getStandardPaintedThemeColors(appearance: ThemeAppearance): ThemeColors {
411+
return { ...getStandardThemeColors(appearance), ...STANDARD_WEB_PAINTED_COLORS[appearance] };
419412
}
420413

421414
type ThemeRgbColor = {
@@ -1636,8 +1629,7 @@ export function applyThemePalette(theme: ThemePreference, appearance?: ThemeAppe
16361629
for (const variable of Object.values(APP_THEME_VARIABLES)) {
16371630
root.style.removeProperty(variable);
16381631
}
1639-
// The redesign's lighter dark bubble is the stricter surface, so this ink also covers legacy UI.
1640-
applyContextChipVariables(root, getStandardPaintedThemeColors(appearance ?? "light", true));
1632+
applyContextChipVariables(root, getStandardPaintedThemeColors(appearance ?? "light"));
16411633
}
16421634

16431635
export function resolveThemeAppearance(

0 commit comments

Comments
 (0)