import { useEffect, useRef, useState } from 'react'; /** * Mouse-tracking radial glow overlay for cards. * * Usage: Place as the first child of a `relative overflow-hidden` container. * The glow follows the cursor within the card and fades on mouse leave. */ export function GlowTracker() { const ref = useRef(null); const [pos, setPos] = useState({ x: 0, y: 0 }); const [visible, setVisible] = useState(false); useEffect(() => { const parent = ref.current?.parentElement; if (!parent) return; const handleMove = (e: MouseEvent) => { const rect = parent.getBoundingClientRect(); setPos({ x: e.clientX - rect.left, y: e.clientY - rect.top }); }; const handleEnter = () => setVisible(true); const handleLeave = () => setVisible(false); parent.addEventListener('mousemove', handleMove); parent.addEventListener('mouseenter', handleEnter); parent.addEventListener('mouseleave', handleLeave); return () => { parent.removeEventListener('mousemove', handleMove); parent.removeEventListener('mouseenter', handleEnter); parent.removeEventListener('mouseleave', handleLeave); }; }, []); return (
); }