Add initial shared code packages

This commit is contained in:
Gabriel20xx committed 2026-08-04 15:17:15 +02:00
commit 838a97d344
54 files changed
+6265

No files matched your search

@@ -0,0 +1,80 @@
<script lang="ts">
import type { NavItem } from '../types';
let {
brand = 'Application',
brandHref = '/',
currentPath = '',
navItems = [],
onLogout,
onProfile,
onSettings,
showSettings = true,
username = ''
}: {
brand?: string;
brandHref?: string;
currentPath?: string;
navItems?: NavItem[];
onLogout?: () => void | Promise<void>;
onProfile?: () => void;
onSettings?: () => void;
showSettings?: boolean;
username?: string;
} = $props();
let navOpen = $state(false);
function isActive(item: NavItem): boolean {
return item.href === '/'
? currentPath === '/'
: currentPath === item.href || currentPath.startsWith(`${item.href}/`);
}
</script>
<header class="sc-header">
<a class="sc-brand" href={brandHref} onclick={() => (navOpen = false)}>
<span aria-hidden="true" class="sc-brand-mark">{brand.slice(0, 1).toUpperCase()}</span>
<span>{brand}</span>
</a>
<nav aria-label="Primary navigation" class="sc-nav" data-open={navOpen}>
{#each navItems as item}
<a
aria-current={isActive(item) ? 'page' : undefined}
class="sc-nav-link"
data-active={isActive(item)}
href={item.href}
onclick={() => (navOpen = false)}
>
{item.label}
</a>
{/each}
</nav>
<div class="sc-header-actions">
{#if showSettings && onSettings}
<button aria-label="Open settings" class="sc-icon-button" type="button" onclick={onSettings}>⚙</button>
{/if}
{#if username && onProfile}
<button class="sc-profile-button" type="button" onclick={onProfile}>{username}</button>
{/if}
{#if onLogout}
<button class="sc-button sc-button-ghost sc-button-sm" type="button" onclick={() => void onLogout?.()}>
Log out
</button>
{/if}
<button
aria-expanded={navOpen}
aria-label={navOpen ? 'Close navigation menu' : 'Open navigation menu'}
class="sc-icon-button sc-mobile-menu-button"
type="button"
onclick={() => (navOpen = !navOpen)}
>
{navOpen ? '×' : '☰'}
</button>
</div>
</header>