feat(#90): add hamburger menu and mobile nav drawer below 640px
Some checks failed
CI / Unit & Component Tests (pull_request) Successful in 2m26s
CI / Backend Unit Tests (pull_request) Successful in 2m11s
CI / E2E Tests (pull_request) Failing after 25m59s
CI / Unit & Component Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Unit & Component Tests (pull_request) Successful in 2m26s
CI / Backend Unit Tests (pull_request) Successful in 2m11s
CI / E2E Tests (pull_request) Failing after 25m59s
CI / Unit & Component Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Nav links were completely hidden on mobile (sm:flex / hidden split). Adds a 44×44px hamburger toggle, a fixed overlay panel with full-width nav links (min-h-[44px] touch targets), backdrop-click and Escape to close, and a $effect that auto-closes on route change. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #104.
This commit is contained in:
@@ -1,11 +1,33 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
|
import { untrack } from 'svelte';
|
||||||
import { m } from '$lib/paraglide/messages.js';
|
import { m } from '$lib/paraglide/messages.js';
|
||||||
|
|
||||||
let { isAdmin = false }: { isAdmin?: boolean } = $props();
|
let { isAdmin = false }: { isAdmin?: boolean } = $props();
|
||||||
|
|
||||||
|
let mobileNavOpen = $state(false);
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
// Read pathname to establish the reactive dependency.
|
||||||
|
// Write via untrack so the effect doesn't re-run on its own write.
|
||||||
|
void page.url.pathname;
|
||||||
|
untrack(() => {
|
||||||
|
mobileNavOpen = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function closeMobileNav() {
|
||||||
|
mobileNavOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleOverlayKeydown(event: KeyboardEvent) {
|
||||||
|
if (event.key === 'Escape') {
|
||||||
|
mobileNavOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex">
|
<div class="flex items-center">
|
||||||
<div class="mr-10 flex flex-shrink-0 items-center">
|
<div class="mr-10 flex flex-shrink-0 items-center">
|
||||||
<a href="/" class="flex items-center" aria-label="Familienarchiv">
|
<a href="/" class="flex items-center" aria-label="Familienarchiv">
|
||||||
<span class="font-sans text-xl font-bold tracking-widest text-ink uppercase"
|
<span class="font-sans text-xl font-bold tracking-widest text-ink uppercase"
|
||||||
@@ -14,6 +36,7 @@ let { isAdmin = false }: { isAdmin?: boolean } = $props();
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Desktop nav -->
|
||||||
<nav class="hidden items-center sm:flex sm:space-x-1">
|
<nav class="hidden items-center sm:flex sm:space-x-1">
|
||||||
<a
|
<a
|
||||||
href="/"
|
href="/"
|
||||||
@@ -56,4 +79,108 @@ let { isAdmin = false }: { isAdmin?: boolean } = $props();
|
|||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<!-- Hamburger toggle (mobile only) -->
|
||||||
|
<button
|
||||||
|
class="ml-auto flex h-11 w-11 items-center justify-center rounded text-ink-2 transition-colors hover:bg-muted hover:text-ink sm:hidden"
|
||||||
|
aria-label={mobileNavOpen ? 'Menü schließen' : 'Menü öffnen'}
|
||||||
|
aria-expanded={mobileNavOpen}
|
||||||
|
aria-controls="mobile-nav"
|
||||||
|
onclick={() => (mobileNavOpen = !mobileNavOpen)}
|
||||||
|
>
|
||||||
|
{#if mobileNavOpen}
|
||||||
|
<!-- X icon -->
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="22"
|
||||||
|
height="22"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<line x1="18" y1="6" x2="6" y2="18" />
|
||||||
|
<line x1="6" y1="6" x2="18" y2="18" />
|
||||||
|
</svg>
|
||||||
|
{:else}
|
||||||
|
<!-- Hamburger icon -->
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="22"
|
||||||
|
height="22"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<line x1="3" y1="6" x2="21" y2="6" />
|
||||||
|
<line x1="3" y1="12" x2="21" y2="12" />
|
||||||
|
<line x1="3" y1="18" x2="21" y2="18" />
|
||||||
|
</svg>
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Mobile nav overlay -->
|
||||||
|
{#if mobileNavOpen}
|
||||||
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
|
<div class="fixed inset-0 top-[68px] z-40 sm:hidden" onkeydown={handleOverlayKeydown}>
|
||||||
|
<!-- Backdrop -->
|
||||||
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||||
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
|
<div class="absolute inset-0 bg-black/20" onclick={closeMobileNav}></div>
|
||||||
|
|
||||||
|
<!-- Panel -->
|
||||||
|
<div class="relative border-b border-line bg-surface shadow-md">
|
||||||
|
<nav id="mobile-nav">
|
||||||
|
<a
|
||||||
|
href="/"
|
||||||
|
class="block flex min-h-[44px] w-full items-center px-4 py-3 font-sans text-sm font-bold tracking-widest uppercase transition-colors
|
||||||
|
{page.url.pathname === '/' || page.url.pathname.startsWith('/documents')
|
||||||
|
? 'bg-nav-active text-ink'
|
||||||
|
: 'text-ink-2 hover:bg-muted hover:text-ink'}"
|
||||||
|
>
|
||||||
|
{m.nav_documents()}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
href="/persons"
|
||||||
|
class="block flex min-h-[44px] w-full items-center px-4 py-3 font-sans text-sm font-bold tracking-widest uppercase transition-colors
|
||||||
|
{page.url.pathname.startsWith('/persons')
|
||||||
|
? 'bg-nav-active text-ink'
|
||||||
|
: 'text-ink-2 hover:bg-muted hover:text-ink'}"
|
||||||
|
>
|
||||||
|
{m.nav_persons()}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
href="/conversations"
|
||||||
|
class="block flex min-h-[44px] w-full items-center px-4 py-3 font-sans text-sm font-bold tracking-widest uppercase transition-colors
|
||||||
|
{page.url.pathname.startsWith('/conversations')
|
||||||
|
? 'bg-nav-active text-ink'
|
||||||
|
: 'text-ink-2 hover:bg-muted hover:text-ink'}"
|
||||||
|
>
|
||||||
|
{m.nav_conversations()}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{#if isAdmin}
|
||||||
|
<a
|
||||||
|
href="/admin"
|
||||||
|
class="block flex min-h-[44px] w-full items-center px-4 py-3 font-sans text-sm font-bold tracking-widest uppercase transition-colors
|
||||||
|
{page.url.pathname.startsWith('/admin')
|
||||||
|
? 'bg-nav-active text-ink'
|
||||||
|
: 'text-ink-2 hover:bg-muted hover:text-ink'}"
|
||||||
|
>
|
||||||
|
{m.nav_admin()}
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user