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! ⚡

108 lines (107 loc) • 4.11 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__, { RippleButton: ()=>RippleButton }); 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 RippleButton = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ children, onClick, className, rippleClassName, scale = 10, transition = { duration: 0.6, ease: "easeOut" }, ...props }, ref)=>{ const [ripples, setRipples] = external_react_namespaceObject.useState([]); const buttonRef = external_react_namespaceObject.useRef(null); external_react_namespaceObject.useImperativeHandle(ref, ()=>buttonRef.current); const createRipple = external_react_namespaceObject.useCallback((event)=>{ const button = buttonRef.current; if (!button) return; const rect = button.getBoundingClientRect(); const x = event.clientX - rect.left; const y = event.clientY - rect.top; const newRipple = { id: Date.now(), x, y }; setRipples((prev)=>[ ...prev, newRipple ]); setTimeout(()=>{ setRipples((prev)=>prev.filter((r)=>r.id !== newRipple.id)); }, 600); }, []); const handleClick = external_react_namespaceObject.useCallback((event)=>{ createRipple(event); if (onClick) onClick(event); }, [ createRipple, onClick ]); return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(react_namespaceObject.motion.button, { ref: buttonRef, onClick: handleClick, whileTap: { scale: 0.95 }, whileHover: { scale: 1.05 }, className: (0, utils_cjs_namespaceObject.cn)("relative h-10 px-4 py-2 text-sm font-medium text-primary-foreground overflow-hidden bg-primary cursor-pointer rounded-lg focus:outline-none", className), ...props, children: [ children, ripples.map((ripple)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.motion.span, { initial: { scale: 0, opacity: 0.5 }, animate: { scale, opacity: 0 }, transition: transition, className: (0, utils_cjs_namespaceObject.cn)("absolute bg-primary-foreground rounded-full size-5 pointer-events-none", rippleClassName), style: { top: ripple.y - 10, left: ripple.x - 10 } }, ripple.id)) ] }); }); RippleButton.displayName = "RippleButton"; exports.RippleButton = __webpack_exports__.RippleButton; for(var __webpack_i__ in __webpack_exports__)if (-1 === [ "RippleButton" ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__]; Object.defineProperty(exports, '__esModule', { value: true }); //# sourceMappingURL=ripple-button.cjs.map