File size: 2,200 Bytes
5463318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React from "react";
import { cn } from "../../utils/cn";
import { Loader2 } from "lucide-react";
import { motion } from "framer-motion";

const buttonVariants = {
    primary:
        "bg-primary text-primary-foreground hover:bg-primary/90 shadow-md shadow-primary/20 hover:shadow-primary/40 active:scale-95",
    secondary:
        "bg-secondary text-secondary-foreground hover:bg-secondary/80 active:scale-95",
    ghost: "hover:bg-accent/10 hover:text-accent active:scale-95",
    danger:
        "bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-md shadow-destructive/20 hover:shadow-destructive/40 active:scale-95",
    outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground active:scale-95"
};

const buttonSizes = {
    sm: "h-9 px-3 text-sm",
    md: "h-11 px-5 py-2 text-base",
    lg: "h-12 px-8 text-lg",
    icon: "h-10 w-10",
};

export const Button = React.forwardRef(
    (
        {
            className,
            variant = "primary",
            size = "md",
            isLoading = false,
            disabled,
            children,
            ...props
        },
        ref
    ) => {
        return (
            <motion.button
                ref={ref}
                whileTap={{ scale: disabled || isLoading ? 1 : 0.98 }}
                className={cn(
                    "inline-flex items-center justify-center rounded-lg font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 relative overflow-hidden",
                    buttonVariants[variant],
                    buttonSizes[size],
                    className
                )}
                disabled={disabled || isLoading}
                {...props}
            >
                {isLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
                {children}

                {/* Ripple/Glow effect placeholder */}
                <span className="absolute inset-0 z-[-1] bg-white/10 opacity-0 hover:opacity-100 transition-opacity duration-300" />
            </motion.button>
        );
    }
);

Button.displayName = "Button";