/** * PWA Loading Overlay Component * * Displays a "We prepare a demo" overlay during first load * with pulsating animation and progress tracking for asset preloading. * Uses project theme colors from theme_config_json when available. */ import React, { useEffect, useState } from 'react'; type PWALoadingOverlayProps = { isVisible: boolean; progress: number; // 0-100 projectName?: string; themeConfig?: { primaryColor?: string; backgroundColor?: string; textColor?: string; }; onComplete?: () => void; }; const PWALoadingOverlay: React.FC = ({ isVisible, progress, projectName, themeConfig, onComplete, }) => { const [shouldRender, setShouldRender] = useState(isVisible); // Handle fade-out animation before unmounting useEffect(() => { if (!isVisible && shouldRender) { const timer = setTimeout(() => { setShouldRender(false); onComplete?.(); }, 500); // Match CSS transition duration return () => clearTimeout(timer); } if (isVisible) { setShouldRender(true); } }, [isVisible, shouldRender, onComplete]); if (!shouldRender) return null; const primaryColor = themeConfig?.primaryColor || '#3b82f6'; const backgroundColor = themeConfig?.backgroundColor || '#1f2937'; const textColor = themeConfig?.textColor || '#ffffff'; return (
{/* Pulsating logo/spinner */}
{/* Project name */} {projectName && (

{projectName}

)} {/* Loading message */}

We prepare a demo

{/* Progress bar */}
{/* Progress percentage */}

{Math.round(progress)}%

{/* Loading indicator dots */}
{[0, 1, 2].map((index) => (
))}
); }; export default PWALoadingOverlay;