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"
|
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
|
|
|
|
|
|
|
|
const wrapperClass = $derived(
|
|
|
|
|
cx("relative h-14 w-14 p-1", {
|
|
|
|
|
"tooltip tooltip-right": title,
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const innerClass = $derived(
|
|
|
|
|
cx(
|
|
|
|
|
"flex h-full w-full cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-base-300",
|
|
|
|
|
restProps.class,
|
2026-05-04 23:01:39 +00:00
|
|
|
{"bg-base-300 border border-solid border-base-content/20": active},
|
2026-04-06 16:08:02 +00:00
|
|
|
),
|
|
|
|
|
)
|
2024-08-05 21:45:16 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-04-06 16:08:02 +00:00
|
|
|
<div class={wrapperClass} data-tip={title}>
|
|
|
|
|
{#if onclick}
|
|
|
|
|
<Button {onclick} class={innerClass}>
|
2025-02-04 01:21:46 +00:00
|
|
|
{@render children?.()}
|
2024-11-14 18:53:13 +00:00
|
|
|
{#if !active && notification}
|
2025-03-20 16:38:57 +00:00
|
|
|
<div class="absolute right-1 top-1 h-2 w-2 rounded-full bg-primary"></div>
|
2024-11-14 18:53:13 +00:00
|
|
|
{/if}
|
2026-04-06 16:08:02 +00:00
|
|
|
</Button>
|
|
|
|
|
{:else}
|
|
|
|
|
<a {href} class={innerClass}>
|
2025-02-04 01:21:46 +00:00
|
|
|
{@render children?.()}
|
2024-11-14 18:53:13 +00:00
|
|
|
{#if !active && notification}
|
2025-03-20 16:38:57 +00:00
|
|
|
<div class="absolute right-1 top-1 h-2 w-2 rounded-full bg-primary"></div>
|
2024-11-14 18:53:13 +00:00
|
|
|
{/if}
|
2026-04-06 16:08:02 +00:00
|
|
|
</a>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|