fx-1 / src /components /ui /button.tsx
felix-fx's picture
Initial commit from GitHub fx-1
6711fd5 verified
Raw History Blame Contribute Delete
3.57 kB
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 justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all 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",
{
variants: {
variant: {
default: "primary-gradient text-primary-foreground hover:shadow-2xl hover:scale-105 glow-effect transition-all duration-300",
destructive: "bg-gradient-to-r from-red-600 to-red-700 text-white hover:from-red-700 hover:to-red-800 shadow-lg hover:shadow-xl transition-all duration-300",
outline: "border-2 border-primary/30 bg-transparent hover:bg-primary/10 hover:border-primary/60 hover:text-primary transition-all duration-300",
secondary: "bg-gradient-to-r from-secondary to-secondary/80 text-secondary-foreground hover:from-secondary/80 hover:to-secondary shadow-md hover:shadow-lg transition-all duration-300",
ghost: "hover:bg-accent/20 hover:text-accent-foreground hover:shadow-md transition-all duration-300",
link: "text-primary underline-offset-4 hover:underline hover:text-primary-glow transition-all duration-300",
hero: "primary-gradient text-primary-foreground font-minecraft text-sm px-8 py-4 rounded-xl hover:scale-110 animate-glow-pulse border-2 border-primary-glow/30 shadow-2xl hover:shadow-primary/50 transition-all duration-500",
minecraft: "bg-gradient-to-r from-secondary to-accent text-secondary-foreground border-2 border-accent hover:from-accent hover:to-primary hover:text-accent-foreground font-minecraft text-xs shadow-lg hover:shadow-xl transition-all duration-300",
upload: "accent-gradient text-accent-foreground hover:shadow-2xl hover:scale-110 border border-accent/50 font-semibold transition-all duration-300",
modern: "bg-gradient-to-r from-slate-800 to-slate-900 text-white hover:from-slate-700 hover:to-slate-800 shadow-lg hover:shadow-xl border border-slate-600 transition-all duration-300",
premium: "bg-gradient-to-r from-yellow-500 via-yellow-600 to-yellow-700 text-yellow-50 hover:from-yellow-400 hover:via-yellow-500 hover:to-yellow-600 shadow-lg hover:shadow-yellow-500/25 transition-all duration-300",
neon: "bg-gradient-to-r from-cyan-500 to-blue-500 text-white hover:from-cyan-400 hover:to-blue-400 shadow-lg shadow-cyan-500/25 hover:shadow-cyan-500/40 transition-all duration-300",
},
size: {
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 rounded-md px-8",
hero: "h-14 px-10 py-4 text-base rounded-xl",
icon: "h-10 w-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
)
}
)
Button.displayName = "Button"
export { Button, buttonVariants }