fix(web): keep theme placeholder text dimmer than entered text (#9104)

This commit is contained in:
oliver authored and GitHub committed 2026-09-01 18:03:15 -04:00
1 parent 3b3465f2a9
commit d0b4acbd13
3 files changed
+26 -1

No files matched your search

+3
View File
@@ -157,6 +157,9 @@ describe("theme files", () => {
expect(contrastRatio(colors.textMuted, colors.canvas)).toBeLessThan(5.5);
expect(contrastRatio(colors.mutedForeground, colors.muted)).toBeGreaterThanOrEqual(4.5);
expect(contrastRatio(colors.placeholder, colors.surfaceRaised)).toBeGreaterThanOrEqual(4.5);
expect(contrastRatio(colors.placeholder, colors.surfaceRaised)).toBeLessThan(
contrastRatio(colors.text, colors.surfaceRaised),
);
expect(colors.secondaryLabel).toBe(colors.textMuted);
expect(contrastRatio(colors.accentForeground, colors.accent)).toBeGreaterThanOrEqual(4.5);
expect(
+1 -1
View File
@@ -917,7 +917,7 @@ export function createVividThemeColors(
solveOklchLightness(textBase, surfaceRgb, 4.6, dark ? "lighter" : "darker"),
);
const mutedForeground = foregroundOn(mutedRgb);
const placeholder = foregroundOn(surfaceRaisedRgb);
const placeholder = themeRgbToThemeColor(readableThemeText(surfaceRaisedRgb, textRgb, 1, 4.6));
const actionHover: ThemeOklch = { ...action, L: action.L + (dark ? 0.06 : -0.06) };
+22
View File
@@ -90,6 +90,28 @@ describe("VS Code theme import", () => {
expect(theme.colors.sidebarRowSelected).not.toBe(theme.colors.sidebar);
});
it("keeps a fallback placeholder dimmer than entered text", () => {
const theme = parseVsCodeThemeFile({
name: "Dark placeholder fallback",
type: "dark",
colors: {
"editor.background": "#1e1e2e",
"editor.foreground": "#cdd6f4",
"input.placeholderForeground": "#cdd6f473",
},
});
expect(
contrastRatio(theme.colors.placeholder, theme.colors.surfaceRaised),
).toBeGreaterThanOrEqual(4.5);
expect(contrastRatio(theme.colors.placeholder, theme.colors.canvas)).toBeGreaterThanOrEqual(
4.5,
);
expect(contrastRatio(theme.colors.placeholder, theme.colors.canvas)).toBeLessThan(
contrastRatio(theme.colors.text, theme.colors.canvas),
);
});
it("fills every role the file omits with a readable derived value", () => {
const theme = parseVsCodeThemeFile(VSCODE_DARK);
const colors = getThemeColorsForMode(theme, "dark")!;