diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 840c394..def0fdd 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -1094,17 +1094,18 @@ safe-bottom − 8px)`, so it sits just above the home indicator), at most `--tab `--glass-border`, `--shadow-float`; content scrolls visibly underneath. - **Slots**: Home, Plan, Calendar, Quests, Review (icons only, `--tab-icon`; the labels stay in the DOM as visually hidden text, so every link keeps its translated accessible name and - `aria-current="page"`), then the **avatar** (`Avatar sm` with the daily-goal ring) as a `Menu` - trigger filling its slot. The account menu content is one snippet shared by both avatars; on - phones it is placed against the capsule (`Menu` props `anchor` / `gap`): right-aligned with - it, opening upwards, clamped to the viewport. The top bar on phones keeps brand + search + `aria-current="page"`), then the **avatar** (`Avatar sm` with the daily-goal ring) as a link + to `/settings` filling its slot (accessible name = the account label, `aria-current` there). + Phones have **no account menu** (owner's decision, 2026-11-22: one tap to Settings beats a + menu whose three items all lead there; pairing is Settings → Devices, the streak is on Home). + Desktop/iPad keep the top-bar avatar's menu. The top bar on phones keeps brand + search (`--nav-h-compact` 56px). - **Active indicator**: one pill (`--tab-pill`, a soft light tint) that slides between slots (`translateX(index × slot width)`, `--dur-sheet` + `--ease-spring`); the active icon turns `--text` with a heavier stroke, the others stay muted. `activeTab()` (`#lib/nav.ts`): the - index in `TAB_ITEMS`, the avatar slot on `/settings` (reached through the avatar menu), else + index in `TAB_ITEMS`, the avatar slot on `/settings` (where the avatar leads), else -1 → the pill fades out (`fadeScale`) and fades back in where it belongs. Press feedback - shrinks the icon (`--press-scale`); the avatar button takes the global touch press. Under + shrinks the icon (`--press-scale`), the avatar likewise. Under reduced motion the pill jumps (global rule + `motionMs` → 0). - **Mini-player**: floats a `--space-2` gap above the capsule with the same insets, max width and glass; capsule-shaped (`--player-h` 56px), the quest colour as a short bar at the start, @@ -1120,12 +1121,11 @@ safe-bottom − 8px)`, so it sits just above the home indicator), at most `--tab `/settings` rests the pill on the avatar instead of hiding it — it is where the avatar leads. - Tests: unit — `nav.test.ts` (`TAB_ITEMS` without Focus, `activeTab` indices, the avatar slot, no slot). e2e `mobile.spec.ts` (`@mobile-only`, iPhone): the five tabs navigate by - accessible name with `aria-current` on exactly one; the tab-bar avatar opens the account - menu above the bar and on screen, Settings navigates. `i18n.spec.ts` (phones): the German + accessible name with `aria-current` on exactly one; the tab-bar avatar opens Settings + directly (no menu) and carries `aria-current` there. `i18n.spec.ts` (phones): the German accessible names navigate (replaces the old "labels aren't ellipsised" check — there are no - visible labels now). Profile/streak `@mobile` tests use the same locators (the hidden avatar - isn't in the accessibility tree). Checked against reintroduced bugs: a menu that never - flips upwards (avatar test fails), labels `display: none` (no accessible names: tab-bar and + visible labels now). Profile/streak `@mobile` tests find the avatar as button or link (the + hidden one isn't in the accessibility tree) and open the account menu only above 720px. Checked against reintroduced bugs: labels `display: none` (no accessible names: tab-bar and German tests fail). - **Not tested**: a real iPhone — `backdrop-filter` in iOS Safari/standalone (headless Chromium only renders the blur with GPU flags; the shots use them), the lift above the diff --git a/e2e/specs/mobile.spec.ts b/e2e/specs/mobile.spec.ts index e6ae842..e3620bf 100644 --- a/e2e/specs/mobile.spec.ts +++ b/e2e/specs/mobile.spec.ts @@ -1,5 +1,5 @@ /** - * Touch-only flows (projects mobile-iphone / mobile-ipad): the phone tab bar and its account menu, Plan's "Move to + * Touch-only flows (projects mobile-iphone / mobile-ipad): the phone tab bar and its avatar, Plan's "Move to * day" picker instead of drag & drop, Review's tap-to-pin tooltips, touch sizing. */ import { test, expect, gotoLive, actionDone } from '../support/fixtures.ts'; @@ -31,34 +31,21 @@ test('phone: the floating tab bar navigates between sections @mobile-only', asyn } }); -test('phone: the tab bar avatar opens the account menu above the bar; Settings navigates @mobile-only', async ({ +test('phone: the tab bar avatar opens Settings directly, without a menu @mobile-only', async ({ page, viewport }) => { test.skip(viewport!.width > 720, 'the tab bar is the phone layout'); await gotoLive(page, '/plan'); const nav = page.getByRole('navigation', { name: 'Main' }); - await nav.getByRole('button', { name: /^Account and devices/ }).tap(); - const menu = page.getByRole('menu'); - await expect(menu).toBeVisible(); - // Opens upwards from the bottom bar and stays on screen. - const bar = (await nav.boundingBox())!; - await expect - .poll(async () => { - const box = (await menu.boundingBox())!; - return ( - box.y >= 0 && - box.x >= 0 && - box.x + box.width <= viewport!.width && - box.y + box.height <= bar.y - ); - }) - .toBe(true); - await menu.getByRole('menuitem', { name: 'Settings' }).tap(); + await expect(nav.getByRole('button')).toHaveCount(0); + const avatar = nav.getByRole('link', { name: /^Account and devices/ }); + await avatar.tap(); await expect(page).toHaveURL(/\/settings$/); await expect(page.getByRole('heading', { level: 1 })).toHaveText('Settings'); - await expect(menu).toBeHidden(); - await expect(nav.locator('a[aria-current=page]')).toHaveCount(0); + await expect(page.getByRole('menu')).toHaveCount(0); + await expect(avatar).toHaveAttribute('aria-current', 'page'); + await expect(nav.locator('a[aria-current=page]')).toHaveCount(1); }); test('Plan: ⋯ "Move to day" moves a card without drag & drop @mobile-only', async ({ diff --git a/e2e/specs/profile.spec.ts b/e2e/specs/profile.spec.ts index 95675d5..c32251d 100644 --- a/e2e/specs/profile.spec.ts +++ b/e2e/specs/profile.spec.ts @@ -68,7 +68,13 @@ function hm(min: number): string { const progressName = (logged: number, goal: string) => new RegExp(`^Account and devices, (${hm(logged)}|${hm(logged + 1)}) of ${goal} today$`); -const avatar = (page: Page) => page.getByRole('button', { name: /^Account and devices/ }); +/** The nav avatar: the account menu's button (desktop/iPad) or the tab bar's link to Settings (iPhone). */ +const avatar = (page: Page) => + page + .getByRole('button', { name: /^Account and devices/ }) + .or(page.getByRole('link', { name: /^Account and devices/ })); +/** iPhone: the tab bar avatar links to Settings — there is no account menu. */ +const phone = (page: Page) => page.viewportSize()!.width <= 720; const GREETING = /^(Good morning|Good afternoon|Good evening|Still up)/; const greeting = (page: Page) => page.getByText(GREETING); @@ -125,11 +131,13 @@ test('Settings → Profile: name and colour persist; nav avatar, menu and Home g await expect(page.getByLabel('Name', { exact: true })).toHaveValue('Anton Schmidt'); await expect(page.getByRole('radio', { name: 'Teal' })).toBeChecked(); await expect(avatar(page)).toHaveAccessibleName('Account and devices (Anton Schmidt)'); - await avatar(page).click(); - const menu = page.getByRole('menu'); - await expect(menu).toContainText('Anton Schmidt'); - await expect(menu).toContainText('This device: e2e browser'); - await page.keyboard.press('Escape'); + if (!phone(page)) { + await avatar(page).click(); + const menu = page.getByRole('menu'); + await expect(menu).toContainText('Anton Schmidt'); + await expect(menu).toContainText('This device: e2e browser'); + await page.keyboard.press('Escape'); + } await gotoLive(page, '/'); await expect(avatar(page)).toHaveText('AS'); diff --git a/e2e/specs/streak.spec.ts b/e2e/specs/streak.spec.ts index eade762..b9d0415 100644 --- a/e2e/specs/streak.spec.ts +++ b/e2e/specs/streak.spec.ts @@ -69,7 +69,13 @@ async function loggedToday(sql: Sql): Promise { const streakBox = (page: Page) => page.getByTestId('streak'); const chip = (page: Page) => page.getByTestId('streak-chip'); -const avatar = (page: Page) => page.getByRole('button', { name: /^Account and devices/ }); +/** The nav avatar: the account menu's button (desktop/iPad) or the tab bar's link to Settings (iPhone). */ +const avatar = (page: Page) => + page + .getByRole('button', { name: /^Account and devices/ }) + .or(page.getByRole('link', { name: /^Account and devices/ })); +/** iPhone: the tab bar avatar links to Settings — there is no account menu. */ +const phone = (page: Page) => page.viewportSize()!.width <= 720; /** "Wednesday" for an ISO day (the weekday toggles' accessible names). */ const weekdayName = (day: string) => new Intl.DateTimeFormat('en-US', { weekday: 'long', timeZone: 'UTC' }).format( @@ -104,9 +110,11 @@ test('Home shows the current streak (pending today), menu and Review the longest await expect(chip(page)).toBeInViewport(); await expectNoHorizontalScroll(page); - await avatar(page).click(); - await expect(page.getByTestId('menu-streak')).toHaveText('3-day streak · Longest: 5 days'); - await page.keyboard.press('Escape'); + if (!phone(page)) { + await avatar(page).click(); + await expect(page.getByTestId('menu-streak')).toHaveText('3-day streak · Longest: 5 days'); + await page.keyboard.press('Escape'); + } await gotoLive(page, '/review'); await expect(page.getByTestId('longest-streak')).toHaveText('Longest streak: 5 days'); diff --git a/src/lib/components/AppNav.svelte b/src/lib/components/AppNav.svelte index 8f9d4c8..ba419a9 100644 --- a/src/lib/components/AppNav.svelte +++ b/src/lib/components/AppNav.svelte @@ -87,7 +87,6 @@ /** Phones: slot of the tab bar's sliding indicator (-1 = none; after the tabs = avatar). */ const tab = $derived(activeTab(page.url.pathname)); - let navEl = $state(); let searchButton = $state(); let palette = $state>(); @@ -105,7 +104,7 @@ {/if} {/snippet} - + {#snippet accountMenu(close: () => void)}