"use client"; import { useEffect, useRef } from "react"; export default function DragonEye({ size = 60 }: { size?: number }) { const irisRef = useRef(null); useEffect(() => { const handleMouseMove = (e: MouseEvent) => { if (!irisRef.current) return; const rect = irisRef.current.parentElement!.getBoundingClientRect(); const cx = rect.left + rect.width / 2; const cy = rect.top + rect.height / 2; const dx = e.clientX - cx; const dy = e.clientY - cy; const dist = Math.sqrt(dx * dx + dy * dy); const max = 5; const mx = (dx / Math.max(dist, 1)) * Math.min(dist * 0.1, max); const my = (dy / Math.max(dist, 1)) * Math.min(dist * 0.1, max); irisRef.current.style.transform = `translate(calc(-50% + ${mx}px), calc(-50% + ${my}px))`; }; window.addEventListener("mousemove", handleMouseMove); return () => window.removeEventListener("mousemove", handleMouseMove); }, []); const h = size; const w = size * 1.6; return (
{/* Outer glow */}
{/* Eye shape */}
{/* Iris */}
{/* Pupil */}
{/* Highlight */}
{/* Eyelid top */}
{/* Eyelid bottom */}
); }