'use client'; import { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; interface PolycamEmbedProps { captureId: string; title: string; index?: number; } export function PolycamEmbed({ captureId, title, index = 0 }: PolycamEmbedProps) { const [isFullscreen, setIsFullscreen] = useState(false); const [isLoading, setIsLoading] = useState(true); const [hasError, setHasError] = useState(false); const [isDesktop, setIsDesktop] = useState(true); useEffect(() => { const checkDesktop = () => { setIsDesktop(window.innerWidth >= 1024); }; checkDesktop(); window.addEventListener('resize', checkDesktop); return () => window.removeEventListener('resize', checkDesktop); }, []); const itemVariants = { hidden: { opacity: 0, y: 20, }, visible: { opacity: 1, y: 0, }, }; return ( <> {/* Regular Embed */} {/* Loading Skeleton */} {isLoading && !hasError && ( )} {/* Error State */} {hasError && ( Failed to load 3D scan Please try again later )} setIsLoading(false)} onError={() => { setIsLoading(false); setHasError(true); }} aria-label={`3D scan viewer: ${title}`} /> {/* Fullscreen Button */} setIsFullscreen(true)} className="absolute top-4 left-4 p-2 rounded-lg bg-black/70 hover:bg-black/85 transition-colors z-10" whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.95 }} aria-label="Open fullscreen view" > {/* Title */} {title && ( {title} )} {/* Fullscreen Modal */} {isFullscreen && ( setIsFullscreen(false)} role="dialog" aria-modal="true" aria-label="Fullscreen 3D scan viewer" > e.stopPropagation()} > {/* Close Button */} setIsFullscreen(false)} className="absolute top-4 left-4 p-2 rounded-lg bg-black/70 hover:bg-black/85 transition-colors" whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.95 }} aria-label="Close fullscreen view" > )} > ); }
Failed to load 3D scan
Please try again later