Files
scavengerhunt-fe/src/lib/components/BottomNav.svelte
2026-05-18 00:44:53 -05:00

40 lines
2.0 KiB
Svelte

<script lang="ts">
import {push, router} from 'svelte-spa-router'
function isActive(path: string) {
return router.location === path || router.location.startsWith(path + '/')
}
const huntId = $derived(
(router.params as Record<string, string> | null)?.huntId ?? null
)
</script>
<nav class="btm-nav btm-nav-sm bg-base-100 border-t border-base-300 fixed bottom-0 left-0 right-0 z-30">
<button class:active={isActive('/')} onclick={() => push('/')}>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
</svg>
<span class="btm-nav-label text-xs">Hunts</span>
</button>
{#if huntId}
<button
class:active={router.location.includes('/leaderboard')}
onclick={() => push(`/hunt/${huntId}/leaderboard`)}
>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
</svg>
<span class="btm-nav-label text-xs">Scores</span>
</button>
{/if}
<button class:active={isActive('/rules')} onclick={() => push('/rules')}>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
<span class="btm-nav-label text-xs">Rules</span>
</button>
</nav>