36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import type { ButtonHTMLAttributes } from "react";
|
|
|
|
type ButtonVariant = "primary" | "ghost" | "danger";
|
|
type ButtonSize = "sm" | "md";
|
|
|
|
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
variant?: ButtonVariant;
|
|
size?: ButtonSize;
|
|
}
|
|
|
|
const variantClasses: Record<ButtonVariant, string> = {
|
|
primary: "bg-accent text-white hover:bg-accent/90",
|
|
ghost: "border border-border bg-white text-ink hover:bg-paper",
|
|
danger: "bg-danger text-white hover:bg-danger/90",
|
|
};
|
|
|
|
const sizeClasses: Record<ButtonSize, string> = {
|
|
sm: "rounded-sm px-2 py-1 text-xs",
|
|
md: "rounded-md px-3 py-2 text-sm",
|
|
};
|
|
|
|
export function Button({
|
|
variant = "primary",
|
|
size = "md",
|
|
className = "",
|
|
type = "button",
|
|
...props
|
|
}: ButtonProps) {
|
|
return (
|
|
<button
|
|
type={type}
|
|
className={`inline-flex items-center justify-center gap-1.5 font-medium transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent disabled:cursor-not-allowed disabled:opacity-50 ${variantClasses[variant]} ${sizeClasses[size]} ${className}`}
|
|
{...props}
|
|
/>
|
|
);
|
|
} |