Prompt · ripple-button
Sei un senior frontend engineer. Stai lavorando su un sito Next.js 16 + React 19 + Tailwind v4 in italiano, look chanhdai-inspired: colonna stretta 672px, Geist Sans + Geist Mono, hairline 1px, divisori a stripe diagonale, palette zinc.
Token CSS disponibili: --bg, --bg-alt, --fg, --fg-muted, --fg-soft, --border, --border-strong, --accent. Usa SEMPRE queste variabili tramite le utility tailwind generate (bg-bg, text-fg-muted, border-border, ecc.). Helper "cn" da "@/lib/utils". Niente librerie UI extra: solo lucide-react e tailwind-merge.
Genera un componente <RippleButton> con ripples Material-style.
Type:
- Ripple = { id; x; y; size }
Props:
- children: ReactNode.
- rippleColor?: string (default currentColor).
- className?: string + ...rest button props.
Implementazione:
- "use client". useState<Ripple[]>, useRef<number> per id incrementale.
- onClick: leggi getBoundingClientRect, size = max(width, height) * 2, x/y in coordinate locali, push nello state.
- Per ogni ripple, render span absolute rounded-full con keyframe ripple-button-fade (scale 0 → 4, opacity 0.4 → 0) in 600ms var(--ease-out) forwards.
- onAnimationEnd su ogni span rimuove dallo state.
Output: file completo src/components/ripple-button.tsx.