ivt
Version:
Ivt Components Library
62 lines (59 loc) • 2.65 kB
JavaScript
import { Slot } from '@radix-ui/react-slot';
import { cva } from 'class-variance-authority';
import * as React from 'react';
import { c as cn } from './utils-05LlW3Cl.mjs';
const buttonVariants = cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 cursor-pointer", {
variants: {
variant: {
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
selection: "border border-input bg-accent text-accent-foreground hover:bg-accent/80",
upload: "bg-accent text-primary hover:bg-accent/80",
ghost: "hover:bg-body",
link: "text-primary underline-offset-4 hover:underline",
table: "text-inherit"
},
size: {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
normal: "h-fit",
"icon-sm": "size-8",
"icon-lg": "size-10"
}
},
defaultVariants: {
variant: "default",
size: "default"
}
});
const Button = /*#__PURE__*/ React.forwardRef(({ className, variant, size, asChild = false, isAction = false, subtle = false, ...props }, ref)=>{
const Comp = asChild ? Slot : "button";
const subtleStyles = (variant)=>{
switch(variant){
case "default":
return "bg-accent text-primary hover:bg-accent/80";
case "destructive":
return "bg-destructive-foreground text-destructive hover:bg-destructive-foreground/80";
case "outline":
return "bg-accent text-accent-foreground hover:bg-accent/80";
default:
return "";
}
};
const finalSubtleStyles = subtle ? subtleStyles(variant) : "";
return /*#__PURE__*/ React.createElement(Comp, {
className: cn(isAction && "min-w-20", buttonVariants({
variant,
size
}), finalSubtleStyles, className),
ref: ref,
...props
});
});
Button.displayName = "Button";
export { Button as B, buttonVariants as b };
//# sourceMappingURL=button-Co_1yLv6.mjs.map