UNPKG

@arolariu/components

Version:

🎨 60+ beautiful, accessible React components built on Radix UI. TypeScript-first, tree-shakeable, SSR-ready. Perfect for modern web apps, design systems & rapid prototyping. Zero config, maximum flexibility! ⚡

100 lines (99 loc) • 4.1 kB
"use client"; "use strict"; var __webpack_require__ = {}; (()=>{ __webpack_require__.d = (exports1, definition)=>{ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, { enumerable: true, get: definition[key] }); }; })(); (()=>{ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); })(); (()=>{ __webpack_require__.r = (exports1)=>{ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, { value: 'Module' }); Object.defineProperty(exports1, '__esModule', { value: true }); }; })(); var __webpack_exports__ = {}; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { FlipButton: ()=>FlipButton }); const jsx_runtime_namespaceObject = require("react/jsx-runtime"); const external_react_namespaceObject = require("react"); const react_namespaceObject = require("motion/react"); const utils_cjs_namespaceObject = require("../../lib/utils.cjs"); const defaultSpanClassName = "absolute inset-0 flex items-center justify-center rounded-lg"; const FlipButton = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ frontText, backText, transition = { type: "spring", stiffness: 280, damping: 20 }, className, frontClassName, backClassName, from = "top", ...props }, ref)=>{ const isVertical = "top" === from || "bottom" === from; const rotateAxis = isVertical ? "rotateX" : "rotateY"; const frontOffset = "top" === from || "left" === from ? "50%" : "-50%"; const backOffset = "top" === from || "left" === from ? "-50%" : "50%"; const buildVariant = (opacity, rotation, offset = null)=>({ opacity, [rotateAxis]: rotation, ...isVertical && null !== offset ? { y: offset } : {}, ...!isVertical && null !== offset ? { x: offset } : {} }); const frontVariants = { initial: buildVariant(1, 0, "0%"), hover: buildVariant(0, 90, frontOffset) }; const backVariants = { initial: buildVariant(0, 90, backOffset), hover: buildVariant(1, 0, "0%") }; return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(react_namespaceObject.motion.button, { ref: ref, initial: "initial", whileHover: "hover", whileTap: { scale: 0.95 }, className: (0, utils_cjs_namespaceObject.cn)("relative inline-block h-10 px-4 py-2 text-sm font-medium cursor-pointer perspective-[1000px] focus:outline-none", className), ...props, children: [ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.motion.span, { variants: frontVariants, transition: transition, className: (0, utils_cjs_namespaceObject.cn)(defaultSpanClassName, "bg-muted text-black dark:text-white", frontClassName), children: frontText }), /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.motion.span, { variants: backVariants, transition: transition, className: (0, utils_cjs_namespaceObject.cn)(defaultSpanClassName, "bg-primary text-primary-foreground", backClassName), children: backText }), /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", { className: "invisible", children: frontText }) ] }); }); FlipButton.displayName = "FlipButton"; exports.FlipButton = __webpack_exports__.FlipButton; for(var __webpack_i__ in __webpack_exports__)if (-1 === [ "FlipButton" ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__]; Object.defineProperty(exports, '__esModule', { value: true }); //# sourceMappingURL=flip-button.cjs.map