TempMonitor/src/lib/components/ui/breadcrumb/breadcrumb-link.svelte

32 lines
729 B
Svelte
Raw Normal View History

2025-05-19 16:25:20 +02:00
<script lang="ts">
import type { HTMLAnchorAttributes } from "svelte/elements";
import type { Snippet } from "svelte";
import { cn, type WithElementRef } from "$lib/utils.js";
2025-05-18 13:18:46 +02:00
let {
ref = $bindable(null),
class: className,
href = undefined,
child,
children,
...restProps
2025-05-19 16:25:20 +02:00
}: WithElementRef<HTMLAnchorAttributes> & {
child?: Snippet<[{ props: HTMLAnchorAttributes }]>;
2025-05-18 13:18:46 +02:00
} = $props();
const attrs = $derived({
2025-05-19 16:25:20 +02:00
"data-slot": "breadcrumb-link",
2025-05-18 13:18:46 +02:00
class: cn("hover:text-foreground transition-colors", className),
href,
...restProps,
});
</script>
{#if child}
{@render child({ props: attrs })}
{:else}
<a bind:this={ref} {...attrs}>
{@render children?.()}
</a>
{/if}