42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
|
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
variant?: 'primary' | 'secondary' | 'accent' | 'danger' | 'outline';
|
|
size?: 'sm' | 'md' | 'lg';
|
|
}
|
|
|
|
export const Button: React.FC<ButtonProps> = ({
|
|
children,
|
|
variant = 'primary',
|
|
size = 'md',
|
|
className = '',
|
|
disabled,
|
|
...props
|
|
}) => {
|
|
const baseStyles = 'inline-flex items-center justify-center font-medium transition duration-150 rounded disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-offset-1';
|
|
|
|
const sizeStyles = {
|
|
sm: 'text-xs px-2.5 py-1.5',
|
|
md: 'text-sm px-4 py-2',
|
|
lg: 'text-base px-5 py-2.5',
|
|
};
|
|
|
|
const variantStyles = {
|
|
primary: 'bg-sidebar-surface hover:bg-sidebar-active text-white focus:ring-sidebar-active shadow-none',
|
|
secondary: 'bg-white hover:bg-surface-low text-text-primary border border-card-border focus:ring-card-border shadow-none',
|
|
accent: 'bg-accent-ochre hover:brightness-95 text-white focus:ring-accent-ochre shadow-none font-semibold',
|
|
danger: 'bg-error hover:bg-red-800 text-white focus:ring-error shadow-none',
|
|
outline: 'bg-transparent hover:bg-surface-low text-text-primary border border-card-border focus:ring-card-border shadow-none',
|
|
};
|
|
|
|
return (
|
|
<button
|
|
className={`${baseStyles} ${sizeStyles[size]} ${variantStyles[variant]} ${className}`}
|
|
disabled={disabled}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</button>
|
|
);
|
|
};
|