diff --git a/frontend/src/components/root/expand-card.tsx b/frontend/src/components/root/expand-card.tsx new file mode 100644 index 00000000..1095aacc --- /dev/null +++ b/frontend/src/components/root/expand-card.tsx @@ -0,0 +1,173 @@ +'use client'; +import Image from 'next/image'; +import React, { useEffect, useRef, useState } from 'react'; +import { AnimatePresence, motion } from 'framer-motion'; +import { X } from 'lucide-react'; + +export function ExpandableCard({ projects }) { + const [active, setActive] = useState(null); + const [iframeUrl, setIframeUrl] = useState(''); + const ref = useRef(null); + + useEffect(() => { + function onKeyDown(event: KeyboardEvent) { + if (event.key === 'Escape') { + setActive(null); + } + } + + if (active && typeof active === 'object') { + document.body.style.overflow = 'hidden'; + } else { + document.body.style.overflow = 'auto'; + } + + window.addEventListener('keydown', onKeyDown); + return () => window.removeEventListener('keydown', onKeyDown); + }, [active]); + + const getWebUrl = async (project) => { + if (!project) return; + console.log('project:', project); + const projectPath = project.path; + + try { + const response = await fetch( + `/api/runProject?projectPath=${encodeURIComponent(projectPath)}`, + { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + } + ); + const json = await response.json(); + const baseUrl = `http://${json.domain}`; + setIframeUrl(baseUrl); + setActive(project); + } catch (error) { + console.error('fetching url error:', error); + } + }; + + return ( + <> + + {active && ( + setActive(null)} + initial={{ opacity: 0 }} + animate={{ opacity: 1 }} + exit={{ opacity: 0 }} + transition={{ + duration: 0.3, + ease: [0.4, 0, 0.2, 1], + }} + className="fixed inset-0 backdrop-blur-[2px] bg-black/20 h-full w-full z-50" + style={{ willChange: 'opacity' }} + /> + )} + + + + {active ? ( +
+ setActive(null)} + > + + + + + + + + {active.name} + + +