"use client"; import React, { useRef, MouseEvent, useId } from "react"; import { cn } from "@/app/component2/utils"; interface MagicCardProps extends React.HTMLAttributes { imageUrl: string; title: string; icon?: React.ReactNode; } export const MagicCard = ({ imageUrl, title, icon, className, ...props }: MagicCardProps) => { const cardRef = useRef(null); const id = useId(); // Sanitize ID for use in URL const filterId = `magic-card-blur-${id.replace(/:/g, '')}`; const handleMouseMove = (e: MouseEvent) => { const card = cardRef.current; if (!card) return; const rect = card.getBoundingClientRect(); const centerX = rect.left + rect.width / 2; const centerY = rect.top + rect.height / 2; const relativeX = e.clientX - centerX; const relativeY = e.clientY - centerY; // Normalize to -1 to 1 range const x = (relativeX / (rect.width / 2)).toFixed(3); const y = (relativeY / (rect.height / 2)).toFixed(3); card.style.setProperty('--pointer-x', x); card.style.setProperty('--pointer-y', y); }; const handleMouseLeave = () => { const card = cardRef.current; if (!card) return; // Reset to default "off-screen" position, matching the default fallback card.style.setProperty('--pointer-x', '-10'); card.style.setProperty('--pointer-y', '-10'); }; return (
{/* Inner Content Wrapper */}
{/* Magic Image Layer (Effect) */}
{/* Main Image */} {/* Title */}

{title}

{/* Border/Glass Effect */}
{/* SVG Filter Definition */}
); };