Elffuss BraidHub

kikocis/continue public

8eb3ae7b8d16 · 1.5 KiBRawPermalink
1import * as React from "react";
2import { cn } from "../../util/cn";
3
4type ButtonVariant = "ghost" | "primary" | "secondary" | "outline";
5type ButtonSize = "sm" | "lg";
6
7type ButtonProps = React.ComponentProps<"button"> & {
8 variant?: ButtonVariant;
9 size?: ButtonSize;
10};
11
12const buttonVariants = {
13 primary:
14 "border-none text-primary-foreground bg-primary hover:enabled:brightness-125",
15 secondary:
16 "border-none text-foreground bg-border hover:enabled:brightness-125",
17 outline:
18 "border border-solid border-badge border-border text-foreground bg-transparent hover:enabled:bg-input",
19 ghost:
20 "border-none text-foreground bg-inherit hover:enabled:brightness-125 hover:enabled:bg-input",
21};
22
23const buttonSizes = {
24 sm: "px-1.5 py-0.5 text-2xs",
25 lg: "px-2 py-1 text-sm",
26};
27
28const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
29 ({ variant = "primary", size = "lg", className, ...props }, ref) => {
30 return (
31 <button
32 ref={ref}
33 className={cn(
34 "my-1.5 cursor-pointer rounded transition-all duration-200",
35 "hover:enabled:cursor-pointer",
36 "disabled:text-description-muted disabled:pointer-events-none disabled:opacity-50",
37 buttonVariants[variant],
38 buttonSizes[size],
39 className,
40 )}
41 style={{
42 fontFamily: "system-ui, -apple-system, sans-serif",
43 ...props.style,
44 }}
45 {...props}
46 />
47 );
48 },
49);
50
51Button.displayName = "Button";
52
53export { Button };