"use client"; import { useRef, useState, type ReactNode } from "react"; import { motion, useReducedMotion } from "motion/react"; type RippleCoreProps = { children: ReactNode; className?: string; onClick?: () => void; /** Colour of the ripple. */ color?: string; /** Seconds one ripple lasts. */ duration?: number; }; type Ripple = { id: number; x: number; y: number; r: number }; /* RippleCore: every press sends a ripple out from the exact point you touched. Keyboard presses ripple from the centre. */ export function RippleCore({ children, className = "rounded-xl bg-[#a78bfa] px-9 py-4 text-[15px] font-medium text-[#1a1530]", onClick, color = "rgba(255,255,255,0.55)", duration = 0.6, }: RippleCoreProps) { const reduce = useReducedMotion(); const [ripples, setRipples] = useState([]); const next = useRef(0); const add = (el: HTMLElement, x: number, y: number) => { if (reduce) return; const { width: w, height: h } = el.getBoundingClientRect(); const r = Math.hypot(Math.max(x, w - x), Math.max(y, h - y)); setRipples((rs) => [...rs, { id: next.current++, x, y, r }]); }; return ( ); }