ui, server handling improvements

This commit is contained in:
2024-12-23 18:47:22 -08:00
parent 32927dfd55
commit 03fb89dc8b
12 changed files with 106 additions and 115 deletions

View File

@@ -6,20 +6,20 @@
const { data, children } = $props();
const { user } = data;
function getNavClass(path: string) {
function getNavClass(path: RegExp) {
return cn('hover:text-foreground/80 transition-colors',
$page.url.pathname.startsWith(path) ? 'text-foreground' : 'text-foreground/60');
path.test($page.url.pathname) ? 'text-foreground' : 'text-foreground/60');
}
</script>
<header class="p-4 sm:flex">
<span class=" mr-6 font-bold sm:inline-block">VPGen</span>
<nav class="flex items-center gap-6 text-sm">
<a href="/" class={getNavClass("/")}>Home</a>
<a href="/" class={getNavClass(/^\/$/)}>Home</a>
{#if user}
<a href="/user" class={getNavClass("/user")}>Profile</a>
<a href="/connections" class={getNavClass("/connections")}>Connections</a>
<a href="/clients" class={getNavClass("/clients")}>Clients</a>
<a href="/user" class={getNavClass(/^\/user$/)}>Profile</a>
<a href="/connections" class={getNavClass(/^\/connections$/)}>Connections</a>
<a href="/clients" class={getNavClass(/^\/clients(\/\d+)?$/)}>Clients</a>
{/if}
</nav>
</header>