Spaces:
Runtime error
Runtime error
Khunndev
Sisyphus
Polish the crop and preview screens with type presets and mono dimension readouts.
13ef64d Download frontend/src/components/StepPreview.tsx from npisb/pipecountapp-dev: direct link, hf CLI and curl.
- Browser
- Download file 2.9 kB
-
https://huggingface.co/spaces/npisb/pipecountapp-dev/resolve/main/frontend/src/components/StepPreview.tsx
- Command line
-
hf download hf://spaces/npisb/pipecountapp-dev/frontend/src/components/StepPreview.tsx
-
curl -L -o StepPreview.tsx https://huggingface.co/spaces/npisb/pipecountapp-dev/resolve/main/frontend/src/components/StepPreview.tsx
2.9 kB
| import { Camera, ChevronLeft, ImagePlus, Loader2 } from 'lucide-react' | |
| import { t } from '../lib/i18n' | |
| import type { Lang } from '../lib/types' | |
| interface Props { | |
| lang: Lang | |
| imageSrc: string | |
| imageDims: { w: number; h: number } | |
| busy: boolean | |
| modelReady: boolean | |
| onBack: () => void | |
| onRetake: () => void | |
| onGallery: () => void | |
| onCount: () => void | |
| } | |
| export function StepPreview({ | |
| lang, | |
| imageSrc, | |
| imageDims, | |
| busy, | |
| modelReady, | |
| onBack, | |
| onRetake, | |
| onGallery, | |
| onCount, | |
| }: Props) { | |
| const ar = imageDims.h / Math.max(imageDims.w, 1) | |
| const maxPreviewH = Math.min(ar * 100, 62) | |
| return ( | |
| <div className="flex flex-1 flex-col overflow-hidden bg-[var(--bg)]"> | |
| <div className="flex items-center justify-between px-4 py-2.5"> | |
| <button | |
| type="button" | |
| className="ct-btn-ghost rise-enter flex h-9 items-center gap-1 px-3 text-sm" | |
| style={{ animationDelay: '0.04s' }} | |
| onClick={onBack} | |
| > | |
| <ChevronLeft size={16} strokeWidth={2.5} /> | |
| {t(lang, 'previewBack')} | |
| </button> | |
| <div className="rise-enter flex gap-2" style={{ animationDelay: '0.1s' }}> | |
| <button type="button" className="ct-btn-ghost h-9 w-9" onClick={onRetake} aria-label={t(lang, 'retake')}> | |
| <Camera size={17} /> | |
| </button> | |
| <button type="button" className="ct-btn-ghost h-9 w-9" onClick={onGallery} aria-label={t(lang, 'chooseFile')}> | |
| <ImagePlus size={17} /> | |
| </button> | |
| </div> | |
| </div> | |
| <div className="flex flex-1 flex-col px-4"> | |
| <div | |
| className="rise-enter overflow-hidden rounded-2xl border border-[var(--hairline)] bg-black shadow-[var(--shadow-lg)] ring-1 ring-black/5" | |
| style={{ flex: '1 1 auto', minHeight: '40vh', maxHeight: `${maxPreviewH}vh`, animationDelay: '0.16s' }} | |
| > | |
| <img src={imageSrc} alt="Preview" className="h-full w-full object-contain" /> | |
| </div> | |
| <p | |
| className="rise-enter mt-2 text-center text-[11px] tabular-nums text-[var(--text-faint)]" | |
| style={{ fontFamily: 'var(--font-mono)', animationDelay: '0.22s' }} | |
| > | |
| {imageDims.w} × {imageDims.h} | |
| </p> | |
| </div> | |
| <div | |
| className="rise-enter shrink-0 border-t border-[var(--hairline)] bg-[var(--header-bg)] px-4 pt-3 shadow-[0_-4px_24px_rgba(15,23,42,0.06)]" | |
| style={{ paddingBottom: 'max(1rem, env(safe-area-inset-bottom))', animationDelay: '0.28s' }} | |
| > | |
| <div className="mx-auto w-full max-w-sm"> | |
| <button | |
| type="button" | |
| disabled={busy || !modelReady} | |
| className="ct-btn-primary" | |
| onClick={onCount} | |
| > | |
| {busy ? <Loader2 className="animate-spin" size={22} /> : null} | |
| {t(lang, 'countNow')} | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| ) | |
| } | |