Spaces:
Runtime error
Runtime error
File size: 1,247 Bytes
24727a3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import { cn } from '../../utils/cn'
import { Spinner } from './Spinner'
const variants = {
primary: 'bg-brand-500 hover:bg-brand-600 text-white shadow-sm',
secondary: 'bg-white hover:bg-gray-50 text-gray-700 border border-gray-300',
accent: 'bg-accent-500 hover:bg-accent-600 text-white shadow-sm',
ghost: 'hover:bg-gray-100 text-gray-600',
danger: 'bg-red-600 hover:bg-red-700 text-white',
outline: 'border-2 border-brand-500 text-brand-500 hover:bg-brand-50',
}
const sizes = {
sm: 'px-3 py-1.5 text-sm rounded-lg',
md: 'px-5 py-2.5 text-sm rounded-xl',
lg: 'px-7 py-3.5 text-base rounded-xl',
xl: 'px-9 py-4 text-lg rounded-2xl',
}
export function Button({ variant = 'primary', size = 'md', loading, icon, children, className, ...props }) {
return (
<button
className={cn(
'inline-flex items-center gap-2 font-semibold transition-all duration-200',
'focus:outline-none focus:ring-2 focus:ring-brand-500 focus:ring-offset-2',
'disabled:opacity-60 disabled:cursor-not-allowed',
variants[variant], sizes[size], className
)}
disabled={loading || props.disabled}
{...props}
>
{loading ? <Spinner size="sm" /> : icon}
{children}
</button>
)
}
|