clove/system
src/lib/components/Header.svelte
<!-- src/lib/components/Header.svelte
Copyright (c) 2026 Clove Nytrix Doughmination Twilight
Licensed under the DASL-1.0 Licence.
See LICENCE.md in the project root for full licence information.
-->
<script lang="ts">
import IcLogin from "~icons/ic/outline-login";
import IcLogout from "~icons/ic/outline-logout";
import IcPerson from "~icons/ic/outline-person";
import IcPublic from "~icons/ic/outline-public";
import IcSettings from "~icons/ic/outline-settings";
import IcWorkspacePremium from "~icons/ic/outline-workspace-premium";
import "#lib/styles/header.css";
import { goto } from "$app/navigation";
import { page } from "$app/state";
import { fallbackAvatar } from "#lib";
import { auth } from "#lib/auth.svelte.ts";
const dashboardPaths = ["/user/docs", "/user/metrics"];
function currentSection(landing: string, section?: string) {
const currentPath = page.url.pathname;
if (currentPath === landing) return "page";
if (section && currentPath.startsWith(section)) return "location";
if (landing === "/user/dash" && dashboardPaths.includes(currentPath)) return "location";
return undefined;
}
async function signOut() {
const endSession = await auth.signOut();
if (endSession) location.href = endSession;
else await goto("/");
}
</script>
<!-- Fixed-height page backdrop, so every page gets the same amount of background -->
<div class="backdrop" aria-hidden="true"></div>
<header class="site-header">
<a class="brand" href="/">
<img src={fallbackAvatar} alt="" width="32" height="32" />
<span>Doughmination System®</span>
</a>
<nav aria-label="Account and dashboards">
{#if auth.signedIn}
<a href="/user/dash" aria-current={currentSection("/user/dash")}>
<IcPublic width="24" height="24" class="nav-icon" />Dashboard
</a>
{#if auth.isAdmin || auth.isOwner}
<a href="/admin/dash" aria-current={currentSection("/admin/dash", "/admin/")}>
<IcSettings width="24" height="24" class="nav-icon" />Admin
</a>
{/if}
{#if auth.isOwner}
<a href="/owner/dash" aria-current={currentSection("/owner/dash", "/owner/")}>
<IcWorkspacePremium width="24" height="24" class="nav-icon" />Owner
</a>
{/if}
<a
href="/user/profile"
aria-current={currentSection("/user/profile", "/user/profile/")}
title={auth.displayName}
>
<IcPerson width="24" height="24" class="nav-icon" />Profile
</a>
<button type="button" class="nav-button" onclick={signOut}>
<IcLogout width="24" height="24" class="nav-icon" />Sign out
</button>
{:else if auth.ready}
<a href="/user/login">
<IcLogin width="24" height="24" class="nav-icon" />Sign in
</a>
{/if}
</nav>
</header>