Spaces:
Runtime error
Runtime error
Download frontend/src/components/StepCapture.tsx from npisb/pipecountapp-dev: direct link, hf CLI and curl.
- Browser
- Download file 6.75 kB
-
https://huggingface.co/spaces/npisb/pipecountapp-dev/resolve/main/frontend/src/components/StepCapture.tsx
- Command line
-
hf download hf://spaces/npisb/pipecountapp-dev/frontend/src/components/StepCapture.tsx
-
curl -L -o StepCapture.tsx https://huggingface.co/spaces/npisb/pipecountapp-dev/resolve/main/frontend/src/components/StepCapture.tsx
6.75 kB
| import { AlertTriangle, Camera, ImagePlus, RotateCcw } from 'lucide-react' | |
| import { ASSETS } from '../lib/assets' | |
| import { t } from '../lib/i18n' | |
| import type { Lang } from '../lib/types' | |
| type Engine = 'checking' | 'local' | 'server' | 'none' | |
| interface Props { | |
| lang: Lang | |
| engine: Engine | |
| modelError?: string | |
| onRetryModel?: () => void | |
| onCamera: () => void | |
| onGallery: () => void | |
| } | |
| export function StepCapture({ lang, engine, modelError, onRetryModel, onCamera, onGallery }: Props) { | |
| const hasError = engine === 'none' || Boolean(modelError) | |
| const ready = engine === 'local' || engine === 'server' | |
| return ( | |
| <div className="grain relative flex flex-1 flex-col overflow-hidden"> | |
| <img | |
| src={ASSETS.bg} | |
| alt="" | |
| aria-hidden | |
| className="absolute inset-0 h-full w-full object-cover" | |
| /> | |
| <div | |
| className="absolute inset-0" | |
| style={{ background: 'linear-gradient(180deg, rgba(0,73,115,0.88) 0%, rgba(0,49,77,0.92) 100%)' }} | |
| /> | |
| <div className="relative z-10 flex flex-1 flex-col items-center justify-center px-8"> | |
| <div className="mb-10 flex flex-col items-center gap-6"> | |
| {/* Logo + live status dot — staggered entrance */} | |
| <div className="rise-enter relative" style={{ animationDelay: '0ms' }}> | |
| <span | |
| aria-hidden | |
| className="pointer-events-none absolute left-1/2 top-1/2 h-32 w-32 -translate-x-1/2 -translate-y-1/2 rounded-full blur-2xl" | |
| style={{ background: 'radial-gradient(circle, rgba(255,255,255,0.22), transparent 70%)' }} | |
| /> | |
| <img | |
| src={ASSETS.logo} | |
| alt="" | |
| className="relative h-[72px] w-auto max-w-[220px]" | |
| style={{ | |
| animation: 'breathe 3.5s ease-in-out infinite', | |
| filter: 'drop-shadow(0 10px 26px rgba(0,0,0,0.32))', | |
| }} | |
| /> | |
| <span | |
| className={`absolute -right-2 -top-1 h-5 w-5 rounded-full border-[3px] border-[#00314d] transition-all duration-700 ${ | |
| engine === 'none' | |
| ? 'bg-[var(--danger)]' | |
| : ready | |
| ? 'bg-[var(--success)]' | |
| : 'animate-pulse bg-[var(--warning)]' | |
| }`} | |
| style={{ boxShadow: 'var(--shadow-sm)' }} | |
| /> | |
| </div> | |
| {/* Title block */} | |
| <div className="rise-enter text-center" style={{ animationDelay: '60ms' }}> | |
| <h1 | |
| className="text-white" | |
| style={{ | |
| font: 'var(--type-h1)', | |
| letterSpacing: 'var(--tracking-tight)', | |
| textShadow: '0 2px 14px rgba(0,0,0,0.20)', | |
| }} | |
| > | |
| {t(lang, 'title')} | |
| </h1> | |
| <p | |
| className="mt-2 text-white/70" | |
| style={{ font: 'var(--type-body)' }} | |
| > | |
| {t(lang, 'captureSubtitle')} | |
| </p> | |
| </div> | |
| {/* Status badge / retry — premium glass treatment */} | |
| {hasError ? ( | |
| <button | |
| type="button" | |
| onClick={onRetryModel} | |
| className="rise-enter ct-badge ct-badge--danger" | |
| style={{ animationDelay: '120ms', boxShadow: 'var(--shadow-sm)' }} | |
| > | |
| <RotateCcw size={12} /> | |
| {t(lang, 'retry')} | |
| </button> | |
| ) : ( | |
| <div | |
| className="rise-enter ct-badge backdrop-blur-md" | |
| style={{ | |
| animationDelay: '120ms', | |
| border: '1px solid rgba(255,255,255,0.18)', | |
| background: ready ? 'rgba(255,255,255,0.16)' : 'rgba(255,255,255,0.10)', | |
| color: ready ? '#fff' : 'rgba(255,255,255,0.9)', | |
| boxShadow: 'var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.22)', | |
| }} | |
| > | |
| <span | |
| className={`h-1.5 w-1.5 rounded-full ${ | |
| ready ? 'bg-[var(--success)]' : 'animate-pulse bg-[var(--warning)]' | |
| }`} | |
| /> | |
| {ready ? t(lang, 'modelReady') : t(lang, 'loadingModel')} | |
| </div> | |
| )} | |
| </div> | |
| {hasError && ( | |
| <div | |
| className="overlay-enter mb-4 w-full max-w-sm border border-red-300/40 bg-white/95 p-4" | |
| style={{ | |
| borderRadius: 'var(--r-xl)', | |
| boxShadow: 'var(--shadow-lg)', | |
| animationDelay: '120ms', | |
| }} | |
| > | |
| <div className="flex items-start gap-2.5"> | |
| <AlertTriangle size={18} className="mt-0.5 shrink-0 text-[var(--danger)]" /> | |
| <div className="min-w-0"> | |
| <p className="text-sm font-semibold text-[var(--danger)]">{t(lang, 'modelErrorTitle')}</p> | |
| <p className="mt-1 break-words text-xs text-[var(--text-dim)]">{modelError}</p> | |
| <button | |
| type="button" | |
| onClick={onRetryModel} | |
| className="mt-3 flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-white" | |
| style={{ background: 'var(--danger)', borderRadius: 'var(--r-md)', boxShadow: 'var(--shadow-sm)' }} | |
| > | |
| <RotateCcw size={13} /> | |
| {t(lang, 'retry')} | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| )} | |
| {/* CTA column — staggered last */} | |
| <div className="rise-enter w-full max-w-sm space-y-3" style={{ animationDelay: '180ms' }}> | |
| <button | |
| type="button" | |
| disabled={hasError} | |
| className="ct-btn-primary" | |
| onClick={onCamera} | |
| > | |
| <Camera size={22} strokeWidth={2.5} /> | |
| {t(lang, 'takePhoto')} | |
| </button> | |
| <button | |
| type="button" | |
| disabled={hasError} | |
| className="flex min-h-14 w-full items-center justify-center gap-3 bg-white/10 text-white backdrop-blur-md transition-all active:scale-[0.98] active:bg-white/20 disabled:opacity-50 disabled:active:scale-100" | |
| onClick={onGallery} | |
| style={{ | |
| borderRadius: 'var(--r-lg)', | |
| border: '1px solid rgba(255,255,255,0.20)', | |
| fontSize: 'var(--text-md)', | |
| fontWeight: 'var(--weight-semibold)', | |
| letterSpacing: 'var(--tracking-snug)', | |
| boxShadow: 'var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.18)', | |
| }} | |
| > | |
| <ImagePlus size={22} strokeWidth={2} /> | |
| {t(lang, 'chooseFile')} | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| ) | |
| } | |