diff --git a/e2e/appearanceSettingsLayout.spec.ts b/e2e/appearanceSettingsLayout.spec.ts new file mode 100644 index 000000000..f3f8dda36 --- /dev/null +++ b/e2e/appearanceSettingsLayout.spec.ts @@ -0,0 +1,74 @@ +import { expect, test } from "./fixtures"; + +test("Appearance keeps themes and UI font controls grouped across Settings widths", async ({ workbench: page }) => { + await page.setViewportSize({ width: 1120, height: 800 }); + await page.keyboard.press("Meta+,"); + const dialog = page.getByRole("dialog", { name: "Settings", exact: true }); + const search = dialog.getByRole("textbox", { name: "Search settings" }); + await search.fill("Use custom font"); + await dialog.getByRole("treeitem", { name: "Appearance", exact: true }).click(); + await search.clear(); + + const theme = dialog.getByRole("button", { name: "Theme", exact: true }); + const sync = dialog.getByRole("checkbox", { name: "Sync with OS", exact: true }); + const preferences = dialog.getByRole("button", { name: "Preferred themes", exact: true }); + const more = dialog.getByRole("button", { name: "Get more themes", exact: true }); + const font = dialog.getByRole("combobox", { name: "UI font", exact: true }); + const fallback = dialog.getByRole("combobox", { name: "UI fallback font", exact: true }); + const size = dialog.getByRole("textbox", { name: "UI font size", exact: true }); + const custom = dialog.getByRole("checkbox", { name: "Use custom font:", exact: true }); + await expect(preferences).toBeDisabled(); + await expect(font).toBeDisabled(); + await expect(size).toBeDisabled(); + await expect(fallback).toBeDisabled(); + + const [themeBox, gearBox, linkBox, fontBox, sizeBox, fallbackBox] = await Promise.all( + [theme, preferences, more, font, size, fallback].map((control) => control.boundingBox()), + ); + if (!themeBox || !gearBox || !linkBox || !fontBox || !sizeBox || !fallbackBox) { + throw new Error("Missing Appearance control bounds"); + } + expect(linkBox.y).toBeGreaterThan(themeBox.y + themeBox.height); + expect(gearBox.x).toBeGreaterThan(themeBox.x + themeBox.width); + expect(gearBox.y + gearBox.height / 2).toBeCloseTo(themeBox.y + themeBox.height / 2, 0); + expect(sizeBox.y).toBeCloseTo(fontBox.y, 0); + expect(sizeBox.x).toBeGreaterThan(fontBox.x + fontBox.width); + expect(fallbackBox.x).toBeCloseTo(fontBox.x, 0); + expect(fallbackBox.y).toBeGreaterThan(fontBox.y); + + await sync.check(); + await expect(theme).toBeDisabled(); + for (const width of [580, 520]) { + await page.setViewportSize({ width, height: 800 }); + await preferences.click(); + const popup = page.getByRole("dialog", { name: "Preferred themes", exact: true }); + const light = popup.getByRole("button", { name: "Preferred light theme", exact: true }); + const dark = popup.getByRole("button", { name: "Preferred dark theme", exact: true }); + await expect(light).toBeInViewport({ ratio: 1 }); + await expect(dark).toBeInViewport({ ratio: 1 }); + const [lightBox, darkBox] = await Promise.all([light.boundingBox(), dark.boundingBox()]); + if (!lightBox || !darkBox) throw new Error("Missing preferred theme bounds"); + expect(lightBox.x).toBeCloseTo(darkBox.x, 0); + expect(lightBox.width).toBeCloseTo(darkBox.width, 0); + await page.keyboard.press("Escape"); + await expect(popup).toBeHidden(); + for (const field of [font, size, fallback]) await expect(field).toBeInViewport({ ratio: 1 }); + const [narrowFont, narrowSize, narrowFallback] = await Promise.all( + [font, size, fallback].map((control) => control.boundingBox()), + ); + if (!narrowFont || !narrowSize || !narrowFallback) throw new Error("Missing narrow font control bounds"); + expect(narrowSize.y).toBeGreaterThan(narrowFont.y); + expect(narrowFallback.x).toBeCloseTo(narrowFont.x, 0); + } + + await custom.check(); + await font.fill("Inter"); + await size.fill("15"); + await fallback.fill("Noto Sans CJK SC"); + await fallback.press("Enter"); + await expect(font).toHaveValue("Inter"); + await expect(size).toHaveValue("15"); + await expect(fallback).toHaveValue("Noto Sans CJK SC"); + await dialog.getByRole("button", { name: "Cancel", exact: true }).click(); + await expect(dialog).toBeHidden(); +}); diff --git a/src/features/settings/pages/Behavior.module.css b/src/features/settings/pages/Behavior.module.css index 0ed9eb3e7..ade202930 100644 --- a/src/features/settings/pages/Behavior.module.css +++ b/src/features/settings/pages/Behavior.module.css @@ -1,13 +1,11 @@ -.inline { +.themeSync { display: inline-flex; align-items: center; gap: var(--space-2); - margin-left: 8px; - padding: 0 4px; border-radius: var(--radius-row); } .themeSelect { - flex: 1 1 120px; + flex: 1 1 140px; min-width: min(120px, 100%); max-width: 180px; } @@ -30,10 +28,16 @@ color: var(--fg-subtle); overflow-wrap: anywhere; } -.popupBody { - display: flex; - flex-direction: column; - padding: 8px 14px; +.preferredThemes { + width: min(440px, calc(100vw - var(--space-4))); + padding: var(--space-2) var(--space-3); +} +.preferredThemes label { + white-space: normal; + overflow-wrap: anywhere; +} +.preferredThemes button { + width: 100%; } /* Inline option groups, with custom font controls wrapping together. */ @@ -47,33 +51,35 @@ margin: 0 -6px; border-radius: var(--radius-row); } -/* Custom font block (IDEA Appearance): labels share one column, so the UI font, - fallback and Size controls all start at the same x. */ .customFontRow { display: grid; - grid-template-columns: max-content minmax(0, 1fr); + grid-template-columns: fit-content(42%) minmax(0, 280px) max-content; align-items: start; column-gap: var(--space-2); row-gap: var(--space-1); - min-height: 28px; + min-height: var(--h-field); padding: 2px 6px; margin: 0 -6px; border-radius: var(--radius-row); } -.customFontRow > .fontLabel { - padding-top: 3px; - white-space: nowrap; -} -.customFontRow > .fontCheck { - white-space: nowrap; -} -.fontControl { +.fontLabel, +.fontCheck, +.fontSize { display: flex; align-items: center; + min-height: var(--h-field); min-width: 0; } -.sizeInput { - width: 64px; +.fontSize { + gap: var(--space-2); +} +@container settings-content (max-width: 580px) { + .customFontRow { + grid-template-columns: fit-content(42%) minmax(0, 280px); + } + .fontSize { + grid-column: 2; + } } .disabled { color: var(--fg-subtle); diff --git a/src/features/settings/pages/behavior.tsx b/src/features/settings/pages/behavior.tsx index a333a7640..5607586c9 100644 --- a/src/features/settings/pages/behavior.tsx +++ b/src/features/settings/pages/behavior.tsx @@ -98,7 +98,14 @@ function ThemeRow() { showPicked(shown); }; return ( - + selectPage("plugins#themes")}> + Get more themes + + } + > value={shown} options={themeSelectOptions(choices, shown)} @@ -108,11 +115,7 @@ function ThemeRow() { className={styles.themeSelect} disabled={sync} /> - {/* As in IntelliJ IDEA: most themes are plugins, so point at the marketplace's. */} - - + { @@ -141,7 +144,7 @@ function ThemeRow() { offset={4} aria-label="Preferred themes" > -
+ value={light} @@ -158,7 +161,7 @@ function ThemeRow() { aria-label="Preferred dark theme" /> -
+
); @@ -260,53 +263,37 @@ function CustomFontRow() { const [size, setSize] = useSetting("appearance.uiFontSize"); const id = useId(); const matched = useLabelMatch("Use custom font"); - // Labels share one column (IDEA Appearance): the UI font, fallback and Size - // controls all start at the same x instead of drifting with flex wrapping. return (
} /> - - - + +
+ + +
- - - - - - {on ? ( - - ) : ( - - )} - +
); } @@ -919,6 +906,12 @@ export const BEHAVIOR_PAGES: PageSpec[] = [ }, { kind: "custom", label: "Accent color", keywords: ["accent colour", "highlight"], component: AccentRow }, { kind: "custom", label: "Different tool window background", component: ToolWindowBackgroundRow }, + { + kind: "custom", + label: "Use custom font", + keywords: ["UI font size", "Size", "font family", "fallback font"], + component: CustomFontRow, + }, ], }, { @@ -936,12 +929,6 @@ export const BEHAVIOR_PAGES: PageSpec[] = [ title: "Accessibility", options: [ { kind: "custom", label: "Zoom", keywords: ["scale", "zoom ide"], component: ZoomRow }, - { - kind: "custom", - label: "Use custom font", - keywords: ["UI font size", "Size", "font family", "fallback font"], - component: CustomFontRow, - }, { kind: "toggle", key: "appearance.contrastScrollbars", label: "Use contrast scrollbars" }, { kind: "toggle",