because I got bored of customising my CV for every job
1import { cva, type VariantProps } from "class-variance-authority";
2import { cn } from "../lib/cn";
3
4const buttonVariants = cva(
5 "inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ctp-blue focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
6 {
7 variants: {
8 variant: {
9 primary: "bg-ctp-blue text-ctp-base hover:bg-ctp-blue/90",
10 secondary: "bg-ctp-surface1 text-ctp-text hover:bg-ctp-surface1/80",
11 outline:
12 "border border-ctp-surface1 bg-transparent text-ctp-text hover:bg-ctp-surface0",
13 ghost: "text-ctp-text hover:bg-ctp-surface0",
14 destructive: "bg-ctp-red text-ctp-base hover:bg-ctp-red/90",
15 },
16 size: {
17 sm: "h-8 px-3 text-sm",
18 md: "h-10 px-4 py-2",
19 lg: "h-12 px-8 text-lg",
20 },
21 },
22 defaultVariants: {
23 variant: "primary",
24 size: "md",
25 },
26 },
27);
28
29interface ButtonProps extends VariantProps<typeof buttonVariants> {
30 children: React.ReactNode;
31 onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
32 disabled?: boolean;
33 className?: string;
34 type?: "button" | "submit" | "reset";
35}
36
37export const Button = ({
38 children,
39 onClick,
40 disabled = false,
41 variant = "primary",
42 size = "md",
43 className = "",
44 type = "button",
45}: ButtonProps) => {
46 return (
47 <button
48 type={type}
49 onClick={onClick}
50 disabled={disabled}
51 className={cn(buttonVariants({ variant, size }), className)}
52 >
53 {children}
54 </button>
55 );
56};