Added mobile hamburger.

This commit is contained in:
Pen Anderson 2026-03-03 16:09:43 -06:00
parent 0d940749b1
commit 9a367bb78b
3 changed files with 47 additions and 4 deletions

View file

@ -23,6 +23,7 @@
let loading = $state(true) let loading = $state(true)
let route = $state(window.location.hash || '#/') let route = $state(window.location.hash || '#/')
let updateAvailable = $state(false) let updateAvailable = $state(false)
let mobileNavOpen = $state(false)
// Check if this is a kiosk token URL before doing anything else // Check if this is a kiosk token URL before doing anything else
const kioskToken = $derived(window.location.hash.match(/^#\/v\/([A-Z0-9]+)/i)?.[1] ?? '') const kioskToken = $derived(window.location.hash.match(/^#\/v\/([A-Z0-9]+)/i)?.[1] ?? '')
@ -52,6 +53,7 @@
} }
window.addEventListener('hashchange', () => { window.addEventListener('hashchange', () => {
route = window.location.hash || '#/' route = window.location.hash || '#/'
mobileNavOpen = false
}) })
// Periodically check for updates // Periodically check for updates
@ -92,8 +94,18 @@
<GateUI {session} {onLogout} /> <GateUI {session} {onLogout} />
{:else} {:else}
<div class="layout"> <div class="layout">
<Nav {session} {onLogout} active={path} /> <!-- svelte-ignore a11y_no_static_element_interactions -->
{#if mobileNavOpen}
<div class="nav-overlay" onclick={() => mobileNavOpen = false} onkeydown={() => {}}></div>
{/if}
<Nav {session} {onLogout} active={path} open={mobileNavOpen} />
<div class="main"> <div class="main">
<header class="mobile-header">
<button class="hamburger" onclick={() => mobileNavOpen = !mobileNavOpen} aria-label="Menu">
<span></span><span></span><span></span>
</button>
<span class="mobile-brand">Turn<span class="accent">pike</span></span>
</header>
{#if path === '/' || path === ''} {#if path === '/' || path === ''}
{#if role === 'volunteer_lead'} {#if role === 'volunteer_lead'}
<ScheduleBoard {session} /> <ScheduleBoard {session} />

View file

@ -170,8 +170,39 @@ tr:hover td { background: rgba(255,255,255,0.02); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } } @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
/* Mobile header — hidden on desktop */
.mobile-header { display: none; }
@media (max-width: 640px) { @media (max-width: 640px) {
.sidebar { display: none; } .mobile-header {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem 1rem;
background: var(--c-surface);
border-bottom: 1px solid var(--c-border);
}
.mobile-brand { font-weight: 700; font-size: 1rem; }
.mobile-brand .accent { color: var(--c-accent); }
.hamburger {
display: flex; flex-direction: column; gap: 4px;
background: none; border: none; padding: 4px; cursor: pointer;
}
.hamburger span {
display: block; width: 20px; height: 2px;
background: var(--c-text); border-radius: 1px;
transition: transform var(--transition), opacity var(--transition);
}
.sidebar {
position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
transform: translateX(-100%);
transition: transform 200ms ease;
}
.sidebar.open { transform: translateX(0); }
.nav-overlay {
position: fixed; inset: 0; z-index: 99;
background: rgba(0,0,0,0.5);
}
.page { padding: 1rem; } .page { padding: 1rem; }
.stats { grid-template-columns: repeat(2, 1fr); } .stats { grid-template-columns: repeat(2, 1fr); }
} }

View file

@ -1,5 +1,5 @@
<script> <script>
let { session, active, onLogout } = $props() let { session, active, onLogout, open = false } = $props()
const role = $derived(session?.user?.role ?? '') const role = $derived(session?.user?.role ?? '')
@ -42,7 +42,7 @@
} }
</script> </script>
<nav class="sidebar"> <nav class="sidebar" class:open>
<div class="sidebar-brand">Turn<span>pike</span></div> <div class="sidebar-brand">Turn<span>pike</span></div>
{#each links as link} {#each links as link}
<a href={link.href} class="nav-link" class:active={isActive(link.href)}> <a href={link.href} class="nav-link" class:active={isActive(link.href)}>