@flanksource/clicky-ui
Version:
Flanksource Clicky UI — React component library built on shadcn/ui with light/dark and density theming.
127 lines (126 loc) • 3.86 kB
JavaScript
import { jsx, jsxs } from "react/jsx-runtime";
import { Slot } from "@radix-ui/react-slot";
import { cva } from "class-variance-authority";
import { forwardRef } from "react";
import { cn } from "../lib/utils.js";
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-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: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline"
},
size: {
default: "h-control-h px-control-px py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-control-h w-control-h"
}
},
defaultVariants: {
variant: "default",
size: "default"
}
}
);
function ButtonSpinner() {
return /* @__PURE__ */ jsxs(
"svg",
{
xmlns: "http://www.w3.org/2000/svg",
width: "32",
height: "32",
viewBox: "0 0 24 24",
"aria-hidden": "true",
className: "h-4 w-4 shrink-0",
children: [
/* @__PURE__ */ jsx("circle", { cx: "4", cy: "12", r: "3", fill: "#151515", children: /* @__PURE__ */ jsx(
"animate",
{
id: "SVG7x14Dcom",
fill: "freeze",
attributeName: "opacity",
begin: "0;SVGqSjG0dUp.end-0.25s",
dur: "0.75s",
values: "1;0.2"
}
) }),
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3", fill: "#151515", opacity: "0.4", children: /* @__PURE__ */ jsx(
"animate",
{
fill: "freeze",
attributeName: "opacity",
begin: "SVG7x14Dcom.begin+0.15s",
dur: "0.75s",
values: "1;0.2"
}
) }),
/* @__PURE__ */ jsx("circle", { cx: "20", cy: "12", r: "3", fill: "#151515", opacity: "0.3", children: /* @__PURE__ */ jsx(
"animate",
{
id: "SVGqSjG0dUp",
fill: "freeze",
attributeName: "opacity",
begin: "SVG7x14Dcom.begin+0.3s",
dur: "0.75s",
values: "1;0.2"
}
) })
]
}
);
}
const Button = forwardRef(
({
children,
className,
disabled,
loading = false,
loadingLabel,
variant,
size,
asChild = false,
...props
}, ref) => {
const Comp = asChild ? Slot : "button";
const content = loadingLabel !== void 0 ? loadingLabel : children;
if (asChild) {
return /* @__PURE__ */ jsx(
Comp,
{
ref,
"aria-busy": loading || void 0,
className: cn(buttonVariants({ variant, size }), className),
disabled: disabled || loading,
...props,
children
}
);
}
return /* @__PURE__ */ jsxs(
Comp,
{
ref,
"aria-busy": loading || void 0,
className: cn(buttonVariants({ variant, size }), className),
disabled: disabled || loading,
...props,
children: [
loading && /* @__PURE__ */ jsx(ButtonSpinner, {}),
content
]
}
);
}
);
Button.displayName = "Button";
export {
Button,
buttonVariants
};
//# sourceMappingURL=button.js.map