38 lines
No EOL
1.2 KiB
TypeScript
38 lines
No EOL
1.2 KiB
TypeScript
import React from 'react';
|
|
|
|
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
variant?: 'default' | 'outline' | 'danger';
|
|
size?: 'sm' | 'md' | 'lg';
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export function Button({
|
|
variant = 'default',
|
|
size = 'md',
|
|
className = '',
|
|
children,
|
|
disabled,
|
|
...props
|
|
}: ButtonProps) {
|
|
const baseClasses = 'inline-flex items-center justify-center rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed';
|
|
|
|
const variantClasses = {
|
|
default: 'bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500',
|
|
outline: 'border border-border bg-transparent text-text-primary hover:bg-surface-secondary focus:ring-primary-500',
|
|
danger: 'bg-red-500 text-white hover:bg-red-600 focus:ring-red-500',
|
|
};
|
|
|
|
const sizeClasses = {
|
|
sm: 'px-2 py-1 text-xs',
|
|
md: 'px-4 py-2 text-sm',
|
|
lg: 'px-6 py-3 text-base',
|
|
};
|
|
|
|
const classes = `${baseClasses} ${variantClasses[variant]} ${sizeClasses[size]} ${className}`;
|
|
|
|
return (
|
|
<button className={classes} disabled={disabled} {...props}>
|
|
{children}
|
|
</button>
|
|
);
|
|
} |