2024-08-05 21:45:16 +00:00
|
|
|
<script lang="ts">
|
2026-04-06 16:08:02 +00:00
|
|
|
import cx from "classnames"
|
2024-10-09 23:15:09 +00:00
|
|
|
import {page} from "$app/stores"
|
2026-06-24 20:56:53 +00:00
|
|
|
import Link from "@lib/components/Link.svelte"
|
2024-08-09 23:22:09 +00:00
|
|
|
import Button from "@lib/components/Button.svelte"
|
|
|
|
|
|
2025-02-04 01:21:46 +00:00
|
|
|
const {
|
|
|
|
|
children,
|
|
|
|
|
onclick = undefined,
|
|
|
|
|
title = "",
|
|
|
|
|
href = "",
|
|
|
|
|
prefix = "",
|
|
|
|
|
notification = false,
|
|
|
|
|
...restProps
|
|
|
|
|
} = $props()
|
2024-10-09 21:19:27 +00:00
|
|
|
|
2025-02-04 00:37:14 +00:00
|
|
|
const active = $derived($page.url?.pathname?.startsWith(prefix || href || "bogus"))
|
2026-04-06 16:08:02 +00:00
|
|
|
|
2026-06-24 20:56:53 +00:00
|
|
|
const className = $derived(
|
|
|
|
|
cx(restProps.class, "primary-nav__nav-item", {
|
|
|
|
|
"primary-nav__nav-item--active": active,
|
|
|
|
|
"tip tip-right": title,
|
2026-04-06 16:08:02 +00:00
|
|
|
}),
|
|
|
|
|
)
|
2024-08-05 21:45:16 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-06-24 20:56:53 +00:00
|
|
|
{#if onclick}
|
|
|
|
|
<Button {onclick} data-tip={title} class={className}>
|
|
|
|
|
{@render children?.()}
|
|
|
|
|
{#if !active && notification}
|
2026-09-01 15:05:45 +00:00
|
|
|
<div class="absolute right-1 top-1 h-2 w-2 rounded-full bg-primary text-primary-content">
|
2026-06-24 20:56:53 +00:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</Button>
|
|
|
|
|
{:else}
|
|
|
|
|
<Link {href} data-tip={title} class={className}>
|
|
|
|
|
{@render children?.()}
|
|
|
|
|
{#if !active && notification}
|
2026-09-01 15:05:45 +00:00
|
|
|
<div class="absolute right-1 top-1 h-2 w-2 rounded-full bg-primary text-primary-content">
|
2026-06-24 20:56:53 +00:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</Link>
|
|
|
|
|
{/if}
|