Spaces:
Sleeping
Sleeping
File size: 1,410 Bytes
7b0525c 5683f0b | 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 React from 'react';
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: 'primary' | 'secondary' | 'danger' | 'ghost' | 'outline';
isLoading?: boolean;
}
export const Button: React.FC<ButtonProps> = ({
children,
variant = 'primary',
className = '',
isLoading = false,
...props
}) => {
const baseStyles = "px-4 py-2 rounded-lg font-medium transition-all duration-200 flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed";
const variants = {
primary: "bg-primary text-background hover:bg-opacity-90 shadow-[0_0_10px_rgba(187,134,252,0.3)]",
secondary: "bg-surfaceHover text-white hover:bg-white/10 border border-white/10",
outline: "bg-transparent border border-primary text-primary hover:bg-primary hover:text-background shadow-[0_0_5px_rgba(187,134,252,0.2)]",
danger: "bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20",
ghost: "text-gray-400 hover:text-white hover:bg-white/5"
};
return (
<button
className={`${baseStyles} ${variants[variant]} ${className}`}
disabled={isLoading || props.disabled}
{...props}
>
{isLoading ? (
<span className="animate-spin h-4 w-4 border-2 border-current border-t-transparent rounded-full" />
) : null}
{children}
</button>
);
}; |