Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
29 changes: 8 additions & 21 deletions e2e/specs/mobile.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 ({
Expand Down
20 changes: 14 additions & 6 deletions e2e/specs/profile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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');
Expand Down
16 changes: 12 additions & 4 deletions e2e/specs/streak.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ async function loggedToday(sql: Sql): Promise<number> {

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(
Expand Down Expand Up @@ -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');
Expand Down
40 changes: 20 additions & 20 deletions src/lib/components/AppNav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLElement>();

let searchButton = $state<HTMLButtonElement>();
let palette = $state<ReturnType<typeof CommandPalette>>();
Expand All @@ -105,7 +104,7 @@
{/if}
{/snippet}

<!-- The account menu: one content for the top-bar avatar (desktop/tablet) and the tab bar's (phones). -->
<!-- The account menu of the top-bar avatar (desktop/tablet; phones link the avatar to Settings). -->
{#snippet accountMenu(close: () => void)}
<div class="menu-head">
{#if displayName}
Expand Down Expand Up @@ -153,7 +152,7 @@
the bottom — icons only (labels stay for screen readers), Focus left out (mini-player,
Next up, ▶, palette), the account avatar as the last slot, one pill sliding to the active slot.
-->
<nav aria-label={t.nav.main} bind:this={navEl} style:--tabs={TAB_ITEMS.length + 1}>
<nav aria-label={t.nav.main} style:--tabs={TAB_ITEMS.length + 1}>
{#if tab >= 0}
<span class="tab-pill" style:--i={tab} aria-hidden="true">
<span transition:fadeScale></span>
Expand All @@ -180,17 +179,21 @@
{/if}
</a>
{/each}
<!-- Phones: the avatar goes straight to Settings (no account menu). -->
<span class="tab-account">
<Menu label={accountLabel} anchor={navEl} gap={8}>
{#snippet trigger()}<Avatar
name={displayName}
color={profile?.avatarColor}
emoji={profile?.avatarEmoji}
size="sm"
ring={goal}
/>{/snippet}
{#snippet children(close)}{@render accountMenu(close)}{/snippet}
</Menu>
<a
href="/settings"
aria-label={accountLabel}
aria-current={tab === TAB_ITEMS.length ? 'page' : undefined}
>
<Avatar
name={displayName}
color={profile?.avatarColor}
emoji={profile?.avatarEmoji}
size="sm"
ring={goal}
/>
</a>
</span>
</nav>

Expand Down Expand Up @@ -623,16 +626,13 @@
white-space: nowrap;
}

/* The avatar slot: the whole slot is the menu button (hit area), the avatar centred. */
.tab-account :global(.menu),
.tab-account :global(.trigger-custom) {
/* The avatar slot: the whole slot is the link (hit area), the avatar centred. */
.tab-account a {
width: 100%;
height: 100%;
}
.tab-account :global(.trigger-custom) {
justify-content: center;
border-radius: var(--radius-pill);
-webkit-tap-highlight-color: transparent;
.tab-account a:active :global(.wrap) {
scale: var(--press-scale);
}
}
</style>
6 changes: 3 additions & 3 deletions src/lib/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export const NAV_ITEMS: NavItem[] = [

/**
* The phone tab bar's sections: all but Focus, which phones reach through the mini-player,
* Home's Next up card, ▶ on task cards and the command palette. The account avatar follows
* as the last slot.
* Home's Next up card, ▶ on task cards and the command palette. The account avatar (a link to
* Settings) follows as the last slot.
*/
export const TAB_ITEMS: NavItem[] = NAV_ITEMS.filter((item) => item.key !== 'focus');

/** Pages behind the account menu: the tab bar's indicator rests on the avatar there. */
/** Pages behind the account avatar (phones: a link to Settings): the indicator rests on it there. */
const ACCOUNT_PATHS = ['/settings'];

export function isActive(pathname: string, href: string): boolean {
Expand Down