40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import * as React from "react";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
type Variant = "primary" | "outline" | "ghost" | "destructive";
|
|
type Size = "sm" | "md";
|
|
|
|
const variants: Record<Variant, string> = {
|
|
primary: "bg-primary text-primary-foreground hover:opacity-90",
|
|
outline: "border border-border bg-card text-foreground hover:bg-muted",
|
|
ghost: "text-foreground hover:bg-muted",
|
|
destructive: "bg-destructive text-destructive-foreground hover:opacity-90",
|
|
};
|
|
const sizes: Record<Size, string> = {
|
|
sm: "h-8 px-3 text-xs",
|
|
md: "h-10 px-4 text-sm",
|
|
};
|
|
|
|
export function Button({
|
|
variant = "primary",
|
|
size = "md",
|
|
className,
|
|
...props
|
|
}: React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
variant?: Variant;
|
|
size?: Size;
|
|
}) {
|
|
return (
|
|
<button
|
|
className={cn(
|
|
"inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-lg font-medium transition-colors outline-none",
|
|
"focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:pointer-events-none",
|
|
variants[variant],
|
|
sizes[size],
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|