Skip to content

Commit 729839e

Browse files
authored
fix(desktop): center compact appearance choices (#3564)
1 parent d2afac3 commit 729839e

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

apps/desktop/e2e/settings.spec.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@
1919

2020
import { test, expect, COMPOSER_INPUT } from './fixtures';
2121

22+
async function choiceContentGeometry(card: import('@playwright/test').Locator) {
23+
return card.evaluate((element) => {
24+
const content = Array.from(element.children).find((child) => child.tagName !== 'INPUT');
25+
if (!(content instanceof HTMLElement)) {
26+
throw new Error('SelectableCard content is missing');
27+
}
28+
const cardRect = element.getBoundingClientRect();
29+
const contentRect = content.getBoundingClientRect();
30+
return {
31+
cardHeight: cardRect.height,
32+
contentHeight: contentRect.height,
33+
topGap: contentRect.top - cardRect.top,
34+
bottomGap: cardRect.bottom - contentRect.bottom,
35+
};
36+
});
37+
}
38+
2239
test('opening settings commits an active titlebar rename', async ({ window: page }) => {
2340
const composer = page.locator(COMPOSER_INPUT);
2441
await composer.fill('create a session for settings rename');
@@ -104,3 +121,23 @@ test('wide settings gutters scroll the whole main pane', async ({ window: page }
104121
await expect.poll(() => pane.evaluate((element) => element.scrollTop)).toBeGreaterThan(0);
105122
await expect(content).toBeVisible();
106123
});
124+
125+
test('appearance choice content stays vertically centered in stretched grid rows', async ({ window: page }) => {
126+
await page.evaluate(async () => {
127+
await window.maka.settings.update({ personalization: { uiLocale: 'en' } });
128+
});
129+
await page.reload();
130+
await page.waitForSelector(COMPOSER_INPUT);
131+
await page.setViewportSize({ width: 1650, height: 992 });
132+
await page.getByRole('button', { name: 'Settings' }).click();
133+
await page.getByRole('button', { name: 'Appearance', exact: true }).click();
134+
await expect(page.getByRole('heading', { name: 'App icon' })).toBeVisible();
135+
136+
for (const name of ['Azure', 'Classic']) {
137+
const card = page.getByRole('checkbox', { name, exact: true }).locator('..');
138+
await expect(card).toBeVisible();
139+
const geometry = await choiceContentGeometry(card);
140+
expect(geometry.cardHeight).toBeGreaterThan(geometry.contentHeight);
141+
expect(Math.abs(geometry.topGap - geometry.bottomGap)).toBeLessThanOrEqual(1);
142+
}
143+
});

apps/desktop/src/renderer/settings/appearance-settings-page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export function AppearanceSettingsPage(props: {
373373
onChange={() => void setPalette(palette)}
374374
padding={2}
375375
>
376-
<HStack gap={2} align="center">
376+
<HStack gap={2} align="center" height="100%">
377377
<span
378378
className={`settingsPaletteSwatch settingsPaletteSwatch-${palette}`}
379379
aria-hidden="true"
@@ -429,7 +429,7 @@ export function AppearanceSettingsPage(props: {
429429
onChange={() => void setAppIcon(option.id)}
430430
padding={2}
431431
>
432-
<HStack gap={2} align="center">
432+
<HStack gap={2} align="center" height="100%">
433433
{/* Decorative: the tile's own label already names the icon. */}
434434
<img className="settingsAppIconPreview" src={option.dataUrl} alt="" width={48} height={48} />
435435
<VStack gap={0.5}>

0 commit comments

Comments
 (0)