This commit is contained in:
1 parent
9a6ec940f7
commit
fd32419371
114 files changed
+21997
-96
No files matched your search
@@ -0,0 +1,43 @@
|
||||
<script lang="ts">
|
||||
import { cva, type VariantProps } from 'class-variance-authority'
|
||||
import type { HTMLButtonAttributes } from 'svelte/elements'
|
||||
import { cn } from '$lib/utils/cn'
|
||||
|
||||
export const buttonVariants = cva(
|
||||
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'bg-primary text-primary-fg hover:opacity-90',
|
||||
secondary: 'border border-border bg-surface text-fg hover:bg-surface-hover',
|
||||
outline: 'border border-border bg-transparent text-fg hover:bg-surface-hover',
|
||||
ghost: 'text-fg hover:bg-surface-hover',
|
||||
danger: 'bg-danger text-danger-fg hover:opacity-90',
|
||||
success: 'bg-success text-success-fg hover:opacity-90',
|
||||
link: 'text-primary underline-offset-4 hover:underline',
|
||||
},
|
||||
size: {
|
||||
default: 'h-9 px-4 py-2',
|
||||
sm: 'h-8 rounded-md px-3 text-xs',
|
||||
lg: 'h-10 rounded-md px-6',
|
||||
icon: 'h-9 w-9',
|
||||
},
|
||||
},
|
||||
defaultVariants: { variant: 'default', size: 'default' },
|
||||
},
|
||||
)
|
||||
|
||||
type Variant = VariantProps<typeof buttonVariants>
|
||||
let {
|
||||
class: className,
|
||||
variant = 'default',
|
||||
size = 'default',
|
||||
type = 'button',
|
||||
children,
|
||||
...rest
|
||||
}: HTMLButtonAttributes & Variant & { children?: import('svelte').Snippet } = $props()
|
||||
</script>
|
||||
|
||||
<button {type} class={cn(buttonVariants({ variant, size }), className)} {...rest}>
|
||||
{@render children?.()}
|
||||
</button>
|
||||
Reference in new issue
Block a user