59 lines
2.2 KiB
TypeScript
59 lines
2.2 KiB
TypeScript
import * as React from "react"
|
|
import {Slot} from "@radix-ui/react-slot"
|
|
import {cva, type VariantProps} from "class-variance-authority"
|
|
|
|
import {cn} from "@/lib/utils"
|
|
|
|
const buttonVariants = cva(
|
|
"inline-flex items-center border-3 border-black justify-center gap-2 whitespace-nowrap rounded-md text-sm font-bold transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default:
|
|
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
destructive:
|
|
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",
|
|
outline:
|
|
"bg-white shadow-sm hover:bg-background",
|
|
secondary:
|
|
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
ghost: "bg-accent hover:text-accent-foreground hover:text-accent-foreground",
|
|
link: "text-primary underline-offset-4 hover:underline",
|
|
},
|
|
size: {
|
|
default: "h-10 px-4 py-2 shadow-[4px_4px_0px_rgba(0,0,0,1)] hover:shadow-none hover:translate-2 transition delay-50 duration-200 ease-in-out",
|
|
sm: "h-8 rounded-md px-3 has-[>svg]:px-2.5",
|
|
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
icon: "size-9",
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: "default",
|
|
size: "default",
|
|
},
|
|
}
|
|
)
|
|
|
|
function Button({
|
|
className,
|
|
variant,
|
|
size,
|
|
asChild = false,
|
|
...props
|
|
}: React.ComponentProps<"button"> &
|
|
VariantProps<typeof buttonVariants> & {
|
|
asChild?: boolean
|
|
}) {
|
|
const Comp = asChild ? Slot : "button"
|
|
|
|
return (
|
|
<Comp
|
|
data-slot="button"
|
|
className={cn(buttonVariants({variant, size, className}))}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export {Button, buttonVariants}
|