66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import React from 'react';
|
|
import { componentStyles, mergeClasses } from '@/lib/styles/designSystem';
|
|
|
|
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
variant?: 'primary' | 'discord' | 'auth' | 'secondary';
|
|
size?: 'sm' | 'md' | 'lg';
|
|
fullWidth?: boolean;
|
|
leftIcon?: React.ReactNode;
|
|
rightIcon?: React.ReactNode;
|
|
loading?: boolean;
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
const sizeClasses = {
|
|
sm: 'px-3 py-1.5 text-sm',
|
|
md: 'px-4 lg:px-6 py-2.5 lg:py-3 text-sm lg:text-base',
|
|
lg: 'px-6 py-3 text-base lg:text-lg',
|
|
};
|
|
|
|
const variantClasses = {
|
|
primary: 'bg-gradient-to-r from-banquise-blue to-banquise-blue-light hover:shadow-banquise-blue/25',
|
|
discord: 'bg-gradient-to-r from-indigo-600 to-purple-600 hover:from-indigo-500 hover:to-purple-500 hover:shadow-indigo-500/25',
|
|
auth: 'bg-gradient-to-r from-banquise-blue-light to-banquise-blue hover:shadow-banquise-blue-light/25',
|
|
secondary: 'bg-white/10 hover:bg-white/20 border border-white/20',
|
|
};
|
|
|
|
export const Button: React.FC<ButtonProps> = ({
|
|
variant = 'primary',
|
|
size = 'md',
|
|
fullWidth = false,
|
|
leftIcon,
|
|
rightIcon,
|
|
loading = false,
|
|
children,
|
|
className = '',
|
|
disabled,
|
|
...props
|
|
}) => {
|
|
const baseClasses = mergeClasses(
|
|
componentStyles.button.base,
|
|
sizeClasses[size],
|
|
variantClasses[variant],
|
|
fullWidth ? 'w-full' : '',
|
|
(disabled || loading) ? 'opacity-50 cursor-not-allowed' : '',
|
|
className
|
|
);
|
|
|
|
return (
|
|
<button
|
|
className={baseClasses}
|
|
disabled={disabled || loading}
|
|
{...props}
|
|
>
|
|
{loading && (
|
|
<svg className="animate-spin -ml-1 mr-2 h-4 w-4 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
|
|
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
</svg>
|
|
)}
|
|
{leftIcon && !loading && <span className="mr-2">{leftIcon}</span>}
|
|
{children}
|
|
{rightIcon && !loading && <span className="ml-2">{rightIcon}</span>}
|
|
</button>
|
|
);
|
|
};
|