1"use client"
2
3import type React from "react"
4import { cva, type VariantProps } from "class-variance-authority"
5import { Loader2 } from "lucide-react"
6import { motion, type HTMLMotionProps } from "motion/react"
7
8const buttonVariants = cva(
9 // Base styles
10 "justify-center px-4 text-sm font-medium items-center transition-[box-shadow,background-color] disabled:cursor-not-allowed disabled:opacity-50 flex active:transition-none",
11 {
12 variants: {
13 intent: {
14 default: [
15 "bg-[#36322F]",
16 "text-[#fff]",
17 "hover:enabled:bg-[#4a4542]",
18 "disabled:bg-[#8c8885]",
19 "[box-shadow:inset_0px_-2.108433723449707px_0px_0px_#171310,_0px_1.2048193216323853px_6.325301647186279px_0px_rgba(58,_33,_8,_58%)]",
20 "hover:enabled:[box-shadow:inset_0px_-2.53012px_0px_0px_#171310,_0px_1.44578px_7.59036px_0px_rgba(58,_33,_8,_64%)]",
21 "disabled:shadow-none",
22 "active:bg-[#2A2724]",
23 "active:[box-shadow:inset_0px_-1.5px_0px_0px_#171310,_0px_0.5px_2px_0px_rgba(58,_33,_8,_70%)]",
24 ],
25 primary: [
26 "bg-[#2C7BE5]",
27 "text-[#fff]",
28 "hover:enabled:bg-[#3D8DF5]",
29 "disabled:bg-[#9FC3F5]",
30 "[box-shadow:inset_0px_-2.108433723449707px_0px_0px_#1A68D1,_0px_1.2048193216323853px_6.325301647186279px_0px_rgba(28,_100,_242,_58%)]",
31 "hover:enabled:[box-shadow:inset_0px_-2.53012px_0px_0px_#2C7BE5,_0px_1.44578px_7.59036px_0px_rgba(28,_100,_242,_64%)]",
32 "disabled:shadow-none",
33 "active:bg-[#1A68D1]",
34 "active:[box-shadow:inset_0px_-1.5px_0px_0px_#1554AB,_0px_0.5px_2px_0px_rgba(28,_100,_242,_70%)]",
35 ],
36 secondary: [
37 "bg-[#FFFFFF]",
38 "text-[#36322F]",
39 "hover:enabled:bg-[#F8F8F8]",
40 "disabled:bg-[#F0F0F0]",
41 "[box-shadow:inset_0px_-2.108433723449707px_0px_0px_#E0E0E0,_0px_1.2048193216323853px_6.325301647186279px_0px_rgba(0,_0,_0,_10%)]",
42 "hover:enabled:[box-shadow:inset_0px_-2.53012px_0px_0px_#E8E8E8,_0px_1.44578px_7.59036px_0px_rgba(0,_0,_0,_12%)]",
43 "disabled:shadow-none",
44 "border",
45 "border-[#E0E0E0]",
46 "active:bg-[#F0F0F0]",
47 "active:[box-shadow:inset_0px_-1.5px_0px_0px_#D8D8D8,_0px_0.5px_2px_0px_rgba(0,_0,_0,_15%)]",
48 ],
49 danger: [
50 "bg-[#E6492D]",
51 "text-[#fff]",
52 "hover:enabled:bg-[#F05B41]",
53 "disabled:bg-[#F5A799]",
54 "[box-shadow:inset_0px_-2.108433723449707px_0px_0px_#D63A1F,_0px_1.2048193216323853px_6.325301647186279px_0px_rgba(214,_58,_31,_58%)]",
55 "hover:enabled:[box-shadow:inset_0px_-2.53012px_0px_0px_#E6492D,_0px_1.44578px_7.59036px_0px_rgba(214,_58,_31,_64%)]",
56 "disabled:shadow-none",
57 "active:bg-[#D63A1F]",
58 "active:[box-shadow:inset_0px_-1.5px_0px_0px_#B22E17,_0px_0.5px_2px_0px_rgba(214,_58,_31,_70%)]",
59 ],
60 },
61 size: {
62 small: ["text-xs", "py-1", "px-2", "h-9", "rounded-[8px]"],
63 medium: ["text-base", "py-2", "px-4", "h-11", "rounded-[9px]"],
64 large: ["text-lg", "py-3", "px-6", "h-14", "rounded-[11px]"],
65 },
66 fullWidth: {
67 true: "w-full",
68 },
69 },
70 compoundVariants: [
71 {
72 intent: ["default", "primary", "secondary", "danger"],
73 size: "medium",
74 className: "uppercase",
75 },
76 ],
77 defaultVariants: {
78 intent: "default",
79 size: "medium",
80 },
81 }
82)
83
84export interface NeumorphButtonProps
85 extends HTMLMotionProps<"button">,
86 VariantProps<typeof buttonVariants> {
87 children: React.ReactNode
88 loading?: boolean
89}
90
91const NeumorphButton: React.FC<NeumorphButtonProps> = ({
92 className,
93 intent,
94 size,
95 fullWidth,
96 children,
97 loading = false,
98 disabled,
99 ...props
100}) => {
101 return (
102 <motion.button
103 className={buttonVariants({ intent, size, fullWidth, className })}
104 disabled={disabled || loading}
105 whileTap={{ scale: 0.98 }}
106 whileHover={{ scale: 1.02 }}
107 transition={{ type: "spring", stiffness: 400, damping: 10 }}
108 {...props}
109 >
110 {loading ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null}
111 <motion.span
112 initial={{ opacity: 1 }}
113 animate={{ opacity: loading ? 0.7 : 1 }}
114 transition={{ duration: 0.2 }}
115 >
116 {children}
117 </motion.span>
118 </motion.button>
119 )
120}
121
122export default NeumorphButton
123