72 lines
3.2 KiB
Markdown
72 lines
3.2 KiB
Markdown
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-lg text-sm font-medium transition-all duration-300 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 cursor-pointer",
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default: "bg-primary text-primary-foreground border-none",
|
|
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
secondary: "text-secondary-foreground border border-border",
|
|
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
link: "text-primary underline-offset-4 hover:underline",
|
|
hero: "bg-primary text-primary-foreground border-none text-base font-semibold tracking-wide",
|
|
},
|
|
size: {
|
|
default: "h-10 px-5 py-2",
|
|
sm: "h-9 rounded-lg px-3",
|
|
lg: "h-12 rounded-lg px-8 text-base",
|
|
xl: "h-14 rounded-xl px-10 text-lg",
|
|
icon: "h-10 w-10",
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: "default",
|
|
size: "default",
|
|
},
|
|
},
|
|
);
|
|
|
|
const primaryShadow = "rgba(0,0,0,0.2) 0px 3px 1px 0px inset, rgba(206,231,255,0.13) 0px 0.839802px 0.503881px -0.3125px, rgba(206,231,255,0.13) 0px 1.99048px 1.19429px -0.625px, rgba(206,231,255,0.13) 0px 3.63084px 2.1785px -0.9375px, rgba(206,231,255,0.13) 0px 6.03627px 3.62176px -1.25px, rgba(206,231,255,0.13) 0px 9.74808px 5.84885px -1.5625px, rgba(206,231,255,0.13) 0px 15.9566px 9.57398px -1.875px, rgba(206,231,255,0.13) 0px 27.4762px 16.4857px -2.1875px, rgba(206,231,255,0.13) 0px 50px 30px -2.5px";
|
|
|
|
const secondaryBg = "linear-gradient(rgba(83,83,83,0.05) 0%, transparent 59.26%), linear-gradient(#000000, #000000), linear-gradient(#000000, #000000), linear-gradient(rgba(83,83,83,0.05) 0%, transparent 59.26%), linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), #000000";
|
|
|
|
const secondaryShadow = "2.10837px 3.16256px 9.48767px rgba(83,83,83,0.1)";
|
|
|
|
export interface ButtonProps
|
|
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
VariantProps<typeof buttonVariants> {
|
|
asChild?: boolean;
|
|
}
|
|
|
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
({ className, variant, size, asChild = false, style, ...props }, ref) => {
|
|
const Comp = asChild ? Slot : "button";
|
|
|
|
const variantStyle: React.CSSProperties = {};
|
|
if (variant === "default" || variant === "hero" || !variant) {
|
|
variantStyle.boxShadow = primaryShadow;
|
|
}
|
|
if (variant === "secondary") {
|
|
variantStyle.background = secondaryBg;
|
|
variantStyle.boxShadow = secondaryShadow;
|
|
}
|
|
|
|
return (
|
|
<Comp
|
|
className={cn(buttonVariants({ variant, size, className }))}
|
|
ref={ref}
|
|
style={{ ...variantStyle, ...style }}
|
|
{...props}
|
|
/>
|
|
);
|
|
},
|
|
);
|
|
Button.displayName = "Button";
|
|
|
|
export { Button, buttonVariants };
|