57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
|
|
import { cn } from "@/shared/utils/utils";
|
||
|
|
import { Slot } from "@radix-ui/react-slot";
|
||
|
|
import { cva, VariantProps } from "class-variance-authority";
|
||
|
|
import * as React from "react";
|
||
|
|
|
||
|
|
const variants = cva(
|
||
|
|
"inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-xl font-medium text-sm transition-all disabled:pointer-events-none disabled:opacity-50",
|
||
|
|
{
|
||
|
|
variants: {
|
||
|
|
variant: {
|
||
|
|
outlined:
|
||
|
|
"border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 hover:text-gray-900",
|
||
|
|
primary: "bg-biru-400 text-white hover:bg-blue-700",
|
||
|
|
whiteOutlined:
|
||
|
|
"bg-transparent border border-white text-white hover:bg-white/10",
|
||
|
|
danger: "bg-danger text-white hover:bg-rose-500",
|
||
|
|
dangerOutlined:
|
||
|
|
"bg-transparent border border-danger text-danger hover:bg-red-50",
|
||
|
|
},
|
||
|
|
size: {
|
||
|
|
xs: "h-7 px-2 text-xs",
|
||
|
|
sm: "h-9 px-3",
|
||
|
|
default: "h-11 px-6 py-3",
|
||
|
|
lg: "h-11 px-8",
|
||
|
|
icon: "h-10 w-10",
|
||
|
|
},
|
||
|
|
},
|
||
|
|
defaultVariants: {
|
||
|
|
variant: "primary",
|
||
|
|
size: "default",
|
||
|
|
},
|
||
|
|
},
|
||
|
|
);
|
||
|
|
|
||
|
|
export interface ButtonProps
|
||
|
|
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||
|
|
VariantProps<typeof variants> {
|
||
|
|
asChild?: boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||
|
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
||
|
|
const Comp = asChild ? Slot : "button";
|
||
|
|
return (
|
||
|
|
<Comp
|
||
|
|
className={cn(variants({ variant, size, className }))}
|
||
|
|
ref={ref}
|
||
|
|
{...props}
|
||
|
|
/>
|
||
|
|
);
|
||
|
|
},
|
||
|
|
);
|
||
|
|
|
||
|
|
Button.displayName = "Button";
|
||
|
|
|
||
|
|
export { Button, variants };
|