61 lines
1.7 KiB
Vue
61 lines
1.7 KiB
Vue
<script setup lang="ts">
|
|
import { computed } from 'vue';
|
|
import { cva } from 'class-variance-authority';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
const buttonVariants = cva(
|
|
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default: 'bg-blue-600 text-white hover:bg-blue-700',
|
|
destructive: 'bg-red-600 text-white hover:bg-red-700',
|
|
outline:
|
|
'border border-gray-300 bg-white hover:bg-gray-50 hover:text-gray-900',
|
|
secondary: 'bg-gray-200 text-gray-900 hover:bg-gray-300',
|
|
ghost: 'hover:bg-gray-100 hover:text-gray-900',
|
|
link: 'text-blue-600 underline-offset-4 hover:underline',
|
|
},
|
|
size: {
|
|
default: 'h-10 px-4 py-2',
|
|
sm: 'h-9 rounded-md px-3',
|
|
lg: 'h-11 rounded-md px-8',
|
|
icon: 'h-10 w-10',
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: 'default',
|
|
size: 'default',
|
|
},
|
|
}
|
|
);
|
|
|
|
interface ButtonProps {
|
|
variant?:
|
|
| 'default'
|
|
| 'destructive'
|
|
| 'outline'
|
|
| 'secondary'
|
|
| 'ghost'
|
|
| 'link';
|
|
size?: 'default' | 'sm' | 'lg' | 'icon';
|
|
type?: 'button' | 'submit' | 'reset';
|
|
disabled?: boolean;
|
|
class?: string;
|
|
}
|
|
|
|
const props = withDefaults(defineProps<ButtonProps>(), {
|
|
type: 'button',
|
|
});
|
|
|
|
const className = computed(() =>
|
|
cn(buttonVariants({ variant: props.variant, size: props.size }), props.class)
|
|
);
|
|
</script>
|
|
|
|
<template>
|
|
<button :type="type" :disabled="disabled" :class="className">
|
|
<slot />
|
|
</button>
|
|
</template>
|