import { useEffect, useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { CheckCircle, Loader2 } from 'lucide-react'; interface Props { handDetected: boolean; onReady: () => void; } const STABLE_DURATION_MS = 1000; // hand must be visible for this long /** * Brief calibration screen shown after onboarding. * Waits until a hand is stable in frame, then auto-transitions. */ export function Calibration({ handDetected, onReady }: Props) { const [stableMs, setStableMs] = useState(0); const [done, setDone] = useState(false); useEffect(() => { if (!handDetected) { setStableMs(0); return; } const interval = setInterval(() => { setStableMs(prev => { const next = prev + 100; if (next >= STABLE_DURATION_MS && !done) { setDone(true); setTimeout(onReady, 600); // brief pause before transitioning } return next; }); }, 100); return () => clearInterval(interval); }, [handDetected, done, onReady]); const progress = Math.min((stableMs / STABLE_DURATION_MS) * 100, 100); const isChecked = done; return ( /* Transparent outer overlay — camera feed stays fully visible behind */
{/* Compact card anchored at the bottom so the camera is unobstructed */} Ready? {handDetected ? 'Hand detected — hold steady…' : 'Show your hand to the camera above.'} {/* Circular progress / check */}
{isChecked ? ( ) : ( )}

{isChecked ? 'All set!' : 'Keep your hand visible for 1 second'}

); }