lightswind
Version:
A collection of beautifully crafted React Components, Blocks & Templates for Modern Developers. Create stunning web applications effortlessly by using our 160+ professional and animated react components.
80 lines • 3.67 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Button = void 0;
exports.buttonVariants = buttonVariants;
const jsx_runtime_1 = require("react/jsx-runtime");
const React = __importStar(require("react"));
const utils_1 = require("@/components/lib/utils");
// Define button style variants as a constant object (not exported)
const buttonStyles = {
variant: {
default: "btn-3d-default",
destructive: "btn-3d-destructive",
outline: "btn-3d-outline",
secondary: "btn-3d-secondary",
ghost: "btn-3d-ghost",
link: "btn-3d-link",
github: "btn-3d-github",
custom: "btn-3d-custom",
},
size: {
default: "h-10 px-4 py-2 rounded-lg",
sm: "h-9 px-3 rounded-md",
lg: "h-11 px-8 rounded-xl",
icon: "h-10 w-10 rounded-lg",
unstyled: "",
}
};
// Define the buttonVariants function (exported)
function buttonVariants(options = {}) {
const { variant = "default", size = "default", className } = options;
return (0, utils_1.cn)("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", buttonStyles.variant[variant], buttonStyles.size[size], className);
}
const Button = React.forwardRef(({ className, variant = "default", size = "default", asChild = false, ...props }, ref) => {
if (asChild) {
return ((0, jsx_runtime_1.jsx)(React.Fragment, { children: React.Children.map(props.children, child => {
if (React.isValidElement(child)) {
// Instead of cloneElement with complex props, use a wrapper
return ((0, jsx_runtime_1.jsx)("span", { className: buttonVariants({ variant, size, className }), children: child }));
}
return child;
}) }));
}
return ((0, jsx_runtime_1.jsx)("button", { className: buttonVariants({ variant, size, className }), ref: ref, ...props }));
});
exports.Button = Button;
Button.displayName = "Button";
//# sourceMappingURL=button.js.map