import React, { useEffect, useRef } from 'react'; import gsap from 'gsap'; const ProjectModal = ({ project, onClose }) => { const modalRef = useRef(null); const overlayRef = useRef(null); const contentRef = useRef(null); useEffect(() => { const ctx = gsap.context(() => { // Animation In gsap.fromTo(overlayRef.current, { opacity: 0 }, { opacity: 1, duration: 0.5, ease: "power2.out" } ); gsap.fromTo(contentRef.current, { y: 100, opacity: 0, scale: 0.95 }, { y: 0, opacity: 1, scale: 1, duration: 0.5, delay: 0.1, ease: "power3.out" } ); }, modalRef); // Prevent body scroll document.body.style.overflow = 'hidden'; return () => { ctx.revert(); document.body.style.overflow = ''; // Restore scroll }; }, []); const handleClose = () => { // Animation Out manually before unmounting gsap.to(contentRef.current, { y: 50, opacity: 0, duration: 0.3, ease: "power2.in" }); gsap.to(overlayRef.current, { opacity: 0, duration: 0.3, onComplete: onClose }); }; if (!project) return null; return (
{/* Overlay */}
{/* Modal Content */}
{/* Close Button */}
{/* Left: Image / Visual */}
{project.image ? ( {project.name} ) : (

{project.name ? project.name.substring(0, 2).toUpperCase() : 'MJ'}

)}
{/* Right: Info */}
{project.price}

{project.name}

{project.details || project.desc || "No details available."}

Type

{project.language || 'Design / Resource'}

); }; export default ProjectModal;