2025-12-14 02:38:35 +07:00
|
|
|
import { forwardRef, type ButtonHTMLAttributes } from 'react'
|
|
|
|
|
import { clsx } from 'clsx'
|
|
|
|
|
import { Loader2 } from 'lucide-react'
|
|
|
|
|
|
|
|
|
|
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
|
|
variant?: 'primary' | 'secondary' | 'danger' | 'ghost'
|
|
|
|
|
size?: 'sm' | 'md' | 'lg'
|
|
|
|
|
isLoading?: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
|
|
({ className, variant = 'primary', size = 'md', isLoading, children, disabled, ...props }, ref) => {
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
ref={ref}
|
|
|
|
|
disabled={disabled || isLoading}
|
|
|
|
|
className={clsx(
|
2025-12-17 02:03:33 +07:00
|
|
|
'inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200',
|
2025-12-14 02:38:35 +07:00
|
|
|
'disabled:opacity-50 disabled:cursor-not-allowed',
|
|
|
|
|
{
|
2025-12-17 14:53:56 +07:00
|
|
|
'bg-neon-500 hover:bg-neon-400 text-dark-900 font-semibold shadow-[0_0_8px_rgba(34,211,238,0.25)] hover:shadow-[0_0_14px_rgba(34,211,238,0.4)]': variant === 'primary',
|
2025-12-17 02:03:33 +07:00
|
|
|
'bg-dark-600 hover:bg-dark-500 text-white border border-dark-500': variant === 'secondary',
|
2025-12-14 02:38:35 +07:00
|
|
|
'bg-red-600 hover:bg-red-700 text-white': variant === 'danger',
|
2025-12-17 02:03:33 +07:00
|
|
|
'bg-transparent hover:bg-dark-700 text-gray-300 hover:text-white': variant === 'ghost',
|
2025-12-14 02:38:35 +07:00
|
|
|
'px-3 py-1.5 text-sm': size === 'sm',
|
|
|
|
|
'px-4 py-2 text-base': size === 'md',
|
|
|
|
|
'px-6 py-3 text-lg': size === 'lg',
|
|
|
|
|
},
|
|
|
|
|
className
|
|
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
>
|
|
|
|
|
{isLoading && <Loader2 className="w-4 h-4 mr-2 animate-spin" />}
|
|
|
|
|
{children}
|
|
|
|
|
</button>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
Button.displayName = 'Button'
|