@devries-cameron20 / OCIU-npo Mirror · read-only
Fork 0

Mirrored from https://github.com/Camo67/OCIU-npo.git

Synced Nov 21, 04:45 UTC

1 import * as React from "react";
2 import { Slot } from "@radix-ui/react-slot";
3 import { cva, type VariantProps } from "class-variance-authority";
4
5 import { cn } from "@/lib/utils";
6
7 const buttonVariants = cva(
8 "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
9 {
10 variants: {
11 variant: {
12 default: "bg-primary text-primary-foreground hover:bg-primary/90",
13 destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
14 outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
15 secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
16 ghost: "hover:bg-accent hover:text-accent-foreground",
17 link: "text-primary underline-offset-4 hover:underline",
18 hero: "bg-gradient-hero text-white hover:opacity-90 shadow-lg hover:shadow-xl transition-all",
19 growth: "bg-gradient-growth text-white hover:opacity-90 shadow-lg hover:shadow-xl transition-all",
20 energy: "bg-gradient-energy text-white hover:opacity-90 shadow-lg hover:shadow-xl transition-all",
21 },
22 size: {
23 default: "h-10 px-4 py-2",
24 sm: "h-9 rounded-md px-3",
25 lg: "h-12 rounded-lg px-10 text-base",
26 icon: "h-10 w-10",
27 },
28 },
29 defaultVariants: {
30 variant: "default",
31 size: "default",
32 },
33 },
34 );
35
36 export interface ButtonProps
37 extends React.ButtonHTMLAttributes<HTMLButtonElement>,
38 VariantProps<typeof buttonVariants> {
39 asChild?: boolean;
40 }
41
42 const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
43 ({ className, variant, size, asChild = false, ...props }, ref) => {
44 const Comp = asChild ? Slot : "button";
45 return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
46 },
47 );
48 Button.displayName = "Button";
49
50 export { Button, buttonVariants };