flotilla/src/lib/components/PrimaryNavItem.svelte

40 lines
1.2 KiB
Svelte
Raw Normal View History

2024-08-05 21:45:16 +00:00
<script lang="ts">
2024-10-09 23:15:09 +00:00
import {page} from "$app/stores"
2024-08-09 23:22:09 +00:00
import Button from "@lib/components/Button.svelte"
2024-08-14 23:25:36 +00:00
export let title = ""
2024-08-16 18:12:14 +00:00
export let href = ""
2024-10-21 20:46:32 +00:00
export let prefix = ""
2024-11-14 18:53:13 +00:00
export let notification = false
2024-10-09 21:19:27 +00:00
2024-10-21 20:46:32 +00:00
$: active = $page.url?.pathname?.startsWith(prefix || href || "bogus")
2024-08-05 21:45:16 +00:00
</script>
2024-08-16 18:12:14 +00:00
{#if href}
<a {href} class="relative z-nav-item flex h-14 w-14 items-center justify-center">
<div
2024-10-09 23:15:09 +00:00
class="avatar cursor-pointer rounded-full p-1 {$$props.class} transition-colors hover:bg-base-300"
2024-10-09 21:19:27 +00:00
class:bg-base-300={active}
2024-08-16 18:12:14 +00:00
class:tooltip={title}
data-tip={title}>
2024-11-14 20:16:44 +00:00
<slot />
2024-11-14 18:53:13 +00:00
{#if !active && notification}
2025-02-03 23:01:42 +00:00
<div class="absolute right-2 top-2 h-2 w-2 rounded-full bg-primary"></div>
2024-11-14 18:53:13 +00:00
{/if}
2024-08-16 18:12:14 +00:00
</div>
</a>
{:else}
<Button on:click class="relative z-nav-item flex h-14 w-14 items-center justify-center">
<div
2024-10-09 23:15:09 +00:00
class="avatar cursor-pointer rounded-full p-1 {$$props.class} transition-colors hover:bg-base-300"
2024-10-09 21:19:27 +00:00
class:bg-base-300={active}
2024-08-16 18:12:14 +00:00
class:tooltip={title}
data-tip={title}>
2024-11-14 20:16:44 +00:00
<slot />
2024-11-14 18:53:13 +00:00
{#if !active && notification}
2025-02-03 23:01:42 +00:00
<div class="absolute right-2 top-2 h-2 w-2 rounded-full bg-primary"></div>
2024-11-14 18:53:13 +00:00
{/if}
2024-08-16 18:12:14 +00:00
</div>
</Button>
{/if}