Skyler Grey | 7177bbd | 2023-06-01 03:26:31 +0200 | [diff] [blame] | 1 | <script lang="ts"> |
| 2 | import type { VariantProps } from "class-variance-authority"; |
| 3 | import type { |
| 4 | HTMLAnchorAttributes, |
| 5 | HTMLButtonAttributes |
| 6 | } from "svelte/elements"; |
| 7 | import { cn } from "$lib/utils"; |
| 8 | import { buttonVariants } from "."; |
| 9 | |
| 10 | let className: string | undefined | null = undefined; |
| 11 | export { className as class }; |
| 12 | export let href: HTMLAnchorAttributes["href"] = undefined; |
| 13 | export let type: HTMLButtonAttributes["type"] = undefined; |
| 14 | export let variant: VariantProps<typeof buttonVariants>["variant"] = |
| 15 | "default"; |
| 16 | export let size: VariantProps<typeof buttonVariants>["size"] = "default"; |
| 17 | </script> |
| 18 | |
| 19 | <svelte:element |
| 20 | this={href ? "a" : "button"} |
| 21 | type={href ? undefined : type} |
| 22 | {href} |
| 23 | class={cn(buttonVariants({ variant, size, className }))} |
| 24 | {...$$restProps} |
| 25 | on:click |
| 26 | on:change |
| 27 | on:keydown |
| 28 | on:keyup |
| 29 | on:mouseenter |
| 30 | on:mouseleave |
| 31 | > |
| 32 | <slot /> |
| 33 | </svelte:element> |