52 lines
2.2 KiB
JavaScript
52 lines
2.2 KiB
JavaScript
import React from "react";
|
|
import { Slot } from "@radix-ui/react-slot";
|
|
import { cva } from "class-variance-authority";
|
|
|
|
import { cn } from "../../lib/utils";
|
|
|
|
const buttonVariants = cva(
|
|
"kart-ui inline-flex w-auto min-w-0 m-0 shrink-0 items-center justify-center gap-2 whitespace-nowrap border border-transparent text-center font-bold leading-none outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default: "rounded-pill bg-primary text-primary-foreground hover:bg-primary/90",
|
|
secondary: "rounded-pill bg-secondary text-muted-foreground hover:bg-secondary/80",
|
|
outline: "rounded-pill border-border bg-white text-primary hover:bg-muted",
|
|
ghost: "bg-transparent text-foreground hover:bg-muted",
|
|
square: "rounded bg-primary text-primary-foreground hover:bg-primary/90",
|
|
soft: "rounded bg-muted text-muted-foreground hover:bg-border",
|
|
destructive: "rounded bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
icon: "rounded border-border bg-white text-muted-foreground hover:bg-muted",
|
|
},
|
|
size: {
|
|
default: "h-7 px-4 text-sm",
|
|
sm: "h-7 px-3 text-xs",
|
|
md: "h-9 px-4 text-sm",
|
|
lg: "h-[50px] px-5 text-base",
|
|
icon: "h-9 w-9 p-0",
|
|
legacy: "h-7 w-[113px] px-3 text-sm",
|
|
wide: "h-[50px] w-[156px] px-5 text-base",
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: "default",
|
|
size: "default",
|
|
},
|
|
}
|
|
);
|
|
|
|
const Button = React.forwardRef(({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
const Comp = asChild ? Slot : "button";
|
|
|
|
return (
|
|
<Comp
|
|
className={cn(buttonVariants({ variant, size, className }))}
|
|
ref={ref}
|
|
{...props}
|
|
/>
|
|
);
|
|
});
|
|
Button.displayName = "Button";
|
|
|
|
export { Button, buttonVariants };
|