mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
36 lines
837 B
Svelte
36 lines
837 B
Svelte
<script lang="ts" module>
|
|
import type { VariantProps } from "tailwind-variants";
|
|
import { badgeVariants } from "@/components/ui/badge";
|
|
|
|
export type BadgeVariant = VariantProps<typeof badgeVariants>["variant"];
|
|
</script>
|
|
|
|
<script lang="ts">
|
|
import type { HTMLAnchorAttributes } from "svelte/elements";
|
|
import type { WithElementRef } from "@/types/components";
|
|
|
|
import { cn } from "@/utils/cn";
|
|
|
|
let {
|
|
ref = $bindable(null),
|
|
href,
|
|
class: className,
|
|
variant = "default",
|
|
children,
|
|
...restProps
|
|
}: WithElementRef<HTMLAnchorAttributes> & {
|
|
variant?: BadgeVariant;
|
|
} = $props();
|
|
</script>
|
|
|
|
<svelte:element
|
|
this={href ? "a" : "span"}
|
|
bind:this={ref}
|
|
data-slot="badge"
|
|
{href}
|
|
class={cn(badgeVariants({ variant }), className)}
|
|
{...restProps}
|
|
>
|
|
{@render children?.()}
|
|
</svelte:element>
|