"use client"; import { useRef, useState, useCallback, useId } from "react"; import { motion } from "motion/react"; export const TextHoverEffect = ({ text, }: { text: string; duration?: number; }) => { const svgRef = useRef(null); const [hovered, setHovered] = useState(false); const [cursorPos, setCursorPos] = useState({ x: 150, y: 30 }); const id = useId(); const gradientId = `textGradient-${id}`; const revealMaskId = `revealMask-${id}`; const textMaskId = `textMask-${id}`; const handleMouseMove = useCallback( (e: React.MouseEvent) => { if (!svgRef.current) return; const rect = svgRef.current.getBoundingClientRect(); // Map screen coords to viewBox coords (0 0 300 60) const x = ((e.clientX - rect.left) / rect.width) * 300; const y = ((e.clientY - rect.top) / rect.height) * 60; setCursorPos({ x, y }); }, [] ); return ( setHovered(true)} onMouseLeave={() => setHovered(false)} onMouseMove={handleMouseMove} className="select-none" > {/* Faint outline always visible */} {text} {/* Animated stroke draw */} {text} {/* Colored gradient revealed on hover */} {text} ); };