Spaces:
Runtime error
Runtime error
Khunndev Cursor commited on
Commit Β·
d30af0c
1
Parent(s): c865058
Light CountThings theme, settings drawer, and results dock UX.
Browse filesRaise detection confidence to 0.72, fix circle label centering, move counting mode into a side settings panel, and add a sticky post-detect action bar.
Co-authored-by: Cursor <cursoragent@cursor.com>
- detect.py +1 -1
- frontend/index.html +2 -2
- frontend/src/App.tsx +48 -33
- frontend/src/components/ExportSheet.tsx +20 -29
- frontend/src/components/GroupPanel.tsx +10 -16
- frontend/src/components/ResultCanvas.tsx +18 -20
- frontend/src/components/ResultsDock.tsx +177 -0
- frontend/src/components/SettingsDrawer.tsx +82 -0
- frontend/src/components/SettingsPanel.tsx +20 -36
- frontend/src/components/StepCapture.tsx +26 -65
- frontend/src/components/StepCounting.tsx +15 -32
- frontend/src/components/StepPreview.tsx +18 -81
- frontend/src/components/StepResults.tsx +45 -99
- frontend/src/components/ToolBar.tsx +12 -15
- frontend/src/index.css +145 -41
- frontend/src/lib/constants.ts +1 -1
- frontend/vite.config.ts +2 -2
- scripts/test_samples.py +1 -1
detect.py
CHANGED
|
@@ -16,7 +16,7 @@ MODEL_DIR = STATIC_PATH / "models"
|
|
| 16 |
|
| 17 |
INFERENCE_SIZE = 1024
|
| 18 |
INFERENCE_SIZE_SMALL = 640
|
| 19 |
-
CONF_THRESHOLD = 0.
|
| 20 |
IOU_THRESHOLD = 0.45
|
| 21 |
MAX_DET = 4000
|
| 22 |
TILE_OVERLAP = 0.2
|
|
|
|
| 16 |
|
| 17 |
INFERENCE_SIZE = 1024
|
| 18 |
INFERENCE_SIZE_SMALL = 640
|
| 19 |
+
CONF_THRESHOLD = 0.72
|
| 20 |
IOU_THRESHOLD = 0.45
|
| 21 |
MAX_DET = 4000
|
| 22 |
TILE_OVERLAP = 0.2
|
frontend/index.html
CHANGED
|
@@ -3,9 +3,9 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
| 6 |
-
<meta name="theme-color" content="#
|
| 7 |
<meta name="apple-mobile-web-app-capable" content="yes" />
|
| 8 |
-
<meta name="apple-mobile-web-app-status-bar-style" content="
|
| 9 |
<meta name="mobile-web-app-capable" content="yes" />
|
| 10 |
<link rel="apple-touch-icon" href="/icon.svg" />
|
| 11 |
<title>NPI Pipe Count</title>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
| 6 |
+
<meta name="theme-color" content="#ffffff" />
|
| 7 |
<meta name="apple-mobile-web-app-capable" content="yes" />
|
| 8 |
+
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
|
| 9 |
<meta name="mobile-web-app-capable" content="yes" />
|
| 10 |
<link rel="apple-touch-icon" href="/icon.svg" />
|
| 11 |
<title>NPI Pipe Count</title>
|
frontend/src/App.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
|
|
| 2 |
import { assignDiameterGroups, countByGroup } from './lib/clustering'
|
| 3 |
import { getActiveBackend, isLowMemoryDevice, loadModel, runDetection } from './lib/inference'
|
| 4 |
import { loadInferenceMode, saveInferenceMode } from './lib/inferenceSettings'
|
|
@@ -9,6 +10,7 @@ import { StepCapture } from './components/StepCapture'
|
|
| 9 |
import { StepCounting } from './components/StepCounting'
|
| 10 |
import { StepPreview } from './components/StepPreview'
|
| 11 |
import { StepResults } from './components/StepResults'
|
|
|
|
| 12 |
|
| 13 |
type Step = 'capture' | 'preview' | 'counting' | 'results'
|
| 14 |
|
|
@@ -49,6 +51,7 @@ export default function App() {
|
|
| 49 |
const [serverAvailable, setServerAvailable] = useState(false)
|
| 50 |
const [status, setStatus] = useState('')
|
| 51 |
const [busy, setBusy] = useState(false)
|
|
|
|
| 52 |
|
| 53 |
const fileRef = useRef<HTMLInputElement>(null)
|
| 54 |
const cameraRef = useRef<HTMLInputElement>(null)
|
|
@@ -231,7 +234,7 @@ export default function App() {
|
|
| 231 |
return (
|
| 232 |
<div className="fixed inset-0 flex flex-col overflow-hidden bg-[var(--bg)]">
|
| 233 |
<header
|
| 234 |
-
className="relative flex shrink-0 items-center justify-between
|
| 235 |
style={{
|
| 236 |
paddingTop: 'max(0.75rem, env(safe-area-inset-top))',
|
| 237 |
paddingBottom: '0.625rem',
|
|
@@ -239,20 +242,18 @@ export default function App() {
|
|
| 239 |
>
|
| 240 |
<div className="flex items-center gap-2.5">
|
| 241 |
<div className="relative">
|
| 242 |
-
<img src="/icon.svg" alt="" className="h-7 w-7 rounded-
|
| 243 |
<span
|
| 244 |
-
className={`absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full border-2 border-[var(--bg)] transition-colors duration-700 ${
|
| 245 |
-
engine === '
|
| 246 |
-
? 'bg-
|
| 247 |
-
: engine === '
|
| 248 |
-
? 'bg-
|
| 249 |
-
:
|
| 250 |
-
? 'bg-red-400'
|
| 251 |
-
: 'animate-pulse bg-amber-400'
|
| 252 |
}`}
|
| 253 |
/>
|
| 254 |
</div>
|
| 255 |
-
<span className="text-[15px] font-
|
| 256 |
{t(lang, 'title')}
|
| 257 |
</span>
|
| 258 |
</div>
|
|
@@ -263,24 +264,32 @@ export default function App() {
|
|
| 263 |
key={s}
|
| 264 |
className={`h-1 rounded-full transition-all duration-500 ease-out ${
|
| 265 |
i === stepIdx
|
| 266 |
-
? 'w-6 bg-
|
| 267 |
: i < stepIdx
|
| 268 |
-
? 'w-2 bg-
|
| 269 |
-
: 'w-2 bg-
|
| 270 |
}`}
|
| 271 |
/>
|
| 272 |
))}
|
| 273 |
</div>
|
| 274 |
|
| 275 |
-
<
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
</header>
|
| 285 |
|
| 286 |
<div key={step} className={`${navDir === 'push' ? 'nav-push' : 'nav-pop'} flex flex-1 flex-col overflow-hidden`}>
|
|
@@ -302,20 +311,10 @@ export default function App() {
|
|
| 302 |
imageDims={imageDims}
|
| 303 |
busy={busy}
|
| 304 |
modelReady={canCount}
|
| 305 |
-
groupCount={groupCount}
|
| 306 |
-
inferenceMode={inferenceMode}
|
| 307 |
-
serverAvailable={serverAvailable}
|
| 308 |
-
useTiling={useTiling}
|
| 309 |
-
filterOutliers={filterOutliers}
|
| 310 |
onBack={resetToCapture}
|
| 311 |
onRetake={() => cameraRef.current?.click()}
|
| 312 |
onGallery={() => fileRef.current?.click()}
|
| 313 |
onCount={runCount}
|
| 314 |
-
onGroupCount={setGroupCount}
|
| 315 |
-
onInferenceMode={handleInferenceMode}
|
| 316 |
-
onUseTiling={setUseTiling}
|
| 317 |
-
onFilterOutliers={setFilterOutliers}
|
| 318 |
-
onRecluster={recluster}
|
| 319 |
/>
|
| 320 |
)}
|
| 321 |
|
|
@@ -338,6 +337,22 @@ export default function App() {
|
|
| 338 |
)}
|
| 339 |
</div>
|
| 340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
<input
|
| 342 |
ref={fileRef}
|
| 343 |
type="file"
|
|
|
|
| 1 |
import { useCallback, useEffect, useRef, useState } from 'react'
|
| 2 |
+
import { Settings } from 'lucide-react'
|
| 3 |
import { assignDiameterGroups, countByGroup } from './lib/clustering'
|
| 4 |
import { getActiveBackend, isLowMemoryDevice, loadModel, runDetection } from './lib/inference'
|
| 5 |
import { loadInferenceMode, saveInferenceMode } from './lib/inferenceSettings'
|
|
|
|
| 10 |
import { StepCounting } from './components/StepCounting'
|
| 11 |
import { StepPreview } from './components/StepPreview'
|
| 12 |
import { StepResults } from './components/StepResults'
|
| 13 |
+
import { SettingsDrawer } from './components/SettingsDrawer'
|
| 14 |
|
| 15 |
type Step = 'capture' | 'preview' | 'counting' | 'results'
|
| 16 |
|
|
|
|
| 51 |
const [serverAvailable, setServerAvailable] = useState(false)
|
| 52 |
const [status, setStatus] = useState('')
|
| 53 |
const [busy, setBusy] = useState(false)
|
| 54 |
+
const [settingsOpen, setSettingsOpen] = useState(false)
|
| 55 |
|
| 56 |
const fileRef = useRef<HTMLInputElement>(null)
|
| 57 |
const cameraRef = useRef<HTMLInputElement>(null)
|
|
|
|
| 234 |
return (
|
| 235 |
<div className="fixed inset-0 flex flex-col overflow-hidden bg-[var(--bg)]">
|
| 236 |
<header
|
| 237 |
+
className="ct-header relative flex shrink-0 items-center justify-between px-4"
|
| 238 |
style={{
|
| 239 |
paddingTop: 'max(0.75rem, env(safe-area-inset-top))',
|
| 240 |
paddingBottom: '0.625rem',
|
|
|
|
| 242 |
>
|
| 243 |
<div className="flex items-center gap-2.5">
|
| 244 |
<div className="relative">
|
| 245 |
+
<img src="/icon.svg" alt="" className="h-7 w-7 rounded-lg" />
|
| 246 |
<span
|
| 247 |
+
className={`absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full border-2 border-[var(--header-bg)] transition-colors duration-700 ${
|
| 248 |
+
engine === 'none'
|
| 249 |
+
? 'bg-[var(--danger)]'
|
| 250 |
+
: engine === 'checking'
|
| 251 |
+
? 'animate-pulse bg-[var(--warning)]'
|
| 252 |
+
: 'bg-[var(--success)]'
|
|
|
|
|
|
|
| 253 |
}`}
|
| 254 |
/>
|
| 255 |
</div>
|
| 256 |
+
<span className="text-[15px] font-bold tracking-tight text-[var(--text)]">
|
| 257 |
{t(lang, 'title')}
|
| 258 |
</span>
|
| 259 |
</div>
|
|
|
|
| 264 |
key={s}
|
| 265 |
className={`h-1 rounded-full transition-all duration-500 ease-out ${
|
| 266 |
i === stepIdx
|
| 267 |
+
? 'w-6 bg-[var(--brand)]'
|
| 268 |
: i < stepIdx
|
| 269 |
+
? 'w-2 bg-[var(--brand-muted)]'
|
| 270 |
+
: 'w-2 bg-[var(--hairline)]'
|
| 271 |
}`}
|
| 272 |
/>
|
| 273 |
))}
|
| 274 |
</div>
|
| 275 |
|
| 276 |
+
<div className="flex items-center gap-1.5">
|
| 277 |
+
<button
|
| 278 |
+
type="button"
|
| 279 |
+
className="ct-btn-ghost h-9 w-9"
|
| 280 |
+
onClick={() => setSettingsOpen(true)}
|
| 281 |
+
aria-label={t(lang, 'settings')}
|
| 282 |
+
>
|
| 283 |
+
<Settings size={17} />
|
| 284 |
+
</button>
|
| 285 |
+
<button
|
| 286 |
+
type="button"
|
| 287 |
+
className="ct-btn-ghost px-3 py-1.5 text-xs"
|
| 288 |
+
onClick={() => setLang(lang === 'th' ? 'en' : 'th')}
|
| 289 |
+
>
|
| 290 |
+
{lang === 'th' ? 'EN' : 'ΰΈ '}
|
| 291 |
+
</button>
|
| 292 |
+
</div>
|
| 293 |
</header>
|
| 294 |
|
| 295 |
<div key={step} className={`${navDir === 'push' ? 'nav-push' : 'nav-pop'} flex flex-1 flex-col overflow-hidden`}>
|
|
|
|
| 311 |
imageDims={imageDims}
|
| 312 |
busy={busy}
|
| 313 |
modelReady={canCount}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
onBack={resetToCapture}
|
| 315 |
onRetake={() => cameraRef.current?.click()}
|
| 316 |
onGallery={() => fileRef.current?.click()}
|
| 317 |
onCount={runCount}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
/>
|
| 319 |
)}
|
| 320 |
|
|
|
|
| 337 |
)}
|
| 338 |
</div>
|
| 339 |
|
| 340 |
+
<SettingsDrawer
|
| 341 |
+
lang={lang}
|
| 342 |
+
open={settingsOpen}
|
| 343 |
+
onClose={() => setSettingsOpen(false)}
|
| 344 |
+
groupCount={groupCount}
|
| 345 |
+
inferenceMode={inferenceMode}
|
| 346 |
+
serverAvailable={serverAvailable}
|
| 347 |
+
useTiling={useTiling}
|
| 348 |
+
filterOutliers={filterOutliers}
|
| 349 |
+
onGroupCount={setGroupCount}
|
| 350 |
+
onInferenceMode={handleInferenceMode}
|
| 351 |
+
onUseTiling={setUseTiling}
|
| 352 |
+
onFilterOutliers={setFilterOutliers}
|
| 353 |
+
onRecluster={recluster}
|
| 354 |
+
/>
|
| 355 |
+
|
| 356 |
<input
|
| 357 |
ref={fileRef}
|
| 358 |
type="file"
|
frontend/src/components/ExportSheet.tsx
CHANGED
|
@@ -27,80 +27,71 @@ export function ExportSheet({
|
|
| 27 |
|
| 28 |
return (
|
| 29 |
<>
|
| 30 |
-
{/* Backdrop */}
|
| 31 |
<button
|
| 32 |
type="button"
|
| 33 |
-
className="overlay-enter fixed inset-0 z-50 bg-black/
|
| 34 |
aria-label="Close"
|
| 35 |
onClick={onClose}
|
| 36 |
/>
|
| 37 |
|
| 38 |
-
{/* Sheet */}
|
| 39 |
<div
|
| 40 |
-
className="sheet-enter fixed inset-x-0 bottom-0 z-50 rounded-t-[1.75rem] bg-[
|
| 41 |
style={{ paddingBottom: 'max(1.25rem, env(safe-area-inset-bottom))' }}
|
| 42 |
>
|
| 43 |
-
{/* Drag handle */}
|
| 44 |
<div className="flex justify-center pt-3 pb-1">
|
| 45 |
-
<div className="h-1 w-9 rounded-full bg-
|
| 46 |
</div>
|
| 47 |
|
| 48 |
-
|
| 49 |
-
<h2 className="px-5 pb-3 pt-2 text-center text-[17px] font-semibold text-white">
|
| 50 |
{t(lang, 'export')}
|
| 51 |
</h2>
|
| 52 |
|
| 53 |
-
|
| 54 |
-
<div className="mx-4 overflow-hidden rounded-2xl bg-white/5 ring-1 ring-white/8">
|
| 55 |
-
{/* PNG */}
|
| 56 |
<button
|
| 57 |
type="button"
|
| 58 |
disabled={!canExportPng}
|
| 59 |
-
className="flex min-h-[52px] w-full items-center gap-4 px-4 text-left transition-colors duration-150 disabled:opacity-40 active:bg-
|
| 60 |
onClick={() => { onExportPng(); onClose() }}
|
| 61 |
>
|
| 62 |
-
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-
|
| 63 |
-
<Image size={18} className="text-
|
| 64 |
</span>
|
| 65 |
-
<span className="text-[15px] font-medium text-
|
| 66 |
</button>
|
| 67 |
|
| 68 |
-
<div className="ml-[3.25rem] h-px bg-
|
| 69 |
|
| 70 |
-
{/* JSON */}
|
| 71 |
<button
|
| 72 |
type="button"
|
| 73 |
disabled={!canExportData}
|
| 74 |
-
className="flex min-h-[52px] w-full items-center gap-4 px-4 text-left transition-colors duration-150 disabled:opacity-40 active:bg-
|
| 75 |
onClick={() => { onExportJson(); onClose() }}
|
| 76 |
>
|
| 77 |
-
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-
|
| 78 |
-
<FileJson size={18} className="text-
|
| 79 |
</span>
|
| 80 |
-
<span className="text-[15px] font-medium text-
|
| 81 |
</button>
|
| 82 |
|
| 83 |
-
<div className="ml-[3.25rem] h-px bg-
|
| 84 |
|
| 85 |
-
{/* CSV */}
|
| 86 |
<button
|
| 87 |
type="button"
|
| 88 |
disabled={!canExportData}
|
| 89 |
-
className="flex min-h-[52px] w-full items-center gap-4 px-4 text-left transition-colors duration-150 disabled:opacity-40 active:bg-
|
| 90 |
onClick={() => { onExportCsv(); onClose() }}
|
| 91 |
>
|
| 92 |
-
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-
|
| 93 |
-
<FileSpreadsheet size={18} className="text-
|
| 94 |
</span>
|
| 95 |
-
<span className="text-[15px] font-medium text-
|
| 96 |
</button>
|
| 97 |
</div>
|
| 98 |
|
| 99 |
-
{/* Cancel */}
|
| 100 |
<div className="mx-4 mt-2.5">
|
| 101 |
<button
|
| 102 |
type="button"
|
| 103 |
-
className="
|
| 104 |
onClick={onClose}
|
| 105 |
>
|
| 106 |
{t(lang, 'cancel')}
|
|
|
|
| 27 |
|
| 28 |
return (
|
| 29 |
<>
|
|
|
|
| 30 |
<button
|
| 31 |
type="button"
|
| 32 |
+
className="overlay-enter fixed inset-0 z-50 bg-black/40 backdrop-blur-sm"
|
| 33 |
aria-label="Close"
|
| 34 |
onClick={onClose}
|
| 35 |
/>
|
| 36 |
|
|
|
|
| 37 |
<div
|
| 38 |
+
className="sheet-enter fixed inset-x-0 bottom-0 z-50 rounded-t-[1.75rem] bg-[var(--surface)] shadow-2xl ring-1 ring-[var(--hairline)]"
|
| 39 |
style={{ paddingBottom: 'max(1.25rem, env(safe-area-inset-bottom))' }}
|
| 40 |
>
|
|
|
|
| 41 |
<div className="flex justify-center pt-3 pb-1">
|
| 42 |
+
<div className="h-1 w-9 rounded-full bg-[var(--hairline)]" />
|
| 43 |
</div>
|
| 44 |
|
| 45 |
+
<h2 className="px-5 pb-3 pt-2 text-center text-[17px] font-semibold text-[var(--text)]">
|
|
|
|
| 46 |
{t(lang, 'export')}
|
| 47 |
</h2>
|
| 48 |
|
| 49 |
+
<div className="mx-4 overflow-hidden rounded-2xl border border-[var(--hairline)] bg-[var(--surface-2)]">
|
|
|
|
|
|
|
| 50 |
<button
|
| 51 |
type="button"
|
| 52 |
disabled={!canExportPng}
|
| 53 |
+
className="flex min-h-[52px] w-full items-center gap-4 px-4 text-left transition-colors duration-150 disabled:opacity-40 active:bg-[var(--surface-active)]"
|
| 54 |
onClick={() => { onExportPng(); onClose() }}
|
| 55 |
>
|
| 56 |
+
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-[var(--info-light)]">
|
| 57 |
+
<Image size={18} className="text-[var(--info)]" />
|
| 58 |
</span>
|
| 59 |
+
<span className="text-[15px] font-medium text-[var(--text)]">{t(lang, 'exportPng')}</span>
|
| 60 |
</button>
|
| 61 |
|
| 62 |
+
<div className="ml-[3.25rem] h-px bg-[var(--hairline)]" />
|
| 63 |
|
|
|
|
| 64 |
<button
|
| 65 |
type="button"
|
| 66 |
disabled={!canExportData}
|
| 67 |
+
className="flex min-h-[52px] w-full items-center gap-4 px-4 text-left transition-colors duration-150 disabled:opacity-40 active:bg-[var(--surface-active)]"
|
| 68 |
onClick={() => { onExportJson(); onClose() }}
|
| 69 |
>
|
| 70 |
+
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-[var(--warning-light)]">
|
| 71 |
+
<FileJson size={18} className="text-[var(--warning)]" />
|
| 72 |
</span>
|
| 73 |
+
<span className="text-[15px] font-medium text-[var(--text)]">{t(lang, 'exportJson')}</span>
|
| 74 |
</button>
|
| 75 |
|
| 76 |
+
<div className="ml-[3.25rem] h-px bg-[var(--hairline)]" />
|
| 77 |
|
|
|
|
| 78 |
<button
|
| 79 |
type="button"
|
| 80 |
disabled={!canExportData}
|
| 81 |
+
className="flex min-h-[52px] w-full items-center gap-4 px-4 text-left transition-colors duration-150 disabled:opacity-40 active:bg-[var(--surface-active)]"
|
| 82 |
onClick={() => { onExportCsv(); onClose() }}
|
| 83 |
>
|
| 84 |
+
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-[var(--success-light)]">
|
| 85 |
+
<FileSpreadsheet size={18} className="text-[var(--success)]" />
|
| 86 |
</span>
|
| 87 |
+
<span className="text-[15px] font-medium text-[var(--text)]">{t(lang, 'exportCsv')}</span>
|
| 88 |
</button>
|
| 89 |
</div>
|
| 90 |
|
|
|
|
| 91 |
<div className="mx-4 mt-2.5">
|
| 92 |
<button
|
| 93 |
type="button"
|
| 94 |
+
className="ct-btn-secondary min-h-[50px] text-[15px]"
|
| 95 |
onClick={onClose}
|
| 96 |
>
|
| 97 |
{t(lang, 'cancel')}
|
frontend/src/components/GroupPanel.tsx
CHANGED
|
@@ -22,11 +22,9 @@ export function GroupPanel({
|
|
| 22 |
}: Props) {
|
| 23 |
return (
|
| 24 |
<section>
|
| 25 |
-
<p className="mb-2 px-1
|
| 26 |
-
{t(lang, 'groups')}
|
| 27 |
-
</p>
|
| 28 |
|
| 29 |
-
<div className="
|
| 30 |
{groups.map((g, idx) => {
|
| 31 |
const count = counts[g.id] ?? 0
|
| 32 |
const mismatch = g.expected !== undefined && g.expected !== count
|
|
@@ -34,36 +32,33 @@ export function GroupPanel({
|
|
| 34 |
|
| 35 |
return (
|
| 36 |
<div key={g.id}>
|
| 37 |
-
{idx > 0 && <div className="ml-4 h-px bg-
|
| 38 |
|
| 39 |
<button
|
| 40 |
type="button"
|
| 41 |
onClick={() => onSelectGroup(g.id)}
|
| 42 |
className={cn(
|
| 43 |
'flex min-h-[56px] w-full items-center gap-3 px-4 text-left transition-colors duration-150',
|
| 44 |
-
selected ? 'bg-
|
| 45 |
)}
|
| 46 |
>
|
| 47 |
-
{/* Color swatch */}
|
| 48 |
<span
|
| 49 |
-
className="h-3 w-3 shrink-0 rounded-full ring-2 ring-
|
| 50 |
style={{ background: g.color }}
|
| 51 |
/>
|
| 52 |
|
| 53 |
-
|
| 54 |
-
<span className="flex-1 text-[15px] text-white/90">{g.label}</span>
|
| 55 |
|
| 56 |
-
{/* Expected input */}
|
| 57 |
<div className="flex items-center gap-2" onClick={(e) => e.stopPropagation()}>
|
| 58 |
{mismatch && (
|
| 59 |
-
<span className="text-xs font-semibold text-
|
| 60 |
)}
|
| 61 |
<input
|
| 62 |
type="number"
|
| 63 |
inputMode="numeric"
|
| 64 |
min={0}
|
| 65 |
placeholder={t(lang, 'expected')}
|
| 66 |
-
className="h-8 w-20 rounded-xl border border-
|
| 67 |
value={g.expected ?? ''}
|
| 68 |
onChange={(e) => {
|
| 69 |
const v = e.target.value
|
|
@@ -72,11 +67,10 @@ export function GroupPanel({
|
|
| 72 |
/>
|
| 73 |
</div>
|
| 74 |
|
| 75 |
-
{/* Count */}
|
| 76 |
<span
|
| 77 |
className={cn(
|
| 78 |
'min-w-[2.5rem] text-right text-2xl font-bold tabular-nums leading-none',
|
| 79 |
-
mismatch ? 'text-
|
| 80 |
)}
|
| 81 |
>
|
| 82 |
{count}
|
|
@@ -87,7 +81,7 @@ export function GroupPanel({
|
|
| 87 |
})}
|
| 88 |
</div>
|
| 89 |
|
| 90 |
-
<p className="mt-1.5 px-1 text-[11px] text-
|
| 91 |
</section>
|
| 92 |
)
|
| 93 |
}
|
|
|
|
| 22 |
}: Props) {
|
| 23 |
return (
|
| 24 |
<section>
|
| 25 |
+
<p className="ct-section-label mb-2 px-1">{t(lang, 'groups')}</p>
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
<div className="ct-card overflow-hidden">
|
| 28 |
{groups.map((g, idx) => {
|
| 29 |
const count = counts[g.id] ?? 0
|
| 30 |
const mismatch = g.expected !== undefined && g.expected !== count
|
|
|
|
| 32 |
|
| 33 |
return (
|
| 34 |
<div key={g.id}>
|
| 35 |
+
{idx > 0 && <div className="ml-4 h-px bg-[var(--hairline)]" />}
|
| 36 |
|
| 37 |
<button
|
| 38 |
type="button"
|
| 39 |
onClick={() => onSelectGroup(g.id)}
|
| 40 |
className={cn(
|
| 41 |
'flex min-h-[56px] w-full items-center gap-3 px-4 text-left transition-colors duration-150',
|
| 42 |
+
selected ? 'bg-[var(--surface-active)]' : 'active:bg-[var(--surface-2)]',
|
| 43 |
)}
|
| 44 |
>
|
|
|
|
| 45 |
<span
|
| 46 |
+
className="h-3 w-3 shrink-0 rounded-full ring-2 ring-[var(--hairline)]"
|
| 47 |
style={{ background: g.color }}
|
| 48 |
/>
|
| 49 |
|
| 50 |
+
<span className="flex-1 text-[15px] text-[var(--text)]">{g.label}</span>
|
|
|
|
| 51 |
|
|
|
|
| 52 |
<div className="flex items-center gap-2" onClick={(e) => e.stopPropagation()}>
|
| 53 |
{mismatch && (
|
| 54 |
+
<span className="text-xs font-semibold text-[var(--warning)]">β {g.expected}</span>
|
| 55 |
)}
|
| 56 |
<input
|
| 57 |
type="number"
|
| 58 |
inputMode="numeric"
|
| 59 |
min={0}
|
| 60 |
placeholder={t(lang, 'expected')}
|
| 61 |
+
className="h-8 w-20 rounded-xl border border-[var(--border)] bg-[var(--surface)] px-2.5 text-center text-sm text-[var(--text)] placeholder:text-[var(--text-faint)] focus:outline-none focus:ring-2 focus:ring-[var(--brand-ring)]"
|
| 62 |
value={g.expected ?? ''}
|
| 63 |
onChange={(e) => {
|
| 64 |
const v = e.target.value
|
|
|
|
| 67 |
/>
|
| 68 |
</div>
|
| 69 |
|
|
|
|
| 70 |
<span
|
| 71 |
className={cn(
|
| 72 |
'min-w-[2.5rem] text-right text-2xl font-bold tabular-nums leading-none',
|
| 73 |
+
mismatch ? 'text-[var(--warning)]' : 'text-[var(--brand)]',
|
| 74 |
)}
|
| 75 |
>
|
| 76 |
{count}
|
|
|
|
| 81 |
})}
|
| 82 |
</div>
|
| 83 |
|
| 84 |
+
<p className="mt-1.5 px-1 text-[11px] text-[var(--text-faint)]">{t(lang, 'selectGroup')}</p>
|
| 85 |
</section>
|
| 86 |
)
|
| 87 |
}
|
frontend/src/components/ResultCanvas.tsx
CHANGED
|
@@ -83,10 +83,10 @@ function fitLabelFontSize(
|
|
| 83 |
displayPx: number,
|
| 84 |
): number {
|
| 85 |
const minFs = 6 / displayPx
|
| 86 |
-
// upper bound: text should not exceed ~
|
| 87 |
-
let fs = Math.min(radius * 1.
|
| 88 |
-
const maxW = radius * 2 * 0.
|
| 89 |
-
const maxH = radius * 2 * 0.
|
| 90 |
|
| 91 |
for (let i = 0; i < 12; i++) {
|
| 92 |
ctx.font = `bold ${fs}px sans-serif`
|
|
@@ -136,36 +136,34 @@ function drawCircle(
|
|
| 136 |
ctx.lineCap = 'round'
|
| 137 |
ctx.stroke()
|
| 138 |
|
| 139 |
-
// number label β centred
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
if (showLabel && radius >= minLabelRadius && eased > 0) {
|
| 143 |
const alpha = Math.min(1, eased * 2)
|
| 144 |
const fs = fitLabelFontSize(ctx, label, radius, displayPx)
|
| 145 |
|
| 146 |
-
ctx.font = `bold ${fs}px sans-serif`
|
| 147 |
ctx.textAlign = 'center'
|
| 148 |
-
ctx.textBaseline = '
|
| 149 |
|
| 150 |
-
// optical vertical centre (some fonts sit slightly below geometric middle)
|
| 151 |
const m = ctx.measureText(label)
|
| 152 |
-
const ascent = m.actualBoundingBoxAscent ?? fs * 0.
|
| 153 |
const descent = m.actualBoundingBoxDescent ?? fs * 0.22
|
| 154 |
-
|
|
|
|
| 155 |
|
| 156 |
-
// clip to inner circle so text never overlaps the stroke or neighbours
|
| 157 |
ctx.save()
|
| 158 |
ctx.beginPath()
|
| 159 |
-
ctx.arc(cx, cy, Math.max(1, radius - lw * 0.
|
| 160 |
ctx.clip()
|
| 161 |
|
| 162 |
-
const outline = Math.max(0.5 / displayPx, fs * 0.
|
| 163 |
ctx.lineJoin = 'round'
|
| 164 |
ctx.lineWidth = outline
|
| 165 |
-
ctx.strokeStyle = `rgba(0,0,0,${0.
|
| 166 |
-
ctx.strokeText(label, cx, ty)
|
| 167 |
ctx.fillStyle = `rgba(255,255,255,${alpha})`
|
| 168 |
-
ctx.
|
|
|
|
| 169 |
ctx.restore()
|
| 170 |
}
|
| 171 |
|
|
@@ -602,7 +600,7 @@ export function ResultCanvas({
|
|
| 602 |
}
|
| 603 |
|
| 604 |
return (
|
| 605 |
-
<div ref={containerRef} className="relative overflow-hidden rounded-2xl border border-
|
| 606 |
<canvas
|
| 607 |
ref={canvasRef}
|
| 608 |
style={{ transformOrigin: '0 0', display: 'block', width: '100%', height: 'auto' }}
|
|
|
|
| 83 |
displayPx: number,
|
| 84 |
): number {
|
| 85 |
const minFs = 6 / displayPx
|
| 86 |
+
// upper bound: text should not exceed ~78% of the inner diameter
|
| 87 |
+
let fs = Math.min(radius * 1.2, 20 / displayPx)
|
| 88 |
+
const maxW = radius * 2 * 0.78
|
| 89 |
+
const maxH = radius * 2 * 0.62
|
| 90 |
|
| 91 |
for (let i = 0; i < 12; i++) {
|
| 92 |
ctx.font = `bold ${fs}px sans-serif`
|
|
|
|
| 136 |
ctx.lineCap = 'round'
|
| 137 |
ctx.stroke()
|
| 138 |
|
| 139 |
+
// number label β centred in the circle using glyph bounding box
|
| 140 |
+
const minLabelRadiusCss = 3
|
| 141 |
+
if (showLabel && radius * displayPx >= minLabelRadiusCss && eased > 0) {
|
|
|
|
| 142 |
const alpha = Math.min(1, eased * 2)
|
| 143 |
const fs = fitLabelFontSize(ctx, label, radius, displayPx)
|
| 144 |
|
| 145 |
+
ctx.font = `bold ${fs}px system-ui, -apple-system, sans-serif`
|
| 146 |
ctx.textAlign = 'center'
|
| 147 |
+
ctx.textBaseline = 'alphabetic'
|
| 148 |
|
|
|
|
| 149 |
const m = ctx.measureText(label)
|
| 150 |
+
const ascent = m.actualBoundingBoxAscent ?? fs * 0.8
|
| 151 |
const descent = m.actualBoundingBoxDescent ?? fs * 0.22
|
| 152 |
+
// place baseline so the glyph visual centre sits at cy
|
| 153 |
+
const baselineY = cy + (ascent - descent) / 2
|
| 154 |
|
|
|
|
| 155 |
ctx.save()
|
| 156 |
ctx.beginPath()
|
| 157 |
+
ctx.arc(cx, cy, Math.max(1, radius - lw * 0.55), 0, Math.PI * 2)
|
| 158 |
ctx.clip()
|
| 159 |
|
| 160 |
+
const outline = Math.max(0.5 / displayPx, fs * 0.1)
|
| 161 |
ctx.lineJoin = 'round'
|
| 162 |
ctx.lineWidth = outline
|
| 163 |
+
ctx.strokeStyle = `rgba(0,0,0,${0.6 * alpha})`
|
|
|
|
| 164 |
ctx.fillStyle = `rgba(255,255,255,${alpha})`
|
| 165 |
+
ctx.strokeText(label, cx, baselineY)
|
| 166 |
+
ctx.fillText(label, cx, baselineY)
|
| 167 |
ctx.restore()
|
| 168 |
}
|
| 169 |
|
|
|
|
| 600 |
}
|
| 601 |
|
| 602 |
return (
|
| 603 |
+
<div ref={containerRef} className="relative overflow-hidden rounded-2xl border border-[var(--hairline)] bg-black shadow-[var(--shadow-md)]">
|
| 604 |
<canvas
|
| 605 |
ref={canvasRef}
|
| 606 |
style={{ transformOrigin: '0 0', display: 'block', width: '100%', height: 'auto' }}
|
frontend/src/components/ResultsDock.tsx
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Camera, Download, Eye, Plus, RotateCcw, SquareDashed, Tag, Trash2 } from 'lucide-react'
|
| 2 |
+
import { cn } from '../lib/utils'
|
| 3 |
+
import { t } from '../lib/i18n'
|
| 4 |
+
import type { DiameterGroup, Lang, ToolMode } from '../lib/types'
|
| 5 |
+
|
| 6 |
+
const TOOLS: {
|
| 7 |
+
id: ToolMode
|
| 8 |
+
icon: typeof Eye
|
| 9 |
+
labelKey: 'toolView' | 'toolDelete' | 'toolAdd' | 'toolReassign' | 'toolArea'
|
| 10 |
+
activeClass: string
|
| 11 |
+
}[] = [
|
| 12 |
+
{ id: 'view', icon: Eye, labelKey: 'toolView', activeClass: 'bg-[var(--text)] text-white' },
|
| 13 |
+
{ id: 'delete', icon: Trash2, labelKey: 'toolDelete', activeClass: 'bg-[var(--danger)] text-white' },
|
| 14 |
+
{ id: 'add', icon: Plus, labelKey: 'toolAdd', activeClass: 'bg-[var(--success)] text-white' },
|
| 15 |
+
{ id: 'reassign', icon: Tag, labelKey: 'toolReassign', activeClass: 'bg-[var(--info)] text-white' },
|
| 16 |
+
{ id: 'area', icon: SquareDashed, labelKey: 'toolArea', activeClass: 'bg-[#7c3aed] text-white' },
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
interface Props {
|
| 20 |
+
lang: Lang
|
| 21 |
+
total: number
|
| 22 |
+
tool: ToolMode
|
| 23 |
+
groups: DiameterGroup[]
|
| 24 |
+
counts: Record<number, number>
|
| 25 |
+
selectedGroupId: number
|
| 26 |
+
onToolChange: (tool: ToolMode) => void
|
| 27 |
+
onSelectGroup: (id: number) => void
|
| 28 |
+
onExpectedChange: (groupId: number, value: number | undefined) => void
|
| 29 |
+
onNewPhoto: () => void
|
| 30 |
+
onRecount: () => void
|
| 31 |
+
onExport: () => void
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
export function ResultsDock({
|
| 35 |
+
lang,
|
| 36 |
+
total,
|
| 37 |
+
tool,
|
| 38 |
+
groups,
|
| 39 |
+
counts,
|
| 40 |
+
selectedGroupId,
|
| 41 |
+
onToolChange,
|
| 42 |
+
onSelectGroup,
|
| 43 |
+
onExpectedChange,
|
| 44 |
+
onNewPhoto,
|
| 45 |
+
onRecount,
|
| 46 |
+
onExport,
|
| 47 |
+
}: Props) {
|
| 48 |
+
const selected = groups.find((g) => g.id === selectedGroupId) ?? groups[0]
|
| 49 |
+
const mismatch =
|
| 50 |
+
selected?.expected !== undefined && selected.expected !== (counts[selected.id] ?? 0)
|
| 51 |
+
|
| 52 |
+
return (
|
| 53 |
+
<div
|
| 54 |
+
className="rise-enter shrink-0 border-t border-[var(--hairline)] bg-[var(--header-bg)] shadow-[0_-4px_24px_rgba(15,23,42,0.06)]"
|
| 55 |
+
style={{ paddingBottom: 'max(0.75rem, env(safe-area-inset-bottom))' }}
|
| 56 |
+
>
|
| 57 |
+
{/* count + groups */}
|
| 58 |
+
<div className="flex items-end justify-between gap-3 px-4 pt-3">
|
| 59 |
+
<div>
|
| 60 |
+
<p className="text-[10px] font-semibold uppercase tracking-widest text-[var(--text-faint)]">
|
| 61 |
+
{t(lang, 'total')}
|
| 62 |
+
</p>
|
| 63 |
+
<p className="text-[40px] font-bold tabular-nums leading-none text-[var(--brand)]">
|
| 64 |
+
{total}
|
| 65 |
+
</p>
|
| 66 |
+
</div>
|
| 67 |
+
|
| 68 |
+
{groups.length > 1 && (
|
| 69 |
+
<div className="flex max-w-[58%] flex-wrap justify-end gap-1.5">
|
| 70 |
+
{groups.map((g) => {
|
| 71 |
+
const active = g.id === selectedGroupId
|
| 72 |
+
const count = counts[g.id] ?? 0
|
| 73 |
+
const diff = g.expected !== undefined && g.expected !== count
|
| 74 |
+
return (
|
| 75 |
+
<button
|
| 76 |
+
key={g.id}
|
| 77 |
+
type="button"
|
| 78 |
+
onClick={() => onSelectGroup(g.id)}
|
| 79 |
+
className={cn(
|
| 80 |
+
'inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-semibold transition-colors',
|
| 81 |
+
active
|
| 82 |
+
? 'border-[var(--brand)] bg-[var(--brand-light)] text-[var(--brand)]'
|
| 83 |
+
: 'border-[var(--hairline)] bg-[var(--surface)] text-[var(--text-dim)]',
|
| 84 |
+
)}
|
| 85 |
+
>
|
| 86 |
+
<span className="h-2 w-2 rounded-full" style={{ background: g.color }} />
|
| 87 |
+
{g.label}: {count}
|
| 88 |
+
{diff && <span className="text-[var(--warning)]">β </span>}
|
| 89 |
+
</button>
|
| 90 |
+
)
|
| 91 |
+
})}
|
| 92 |
+
</div>
|
| 93 |
+
)}
|
| 94 |
+
</div>
|
| 95 |
+
|
| 96 |
+
{/* expected count for selected group */}
|
| 97 |
+
{selected && groups.length > 0 && (
|
| 98 |
+
<div className="mt-2 flex items-center gap-2 px-4">
|
| 99 |
+
<span
|
| 100 |
+
className="h-2.5 w-2.5 shrink-0 rounded-full"
|
| 101 |
+
style={{ background: selected.color }}
|
| 102 |
+
/>
|
| 103 |
+
<span className="flex-1 text-sm text-[var(--text-dim)]">{selected.label}</span>
|
| 104 |
+
{mismatch && (
|
| 105 |
+
<span className="text-xs font-semibold text-[var(--warning)]">
|
| 106 |
+
{t(lang, 'mismatch')}
|
| 107 |
+
</span>
|
| 108 |
+
)}
|
| 109 |
+
<input
|
| 110 |
+
type="number"
|
| 111 |
+
inputMode="numeric"
|
| 112 |
+
min={0}
|
| 113 |
+
placeholder={t(lang, 'expected')}
|
| 114 |
+
className="h-8 w-[4.5rem] rounded-lg border border-[var(--border)] bg-[var(--surface)] px-2 text-center text-sm text-[var(--text)] placeholder:text-[var(--text-faint)] focus:outline-none focus:ring-2 focus:ring-[var(--brand-ring)]"
|
| 115 |
+
value={selected.expected ?? ''}
|
| 116 |
+
onChange={(e) => {
|
| 117 |
+
const v = e.target.value
|
| 118 |
+
onExpectedChange(selected.id, v === '' ? undefined : Number(v))
|
| 119 |
+
}}
|
| 120 |
+
/>
|
| 121 |
+
<span className="min-w-[2rem] text-right text-lg font-bold tabular-nums text-[var(--brand)]">
|
| 122 |
+
{counts[selected.id] ?? 0}
|
| 123 |
+
</span>
|
| 124 |
+
</div>
|
| 125 |
+
)}
|
| 126 |
+
|
| 127 |
+
{/* tools */}
|
| 128 |
+
<div className="mt-3 px-3">
|
| 129 |
+
<p className="mb-1.5 px-1 text-[10px] font-semibold uppercase tracking-widest text-[var(--text-faint)]">
|
| 130 |
+
{t(lang, 'tools')}
|
| 131 |
+
</p>
|
| 132 |
+
<div className="grid grid-cols-5 gap-1 rounded-xl border border-[var(--hairline)] bg-[var(--surface-2)] p-1">
|
| 133 |
+
{TOOLS.map(({ id, icon: Icon, labelKey, activeClass }) => {
|
| 134 |
+
const active = tool === id
|
| 135 |
+
return (
|
| 136 |
+
<button
|
| 137 |
+
key={id}
|
| 138 |
+
type="button"
|
| 139 |
+
className={cn(
|
| 140 |
+
'flex flex-col items-center gap-0.5 rounded-lg py-2 text-[10px] font-semibold transition-all active:scale-95',
|
| 141 |
+
active ? activeClass : 'text-[var(--text-dim)]',
|
| 142 |
+
)}
|
| 143 |
+
onClick={() => onToolChange(id)}
|
| 144 |
+
>
|
| 145 |
+
<Icon size={18} strokeWidth={active ? 2.5 : 2} />
|
| 146 |
+
<span className="leading-tight">{t(lang, labelKey)}</span>
|
| 147 |
+
</button>
|
| 148 |
+
)
|
| 149 |
+
})}
|
| 150 |
+
</div>
|
| 151 |
+
{tool !== 'view' && (
|
| 152 |
+
<p className="mt-1.5 px-1 text-[11px] text-[var(--text-faint)]">{t(lang, 'selectGroup')}</p>
|
| 153 |
+
)}
|
| 154 |
+
</div>
|
| 155 |
+
|
| 156 |
+
{/* primary actions */}
|
| 157 |
+
<div className="mt-3 grid grid-cols-3 gap-2 px-4">
|
| 158 |
+
<button type="button" className="ct-btn-secondary !min-h-11 !text-sm" onClick={onNewPhoto}>
|
| 159 |
+
<Camera size={16} />
|
| 160 |
+
{t(lang, 'resultsBack')}
|
| 161 |
+
</button>
|
| 162 |
+
<button
|
| 163 |
+
type="button"
|
| 164 |
+
className="flex min-h-11 items-center justify-center gap-1.5 rounded-[var(--r-lg)] border border-[var(--border)] bg-[var(--surface)] text-sm font-semibold text-[var(--text)] shadow-[var(--shadow-sm)] active:scale-[0.98] active:bg-[var(--surface-2)]"
|
| 165 |
+
onClick={onRecount}
|
| 166 |
+
>
|
| 167 |
+
<RotateCcw size={16} />
|
| 168 |
+
{t(lang, 'recount')}
|
| 169 |
+
</button>
|
| 170 |
+
<button type="button" className="ct-btn-primary !min-h-11 !text-sm" onClick={onExport}>
|
| 171 |
+
<Download size={16} />
|
| 172 |
+
{t(lang, 'export')}
|
| 173 |
+
</button>
|
| 174 |
+
</div>
|
| 175 |
+
</div>
|
| 176 |
+
)
|
| 177 |
+
}
|
frontend/src/components/SettingsDrawer.tsx
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { X } from 'lucide-react'
|
| 2 |
+
import { t } from '../lib/i18n'
|
| 3 |
+
import type { InferenceMode, Lang } from '../lib/types'
|
| 4 |
+
import { SettingsPanel } from './SettingsPanel'
|
| 5 |
+
|
| 6 |
+
interface Props {
|
| 7 |
+
lang: Lang
|
| 8 |
+
open: boolean
|
| 9 |
+
onClose: () => void
|
| 10 |
+
groupCount: number | 'auto'
|
| 11 |
+
inferenceMode: InferenceMode
|
| 12 |
+
serverAvailable: boolean
|
| 13 |
+
useTiling: boolean
|
| 14 |
+
filterOutliers: boolean
|
| 15 |
+
onGroupCount: (value: number | 'auto') => void
|
| 16 |
+
onInferenceMode: (mode: InferenceMode) => void
|
| 17 |
+
onUseTiling: (value: boolean) => void
|
| 18 |
+
onFilterOutliers: (value: boolean) => void
|
| 19 |
+
onRecluster: () => void
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
export function SettingsDrawer({
|
| 23 |
+
lang,
|
| 24 |
+
open,
|
| 25 |
+
onClose,
|
| 26 |
+
groupCount,
|
| 27 |
+
inferenceMode,
|
| 28 |
+
serverAvailable,
|
| 29 |
+
useTiling,
|
| 30 |
+
filterOutliers,
|
| 31 |
+
onGroupCount,
|
| 32 |
+
onInferenceMode,
|
| 33 |
+
onUseTiling,
|
| 34 |
+
onFilterOutliers,
|
| 35 |
+
onRecluster,
|
| 36 |
+
}: Props) {
|
| 37 |
+
if (!open) return null
|
| 38 |
+
|
| 39 |
+
return (
|
| 40 |
+
<>
|
| 41 |
+
<button
|
| 42 |
+
type="button"
|
| 43 |
+
className="overlay-enter fixed inset-0 z-[60] bg-black/35 backdrop-blur-[2px]"
|
| 44 |
+
aria-label={t(lang, 'cancel')}
|
| 45 |
+
onClick={onClose}
|
| 46 |
+
/>
|
| 47 |
+
|
| 48 |
+
<aside
|
| 49 |
+
className="drawer-enter fixed inset-y-0 right-0 z-[70] flex w-[min(100%,20rem)] flex-col bg-[var(--surface)] shadow-2xl ring-1 ring-[var(--hairline)]"
|
| 50 |
+
style={{ paddingTop: 'env(safe-area-inset-top)', paddingBottom: 'env(safe-area-inset-bottom)' }}
|
| 51 |
+
>
|
| 52 |
+
<div className="flex shrink-0 items-center justify-between border-b border-[var(--hairline)] px-4 py-3">
|
| 53 |
+
<h2 className="text-[17px] font-bold text-[var(--text)]">{t(lang, 'settings')}</h2>
|
| 54 |
+
<button
|
| 55 |
+
type="button"
|
| 56 |
+
className="ct-btn-ghost h-9 w-9"
|
| 57 |
+
onClick={onClose}
|
| 58 |
+
aria-label={t(lang, 'cancel')}
|
| 59 |
+
>
|
| 60 |
+
<X size={18} />
|
| 61 |
+
</button>
|
| 62 |
+
</div>
|
| 63 |
+
|
| 64 |
+
<div className="native-scroll flex-1 overflow-y-auto px-4 py-4">
|
| 65 |
+
<SettingsPanel
|
| 66 |
+
lang={lang}
|
| 67 |
+
groupCount={groupCount}
|
| 68 |
+
inferenceMode={inferenceMode}
|
| 69 |
+
serverAvailable={serverAvailable}
|
| 70 |
+
useTiling={useTiling}
|
| 71 |
+
filterOutliers={filterOutliers}
|
| 72 |
+
onGroupCount={onGroupCount}
|
| 73 |
+
onInferenceMode={onInferenceMode}
|
| 74 |
+
onUseTiling={onUseTiling}
|
| 75 |
+
onFilterOutliers={onFilterOutliers}
|
| 76 |
+
onRecluster={onRecluster}
|
| 77 |
+
/>
|
| 78 |
+
</div>
|
| 79 |
+
</aside>
|
| 80 |
+
</>
|
| 81 |
+
)
|
| 82 |
+
}
|
frontend/src/components/SettingsPanel.tsx
CHANGED
|
@@ -3,7 +3,6 @@ import type { InferenceMode, Lang } from '../lib/types'
|
|
| 3 |
|
| 4 |
interface Props {
|
| 5 |
lang: Lang
|
| 6 |
-
open: boolean
|
| 7 |
groupCount: number | 'auto'
|
| 8 |
inferenceMode: InferenceMode
|
| 9 |
serverAvailable: boolean
|
|
@@ -16,7 +15,6 @@ interface Props {
|
|
| 16 |
onRecluster: () => void
|
| 17 |
}
|
| 18 |
|
| 19 |
-
/** iOS-style toggle switch */
|
| 20 |
function Toggle({
|
| 21 |
checked,
|
| 22 |
onChange,
|
|
@@ -33,26 +31,26 @@ function Toggle({
|
|
| 33 |
type="button"
|
| 34 |
role="switch"
|
| 35 |
aria-checked={checked}
|
| 36 |
-
className="flex min-h-[52px] w-full items-center justify-between gap-3 px-4 text-left transition-colors duration-150 active:bg-
|
| 37 |
onClick={() => onChange(!checked)}
|
| 38 |
>
|
| 39 |
<span className="flex flex-col gap-0.5">
|
| 40 |
-
<span className="text-[15px] text-
|
| 41 |
{description && (
|
| 42 |
-
<span className="text-xs text-
|
| 43 |
)}
|
| 44 |
</span>
|
| 45 |
<span
|
| 46 |
className={`relative h-[31px] w-[51px] shrink-0 rounded-full transition-colors duration-200 ${
|
| 47 |
-
checked ? 'bg-[
|
| 48 |
}`}
|
| 49 |
-
style={{ boxShadow: 'inset 0 0 0 1px rgba(0,0,0,0.
|
| 50 |
>
|
| 51 |
<span
|
| 52 |
className={`absolute top-[2px] h-[27px] w-[27px] rounded-full bg-white shadow-md transition-all duration-200 ${
|
| 53 |
checked ? 'left-[22px]' : 'left-[2px]'
|
| 54 |
}`}
|
| 55 |
-
style={{ boxShadow: '0 2px 6px rgba(0,0,0,0.
|
| 56 |
/>
|
| 57 |
</span>
|
| 58 |
</button>
|
|
@@ -60,12 +58,11 @@ function Toggle({
|
|
| 60 |
}
|
| 61 |
|
| 62 |
function Separator() {
|
| 63 |
-
return <div className="ml-4 h-px bg-
|
| 64 |
}
|
| 65 |
|
| 66 |
export function SettingsPanel({
|
| 67 |
lang,
|
| 68 |
-
open,
|
| 69 |
groupCount,
|
| 70 |
inferenceMode,
|
| 71 |
serverAvailable,
|
|
@@ -77,16 +74,11 @@ export function SettingsPanel({
|
|
| 77 |
onFilterOutliers,
|
| 78 |
onRecluster,
|
| 79 |
}: Props) {
|
| 80 |
-
if (!open) return null
|
| 81 |
-
|
| 82 |
return (
|
| 83 |
<div className="space-y-4">
|
| 84 |
-
{/* ββ Inference mode βββββββββββββββββββββββββββββββββββββββββββ */}
|
| 85 |
<section>
|
| 86 |
-
<p className="mb-2 px-1
|
| 87 |
-
|
| 88 |
-
</p>
|
| 89 |
-
<div className="overflow-hidden rounded-2xl bg-white/6 ring-1 ring-white/8 p-3">
|
| 90 |
<div className="flex gap-2">
|
| 91 |
{(['server', 'local'] as InferenceMode[]).map((mode) => {
|
| 92 |
const active = inferenceMode === mode
|
|
@@ -98,17 +90,15 @@ export function SettingsPanel({
|
|
| 98 |
disabled={disabled}
|
| 99 |
className={`flex flex-1 flex-col items-center gap-0.5 rounded-xl px-3 py-2.5 text-center transition-all duration-150 active:scale-[0.98] disabled:opacity-40 ${
|
| 100 |
active
|
| 101 |
-
?
|
| 102 |
-
|
| 103 |
-
: 'bg-emerald-600 text-white shadow-md shadow-emerald-900/40'
|
| 104 |
-
: 'bg-white/8 text-white/65 active:bg-white/15'
|
| 105 |
}`}
|
| 106 |
onClick={() => onInferenceMode(mode)}
|
| 107 |
>
|
| 108 |
<span className="text-sm font-semibold">
|
| 109 |
{mode === 'server' ? t(lang, 'inferenceServer') : t(lang, 'inferenceLocal')}
|
| 110 |
</span>
|
| 111 |
-
<span className={`text-[10px] leading-tight ${active ? 'text-white/
|
| 112 |
{mode === 'server' ? t(lang, 'inferenceServerHint') : t(lang, 'inferenceLocalHint')}
|
| 113 |
</span>
|
| 114 |
</button>
|
|
@@ -116,19 +106,16 @@ export function SettingsPanel({
|
|
| 116 |
})}
|
| 117 |
</div>
|
| 118 |
{!serverAvailable && inferenceMode === 'local' && (
|
| 119 |
-
<p className="mt-2 px-1 text-center text-[11px] text-
|
| 120 |
{t(lang, 'serverUnavailable')}
|
| 121 |
</p>
|
| 122 |
)}
|
| 123 |
</div>
|
| 124 |
</section>
|
| 125 |
|
| 126 |
-
{/* ββ Group count section ββββββββββββοΏ½οΏ½οΏ½βββββββββββββββββββββββ */}
|
| 127 |
<section>
|
| 128 |
-
<p className="mb-2 px-1
|
| 129 |
-
|
| 130 |
-
</p>
|
| 131 |
-
<div className="overflow-hidden rounded-2xl bg-white/6 ring-1 ring-white/8">
|
| 132 |
<div className="flex flex-wrap gap-2 p-3">
|
| 133 |
{(['auto', 1, 2, 3, 4, 5, 6] as (number | 'auto')[]).map((n) => {
|
| 134 |
const active = groupCount === n
|
|
@@ -138,8 +125,8 @@ export function SettingsPanel({
|
|
| 138 |
type="button"
|
| 139 |
className={`min-h-9 rounded-xl px-4 text-sm font-semibold transition-all duration-150 active:scale-95 ${
|
| 140 |
active
|
| 141 |
-
? 'bg-
|
| 142 |
-
: 'bg-
|
| 143 |
}`}
|
| 144 |
onClick={() => onGroupCount(n)}
|
| 145 |
>
|
|
@@ -149,7 +136,7 @@ export function SettingsPanel({
|
|
| 149 |
})}
|
| 150 |
<button
|
| 151 |
type="button"
|
| 152 |
-
className="min-h-9 rounded-xl bg-
|
| 153 |
onClick={onRecluster}
|
| 154 |
>
|
| 155 |
{t(lang, 'apply')}
|
|
@@ -158,12 +145,9 @@ export function SettingsPanel({
|
|
| 158 |
</div>
|
| 159 |
</section>
|
| 160 |
|
| 161 |
-
{/* ββ Toggle settings section ββββββββββββββββββββββββββββββββ */}
|
| 162 |
<section>
|
| 163 |
-
<p className="mb-2 px-1
|
| 164 |
-
|
| 165 |
-
</p>
|
| 166 |
-
<div className="overflow-hidden rounded-2xl bg-white/6 ring-1 ring-white/8">
|
| 167 |
<Toggle
|
| 168 |
checked={useTiling}
|
| 169 |
onChange={onUseTiling}
|
|
|
|
| 3 |
|
| 4 |
interface Props {
|
| 5 |
lang: Lang
|
|
|
|
| 6 |
groupCount: number | 'auto'
|
| 7 |
inferenceMode: InferenceMode
|
| 8 |
serverAvailable: boolean
|
|
|
|
| 15 |
onRecluster: () => void
|
| 16 |
}
|
| 17 |
|
|
|
|
| 18 |
function Toggle({
|
| 19 |
checked,
|
| 20 |
onChange,
|
|
|
|
| 31 |
type="button"
|
| 32 |
role="switch"
|
| 33 |
aria-checked={checked}
|
| 34 |
+
className="flex min-h-[52px] w-full items-center justify-between gap-3 px-4 text-left transition-colors duration-150 active:bg-[var(--surface-2)]"
|
| 35 |
onClick={() => onChange(!checked)}
|
| 36 |
>
|
| 37 |
<span className="flex flex-col gap-0.5">
|
| 38 |
+
<span className="text-[15px] text-[var(--text)]">{label}</span>
|
| 39 |
{description && (
|
| 40 |
+
<span className="text-xs text-[var(--text-faint)]">{description}</span>
|
| 41 |
)}
|
| 42 |
</span>
|
| 43 |
<span
|
| 44 |
className={`relative h-[31px] w-[51px] shrink-0 rounded-full transition-colors duration-200 ${
|
| 45 |
+
checked ? 'bg-[var(--ios-toggle)]' : 'bg-[var(--hairline)]'
|
| 46 |
}`}
|
| 47 |
+
style={{ boxShadow: 'inset 0 0 0 1px rgba(0,0,0,0.06)' }}
|
| 48 |
>
|
| 49 |
<span
|
| 50 |
className={`absolute top-[2px] h-[27px] w-[27px] rounded-full bg-white shadow-md transition-all duration-200 ${
|
| 51 |
checked ? 'left-[22px]' : 'left-[2px]'
|
| 52 |
}`}
|
| 53 |
+
style={{ boxShadow: '0 2px 6px rgba(0,0,0,0.15)' }}
|
| 54 |
/>
|
| 55 |
</span>
|
| 56 |
</button>
|
|
|
|
| 58 |
}
|
| 59 |
|
| 60 |
function Separator() {
|
| 61 |
+
return <div className="ml-4 h-px bg-[var(--hairline)]" />
|
| 62 |
}
|
| 63 |
|
| 64 |
export function SettingsPanel({
|
| 65 |
lang,
|
|
|
|
| 66 |
groupCount,
|
| 67 |
inferenceMode,
|
| 68 |
serverAvailable,
|
|
|
|
| 74 |
onFilterOutliers,
|
| 75 |
onRecluster,
|
| 76 |
}: Props) {
|
|
|
|
|
|
|
| 77 |
return (
|
| 78 |
<div className="space-y-4">
|
|
|
|
| 79 |
<section>
|
| 80 |
+
<p className="ct-section-label mb-2 px-1">{t(lang, 'inferenceMode')}</p>
|
| 81 |
+
<div className="ct-card overflow-hidden p-3">
|
|
|
|
|
|
|
| 82 |
<div className="flex gap-2">
|
| 83 |
{(['server', 'local'] as InferenceMode[]).map((mode) => {
|
| 84 |
const active = inferenceMode === mode
|
|
|
|
| 90 |
disabled={disabled}
|
| 91 |
className={`flex flex-1 flex-col items-center gap-0.5 rounded-xl px-3 py-2.5 text-center transition-all duration-150 active:scale-[0.98] disabled:opacity-40 ${
|
| 92 |
active
|
| 93 |
+
? 'bg-[var(--brand)] text-white shadow-[var(--shadow-brand)]'
|
| 94 |
+
: 'bg-[var(--surface-2)] text-[var(--text-dim)] active:bg-[var(--surface-active)]'
|
|
|
|
|
|
|
| 95 |
}`}
|
| 96 |
onClick={() => onInferenceMode(mode)}
|
| 97 |
>
|
| 98 |
<span className="text-sm font-semibold">
|
| 99 |
{mode === 'server' ? t(lang, 'inferenceServer') : t(lang, 'inferenceLocal')}
|
| 100 |
</span>
|
| 101 |
+
<span className={`text-[10px] leading-tight ${active ? 'text-white/90' : 'text-[var(--text-faint)]'}`}>
|
| 102 |
{mode === 'server' ? t(lang, 'inferenceServerHint') : t(lang, 'inferenceLocalHint')}
|
| 103 |
</span>
|
| 104 |
</button>
|
|
|
|
| 106 |
})}
|
| 107 |
</div>
|
| 108 |
{!serverAvailable && inferenceMode === 'local' && (
|
| 109 |
+
<p className="mt-2 px-1 text-center text-[11px] text-[var(--warning)]">
|
| 110 |
{t(lang, 'serverUnavailable')}
|
| 111 |
</p>
|
| 112 |
)}
|
| 113 |
</div>
|
| 114 |
</section>
|
| 115 |
|
|
|
|
| 116 |
<section>
|
| 117 |
+
<p className="ct-section-label mb-2 px-1">{t(lang, 'groupCount')}</p>
|
| 118 |
+
<div className="ct-card overflow-hidden">
|
|
|
|
|
|
|
| 119 |
<div className="flex flex-wrap gap-2 p-3">
|
| 120 |
{(['auto', 1, 2, 3, 4, 5, 6] as (number | 'auto')[]).map((n) => {
|
| 121 |
const active = groupCount === n
|
|
|
|
| 125 |
type="button"
|
| 126 |
className={`min-h-9 rounded-xl px-4 text-sm font-semibold transition-all duration-150 active:scale-95 ${
|
| 127 |
active
|
| 128 |
+
? 'bg-[var(--brand)] text-white shadow-[var(--shadow-brand)]'
|
| 129 |
+
: 'bg-[var(--surface-2)] text-[var(--text-dim)] active:bg-[var(--surface-active)]'
|
| 130 |
}`}
|
| 131 |
onClick={() => onGroupCount(n)}
|
| 132 |
>
|
|
|
|
| 136 |
})}
|
| 137 |
<button
|
| 138 |
type="button"
|
| 139 |
+
className="min-h-9 rounded-xl bg-[var(--surface-2)] px-4 text-sm font-semibold text-[var(--text-dim)] transition-all duration-150 active:scale-95 active:bg-[var(--surface-active)]"
|
| 140 |
onClick={onRecluster}
|
| 141 |
>
|
| 142 |
{t(lang, 'apply')}
|
|
|
|
| 145 |
</div>
|
| 146 |
</section>
|
| 147 |
|
|
|
|
| 148 |
<section>
|
| 149 |
+
<p className="ct-section-label mb-2 px-1">{t(lang, 'settings')}</p>
|
| 150 |
+
<div className="ct-card overflow-hidden">
|
|
|
|
|
|
|
| 151 |
<Toggle
|
| 152 |
checked={useTiling}
|
| 153 |
onChange={onUseTiling}
|
frontend/src/components/StepCapture.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { AlertTriangle, Camera,
|
| 2 |
import { t } from '../lib/i18n'
|
| 3 |
import type { Lang } from '../lib/types'
|
| 4 |
|
|
@@ -16,87 +16,59 @@ interface Props {
|
|
| 16 |
export function StepCapture({ lang, engine, modelError, onRetryModel, onCamera, onGallery }: Props) {
|
| 17 |
const hasError = engine === 'none' || Boolean(modelError)
|
| 18 |
const ready = engine === 'local' || engine === 'server'
|
|
|
|
| 19 |
return (
|
| 20 |
-
<div className="relative flex flex-1 flex-col overflow-hidden">
|
| 21 |
-
{/*
|
| 22 |
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
| 23 |
<div
|
| 24 |
-
className="h-[
|
| 25 |
style={{
|
| 26 |
-
background: 'radial-gradient(circle,
|
| 27 |
animation: 'glow-pulse 4s ease-in-out infinite',
|
| 28 |
}}
|
| 29 |
/>
|
| 30 |
</div>
|
| 31 |
|
| 32 |
-
{/* Hero area */}
|
| 33 |
<div className="relative z-10 flex flex-1 flex-col items-center justify-center px-8">
|
| 34 |
-
{/* Logo mark */}
|
| 35 |
<div className="mb-8 flex flex-col items-center gap-4">
|
| 36 |
<div className="relative">
|
| 37 |
-
{/* Outer glow ring */}
|
| 38 |
-
<div
|
| 39 |
-
className="absolute -inset-4 rounded-full opacity-40"
|
| 40 |
-
style={{
|
| 41 |
-
background: 'radial-gradient(circle, rgba(59,130,246,0.5) 0%, transparent 70%)',
|
| 42 |
-
animation: 'breathe 3.5s ease-in-out infinite',
|
| 43 |
-
}}
|
| 44 |
-
/>
|
| 45 |
-
{/* Icon container */}
|
| 46 |
<div
|
| 47 |
-
className="relative flex h-28 w-28 items-center justify-center rounded-[
|
| 48 |
style={{ animation: 'breathe 3.5s ease-in-out infinite' }}
|
| 49 |
>
|
| 50 |
-
<img src="/icon.svg" alt=""
|
| 51 |
-
|
| 52 |
-
{/* Engine-ready dot */}
|
| 53 |
<span
|
| 54 |
className={`absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full border-[3px] border-[var(--bg)] transition-all duration-700 ${
|
| 55 |
-
engine === '
|
| 56 |
-
? 'bg-
|
| 57 |
-
:
|
| 58 |
-
? 'bg-
|
| 59 |
-
:
|
| 60 |
-
? 'bg-red-400 shadow-[0_0_10px_rgba(248,113,113,0.7)]'
|
| 61 |
-
: 'animate-pulse bg-amber-400 shadow-[0_0_10px_rgba(251,191,36,0.7)]'
|
| 62 |
}`}
|
| 63 |
/>
|
| 64 |
</div>
|
| 65 |
</div>
|
| 66 |
|
| 67 |
<div className="text-center">
|
| 68 |
-
<h1 className="text-[26px] font-bold tracking-tight text-
|
| 69 |
{t(lang, 'title')}
|
| 70 |
</h1>
|
| 71 |
-
<p className="mt-1.5 text-sm text-
|
| 72 |
{t(lang, 'captureSubtitle')}
|
| 73 |
</p>
|
| 74 |
</div>
|
| 75 |
|
| 76 |
-
{/* Engine status badge */}
|
| 77 |
{hasError ? (
|
| 78 |
-
<button
|
| 79 |
-
type="button"
|
| 80 |
-
onClick={onRetryModel}
|
| 81 |
-
className="flex items-center gap-1.5 rounded-full bg-red-500/15 px-3 py-1 text-xs font-medium text-red-300 transition-all duration-150 active:scale-95"
|
| 82 |
-
>
|
| 83 |
<RotateCcw size={12} />
|
| 84 |
{t(lang, 'retry')}
|
| 85 |
</button>
|
| 86 |
-
) : engine === 'server' ? (
|
| 87 |
-
<div className="flex items-center gap-1.5 rounded-full bg-sky-500/15 px-3 py-1 text-xs font-medium text-sky-300">
|
| 88 |
-
<Cloud size={12} />
|
| 89 |
-
{t(lang, 'cloudMode')}
|
| 90 |
-
</div>
|
| 91 |
) : (
|
| 92 |
-
<div
|
| 93 |
-
className={`flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium transition-colors duration-500 ${
|
| 94 |
-
ready ? 'bg-emerald-500/15 text-emerald-300' : 'bg-amber-500/15 text-amber-300'
|
| 95 |
-
}`}
|
| 96 |
-
>
|
| 97 |
<span
|
| 98 |
className={`h-1.5 w-1.5 rounded-full ${
|
| 99 |
-
ready ? 'bg-
|
| 100 |
}`}
|
| 101 |
/>
|
| 102 |
{ready ? t(lang, 'modelReady') : t(lang, 'loadingModel')}
|
|
@@ -104,18 +76,17 @@ export function StepCapture({ lang, engine, modelError, onRetryModel, onCamera,
|
|
| 104 |
)}
|
| 105 |
</div>
|
| 106 |
|
| 107 |
-
{/* Model load error */}
|
| 108 |
{hasError && (
|
| 109 |
-
<div className="mb-4 w-full max-w-sm rounded-2xl border border-red-
|
| 110 |
<div className="flex items-start gap-2.5">
|
| 111 |
-
<AlertTriangle size={18} className="mt-0.5 shrink-0 text-
|
| 112 |
<div className="min-w-0">
|
| 113 |
-
<p className="text-sm font-semibold text-
|
| 114 |
-
<p className="mt-1 break-words text-xs text-
|
| 115 |
<button
|
| 116 |
type="button"
|
| 117 |
onClick={onRetryModel}
|
| 118 |
-
className="mt-3 flex items-center gap-1.5 rounded-xl bg-
|
| 119 |
>
|
| 120 |
<RotateCcw size={13} />
|
| 121 |
{t(lang, 'retry')}
|
|
@@ -125,30 +96,21 @@ export function StepCapture({ lang, engine, modelError, onRetryModel, onCamera,
|
|
| 125 |
</div>
|
| 126 |
)}
|
| 127 |
|
| 128 |
-
{/* CTA buttons */}
|
| 129 |
<div className="w-full max-w-sm space-y-3">
|
| 130 |
-
{/* Primary: Camera */}
|
| 131 |
<button
|
| 132 |
type="button"
|
| 133 |
disabled={hasError}
|
| 134 |
-
className="
|
| 135 |
-
style={{
|
| 136 |
-
background: 'linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%)',
|
| 137 |
-
boxShadow: '0 8px 32px rgba(37,99,235,0.45)',
|
| 138 |
-
}}
|
| 139 |
onClick={onCamera}
|
| 140 |
>
|
| 141 |
-
{/* Shimmer overlay */}
|
| 142 |
-
<span className="pointer-events-none absolute inset-0 bg-gradient-to-r from-transparent via-white/10 to-transparent" />
|
| 143 |
<Camera size={22} strokeWidth={2.5} />
|
| 144 |
{t(lang, 'takePhoto')}
|
| 145 |
</button>
|
| 146 |
|
| 147 |
-
{/* Secondary: Gallery */}
|
| 148 |
<button
|
| 149 |
type="button"
|
| 150 |
disabled={hasError}
|
| 151 |
-
className="
|
| 152 |
onClick={onGallery}
|
| 153 |
>
|
| 154 |
<ImagePlus size={22} strokeWidth={2} />
|
|
@@ -157,9 +119,8 @@ export function StepCapture({ lang, engine, modelError, onRetryModel, onCamera,
|
|
| 157 |
</div>
|
| 158 |
</div>
|
| 159 |
|
| 160 |
-
{/* Footer */}
|
| 161 |
<div className="relative z-10 pb-[max(1.5rem,env(safe-area-inset-bottom))] text-center">
|
| 162 |
-
<p className="text-[11px] tracking-wide text-
|
| 163 |
</div>
|
| 164 |
</div>
|
| 165 |
)
|
|
|
|
| 1 |
+
import { AlertTriangle, Camera, ImagePlus, RotateCcw } from 'lucide-react'
|
| 2 |
import { t } from '../lib/i18n'
|
| 3 |
import type { Lang } from '../lib/types'
|
| 4 |
|
|
|
|
| 16 |
export function StepCapture({ lang, engine, modelError, onRetryModel, onCamera, onGallery }: Props) {
|
| 17 |
const hasError = engine === 'none' || Boolean(modelError)
|
| 18 |
const ready = engine === 'local' || engine === 'server'
|
| 19 |
+
|
| 20 |
return (
|
| 21 |
+
<div className="relative flex flex-1 flex-col overflow-hidden bg-[var(--bg)]">
|
| 22 |
+
{/* soft brand glow */}
|
| 23 |
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
| 24 |
<div
|
| 25 |
+
className="h-[380px] w-[380px] rounded-full"
|
| 26 |
style={{
|
| 27 |
+
background: 'radial-gradient(circle, var(--brand-ring) 0%, transparent 70%)',
|
| 28 |
animation: 'glow-pulse 4s ease-in-out infinite',
|
| 29 |
}}
|
| 30 |
/>
|
| 31 |
</div>
|
| 32 |
|
|
|
|
| 33 |
<div className="relative z-10 flex flex-1 flex-col items-center justify-center px-8">
|
|
|
|
| 34 |
<div className="mb-8 flex flex-col items-center gap-4">
|
| 35 |
<div className="relative">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
<div
|
| 37 |
+
className="relative flex h-28 w-28 items-center justify-center rounded-[1.75rem] bg-[var(--surface)] shadow-[var(--shadow-md)] ring-1 ring-[var(--hairline)]"
|
| 38 |
style={{ animation: 'breathe 3.5s ease-in-out infinite' }}
|
| 39 |
>
|
| 40 |
+
<img src="/icon.svg" alt="" style={{ width: 72, height: 72 }} />
|
|
|
|
|
|
|
| 41 |
<span
|
| 42 |
className={`absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full border-[3px] border-[var(--bg)] transition-all duration-700 ${
|
| 43 |
+
engine === 'none'
|
| 44 |
+
? 'bg-[var(--danger)]'
|
| 45 |
+
: ready
|
| 46 |
+
? 'bg-[var(--success)]'
|
| 47 |
+
: 'animate-pulse bg-[var(--warning)]'
|
|
|
|
|
|
|
| 48 |
}`}
|
| 49 |
/>
|
| 50 |
</div>
|
| 51 |
</div>
|
| 52 |
|
| 53 |
<div className="text-center">
|
| 54 |
+
<h1 className="text-[26px] font-bold tracking-tight text-[var(--text)]">
|
| 55 |
{t(lang, 'title')}
|
| 56 |
</h1>
|
| 57 |
+
<p className="mt-1.5 text-sm text-[var(--text-dim)]">
|
| 58 |
{t(lang, 'captureSubtitle')}
|
| 59 |
</p>
|
| 60 |
</div>
|
| 61 |
|
|
|
|
| 62 |
{hasError ? (
|
| 63 |
+
<button type="button" onClick={onRetryModel} className="ct-badge ct-badge--danger">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
<RotateCcw size={12} />
|
| 65 |
{t(lang, 'retry')}
|
| 66 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
) : (
|
| 68 |
+
<div className={`ct-badge ${ready ? 'ct-badge--success' : 'ct-badge--warning'}`}>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
<span
|
| 70 |
className={`h-1.5 w-1.5 rounded-full ${
|
| 71 |
+
ready ? 'bg-[var(--success)]' : 'animate-pulse bg-[var(--warning)]'
|
| 72 |
}`}
|
| 73 |
/>
|
| 74 |
{ready ? t(lang, 'modelReady') : t(lang, 'loadingModel')}
|
|
|
|
| 76 |
)}
|
| 77 |
</div>
|
| 78 |
|
|
|
|
| 79 |
{hasError && (
|
| 80 |
+
<div className="mb-4 w-full max-w-sm rounded-2xl border border-red-200 bg-[var(--danger-light)] p-4">
|
| 81 |
<div className="flex items-start gap-2.5">
|
| 82 |
+
<AlertTriangle size={18} className="mt-0.5 shrink-0 text-[var(--danger)]" />
|
| 83 |
<div className="min-w-0">
|
| 84 |
+
<p className="text-sm font-semibold text-[var(--danger)]">{t(lang, 'modelErrorTitle')}</p>
|
| 85 |
+
<p className="mt-1 break-words text-xs text-[var(--text-dim)]">{modelError}</p>
|
| 86 |
<button
|
| 87 |
type="button"
|
| 88 |
onClick={onRetryModel}
|
| 89 |
+
className="mt-3 flex items-center gap-1.5 rounded-xl bg-[var(--danger)] px-3 py-1.5 text-xs font-semibold text-white"
|
| 90 |
>
|
| 91 |
<RotateCcw size={13} />
|
| 92 |
{t(lang, 'retry')}
|
|
|
|
| 96 |
</div>
|
| 97 |
)}
|
| 98 |
|
|
|
|
| 99 |
<div className="w-full max-w-sm space-y-3">
|
|
|
|
| 100 |
<button
|
| 101 |
type="button"
|
| 102 |
disabled={hasError}
|
| 103 |
+
className="ct-btn-primary"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
onClick={onCamera}
|
| 105 |
>
|
|
|
|
|
|
|
| 106 |
<Camera size={22} strokeWidth={2.5} />
|
| 107 |
{t(lang, 'takePhoto')}
|
| 108 |
</button>
|
| 109 |
|
|
|
|
| 110 |
<button
|
| 111 |
type="button"
|
| 112 |
disabled={hasError}
|
| 113 |
+
className="ct-btn-secondary"
|
| 114 |
onClick={onGallery}
|
| 115 |
>
|
| 116 |
<ImagePlus size={22} strokeWidth={2} />
|
|
|
|
| 119 |
</div>
|
| 120 |
</div>
|
| 121 |
|
|
|
|
| 122 |
<div className="relative z-10 pb-[max(1.5rem,env(safe-area-inset-bottom))] text-center">
|
| 123 |
+
<p className="text-[11px] tracking-wide text-[var(--text-faint)]">{t(lang, 'company')}</p>
|
| 124 |
</div>
|
| 125 |
</div>
|
| 126 |
)
|
frontend/src/components/StepCounting.tsx
CHANGED
|
@@ -17,18 +17,16 @@ export function StepCounting({ lang, status, imageSrc }: Props) {
|
|
| 17 |
}, [])
|
| 18 |
|
| 19 |
return (
|
| 20 |
-
<div className="relative flex flex-1 flex-col items-center justify-center overflow-hidden">
|
| 21 |
-
{/* Blurred background image */}
|
| 22 |
{imageSrc && (
|
| 23 |
<img
|
| 24 |
src={imageSrc}
|
| 25 |
alt=""
|
| 26 |
aria-hidden
|
| 27 |
-
className="absolute inset-0 h-full w-full scale-110 object-cover opacity-
|
| 28 |
/>
|
| 29 |
)}
|
| 30 |
|
| 31 |
-
{/* Radial vignette overlay */}
|
| 32 |
<div
|
| 33 |
className="pointer-events-none absolute inset-0"
|
| 34 |
style={{
|
|
@@ -37,64 +35,49 @@ export function StepCounting({ lang, status, imageSrc }: Props) {
|
|
| 37 |
/>
|
| 38 |
|
| 39 |
<div className="relative z-10 flex flex-col items-center gap-7 px-8 text-center">
|
| 40 |
-
{/* Concentric ring animation */}
|
| 41 |
<div className="relative flex h-36 w-36 items-center justify-center">
|
| 42 |
-
{/* Three expanding rings with staggered timing */}
|
| 43 |
<span
|
| 44 |
-
className="absolute inset-0 rounded-full border border-
|
| 45 |
style={{ animation: 'ping 2s cubic-bezier(0,0,0.2,1) infinite' }}
|
| 46 |
/>
|
| 47 |
<span
|
| 48 |
-
className="absolute inset-4 rounded-full border border-
|
| 49 |
style={{ animation: 'ping 2s cubic-bezier(0,0,0.2,1) 0.5s infinite' }}
|
| 50 |
/>
|
| 51 |
<span
|
| 52 |
-
className="absolute inset-8 rounded-full border border-
|
| 53 |
style={{ animation: 'ping 2s cubic-bezier(0,0,0.2,1) 1s infinite' }}
|
| 54 |
/>
|
| 55 |
|
| 56 |
-
|
| 57 |
-
<div className="absolute inset-10 rounded-full bg-emerald-500/8 ring-1 ring-emerald-500/40" />
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
className="absolute inset-0 h-full w-full"
|
| 62 |
-
viewBox="0 0 100 100"
|
| 63 |
-
fill="none"
|
| 64 |
-
>
|
| 65 |
<circle
|
| 66 |
cx="50" cy="50" r="44"
|
| 67 |
-
stroke="
|
| 68 |
-
strokeWidth="2"
|
| 69 |
-
/>
|
| 70 |
-
<circle
|
| 71 |
-
cx="50" cy="50" r="44"
|
| 72 |
-
stroke="rgba(16,185,129,0.7)"
|
| 73 |
-
strokeWidth="2"
|
| 74 |
strokeLinecap="round"
|
| 75 |
strokeDasharray="80 196"
|
| 76 |
style={{ animation: 'spin 1.6s linear infinite', transformOrigin: '50% 50%' }}
|
| 77 |
/>
|
| 78 |
</svg>
|
| 79 |
|
| 80 |
-
|
| 81 |
-
<img src="/icon.svg" alt="" className="relative z-10 h-10 w-10 opacity-90" />
|
| 82 |
</div>
|
| 83 |
|
| 84 |
-
{/* Text */}
|
| 85 |
<div>
|
| 86 |
-
<h2 className="text-xl font-
|
| 87 |
{t(lang, 'countingTitle')}{''.padEnd(dots, '.')}
|
| 88 |
</h2>
|
| 89 |
-
<p className="mt-2 min-h-6 text-sm text-
|
| 90 |
{status || t(lang, 'pleaseWait')}
|
| 91 |
</p>
|
| 92 |
</div>
|
| 93 |
|
| 94 |
-
|
| 95 |
-
<div className="h-0.5 w-48 overflow-hidden rounded-full bg-white/10">
|
| 96 |
<div
|
| 97 |
-
className="h-full rounded-full bg-
|
| 98 |
style={{ animation: 'track-slide 1.8s ease-in-out infinite', width: '35%' }}
|
| 99 |
/>
|
| 100 |
</div>
|
|
|
|
| 17 |
}, [])
|
| 18 |
|
| 19 |
return (
|
| 20 |
+
<div className="relative flex flex-1 flex-col items-center justify-center overflow-hidden bg-[var(--bg)]">
|
|
|
|
| 21 |
{imageSrc && (
|
| 22 |
<img
|
| 23 |
src={imageSrc}
|
| 24 |
alt=""
|
| 25 |
aria-hidden
|
| 26 |
+
className="absolute inset-0 h-full w-full scale-110 object-cover opacity-20 blur-2xl"
|
| 27 |
/>
|
| 28 |
)}
|
| 29 |
|
|
|
|
| 30 |
<div
|
| 31 |
className="pointer-events-none absolute inset-0"
|
| 32 |
style={{
|
|
|
|
| 35 |
/>
|
| 36 |
|
| 37 |
<div className="relative z-10 flex flex-col items-center gap-7 px-8 text-center">
|
|
|
|
| 38 |
<div className="relative flex h-36 w-36 items-center justify-center">
|
|
|
|
| 39 |
<span
|
| 40 |
+
className="absolute inset-0 rounded-full border-2 border-[var(--brand-ring)]"
|
| 41 |
style={{ animation: 'ping 2s cubic-bezier(0,0,0.2,1) infinite' }}
|
| 42 |
/>
|
| 43 |
<span
|
| 44 |
+
className="absolute inset-4 rounded-full border-2 border-[var(--brand-muted)]/40"
|
| 45 |
style={{ animation: 'ping 2s cubic-bezier(0,0,0.2,1) 0.5s infinite' }}
|
| 46 |
/>
|
| 47 |
<span
|
| 48 |
+
className="absolute inset-8 rounded-full border-2 border-[var(--brand)]/25"
|
| 49 |
style={{ animation: 'ping 2s cubic-bezier(0,0,0.2,1) 1s infinite' }}
|
| 50 |
/>
|
| 51 |
|
| 52 |
+
<div className="absolute inset-10 rounded-full bg-[var(--brand-light)] ring-2 ring-[var(--brand)]/30" />
|
|
|
|
| 53 |
|
| 54 |
+
<svg className="absolute inset-0 h-full w-full" viewBox="0 0 100 100" fill="none">
|
| 55 |
+
<circle cx="50" cy="50" r="44" stroke="var(--brand-ring)" strokeWidth="2" />
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
<circle
|
| 57 |
cx="50" cy="50" r="44"
|
| 58 |
+
stroke="var(--brand)"
|
| 59 |
+
strokeWidth="2.5"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
strokeLinecap="round"
|
| 61 |
strokeDasharray="80 196"
|
| 62 |
style={{ animation: 'spin 1.6s linear infinite', transformOrigin: '50% 50%' }}
|
| 63 |
/>
|
| 64 |
</svg>
|
| 65 |
|
| 66 |
+
<img src="/icon.svg" alt="" className="relative z-10 h-10 w-10" />
|
|
|
|
| 67 |
</div>
|
| 68 |
|
|
|
|
| 69 |
<div>
|
| 70 |
+
<h2 className="text-xl font-bold tracking-tight text-[var(--text)]">
|
| 71 |
{t(lang, 'countingTitle')}{''.padEnd(dots, '.')}
|
| 72 |
</h2>
|
| 73 |
+
<p className="mt-2 min-h-6 text-sm text-[var(--text-dim)]">
|
| 74 |
{status || t(lang, 'pleaseWait')}
|
| 75 |
</p>
|
| 76 |
</div>
|
| 77 |
|
| 78 |
+
<div className="h-1 w-48 overflow-hidden rounded-full bg-[var(--hairline)]">
|
|
|
|
| 79 |
<div
|
| 80 |
+
className="h-full rounded-full bg-[var(--brand)]"
|
| 81 |
style={{ animation: 'track-slide 1.8s ease-in-out infinite', width: '35%' }}
|
| 82 |
/>
|
| 83 |
</div>
|
frontend/src/components/StepPreview.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import { Camera, ChevronLeft, ImagePlus, Loader2 } from 'lucide-react'
|
| 2 |
import { t } from '../lib/i18n'
|
| 3 |
-
import type {
|
| 4 |
-
import { SettingsPanel } from './SettingsPanel'
|
| 5 |
|
| 6 |
interface Props {
|
| 7 |
lang: Lang
|
|
@@ -9,20 +8,10 @@ interface Props {
|
|
| 9 |
imageDims: { w: number; h: number }
|
| 10 |
busy: boolean
|
| 11 |
modelReady: boolean
|
| 12 |
-
groupCount: number | 'auto'
|
| 13 |
-
inferenceMode: InferenceMode
|
| 14 |
-
serverAvailable: boolean
|
| 15 |
-
useTiling: boolean
|
| 16 |
-
filterOutliers: boolean
|
| 17 |
onBack: () => void
|
| 18 |
onRetake: () => void
|
| 19 |
onGallery: () => void
|
| 20 |
onCount: () => void
|
| 21 |
-
onGroupCount: (v: number | 'auto') => void
|
| 22 |
-
onInferenceMode: (mode: InferenceMode) => void
|
| 23 |
-
onUseTiling: (v: boolean) => void
|
| 24 |
-
onFilterOutliers: (v: boolean) => void
|
| 25 |
-
onRecluster: () => void
|
| 26 |
}
|
| 27 |
|
| 28 |
export function StepPreview({
|
|
@@ -31,107 +20,55 @@ export function StepPreview({
|
|
| 31 |
imageDims,
|
| 32 |
busy,
|
| 33 |
modelReady,
|
| 34 |
-
groupCount,
|
| 35 |
-
inferenceMode,
|
| 36 |
-
serverAvailable,
|
| 37 |
-
useTiling,
|
| 38 |
-
filterOutliers,
|
| 39 |
onBack,
|
| 40 |
onRetake,
|
| 41 |
onGallery,
|
| 42 |
onCount,
|
| 43 |
-
onGroupCount,
|
| 44 |
-
onInferenceMode,
|
| 45 |
-
onUseTiling,
|
| 46 |
-
onFilterOutliers,
|
| 47 |
-
onRecluster,
|
| 48 |
}: Props) {
|
| 49 |
const ar = imageDims.h / Math.max(imageDims.w, 1)
|
| 50 |
-
const maxPreviewH = Math.min(ar * 100,
|
| 51 |
|
| 52 |
return (
|
| 53 |
-
<div className="flex flex-1 flex-col overflow-hidden">
|
| 54 |
-
{/* ββ Navigation bar βββββββββββββββββββββββββββββββββββββββββββ */}
|
| 55 |
<div className="flex items-center justify-between px-4 py-2.5">
|
| 56 |
-
<button
|
| 57 |
-
type="button"
|
| 58 |
-
className="flex h-9 items-center gap-1 rounded-xl bg-white/7 px-3 text-sm font-medium text-white/85 transition-all duration-150 active:scale-95 active:bg-white/12"
|
| 59 |
-
onClick={onBack}
|
| 60 |
-
>
|
| 61 |
<ChevronLeft size={16} strokeWidth={2.5} />
|
| 62 |
{t(lang, 'previewBack')}
|
| 63 |
</button>
|
| 64 |
|
| 65 |
<div className="flex gap-2">
|
| 66 |
-
<button
|
| 67 |
-
type="button"
|
| 68 |
-
className="flex h-9 w-9 items-center justify-center rounded-xl bg-white/7 text-white/70 transition-all duration-150 active:scale-95 active:bg-white/12"
|
| 69 |
-
onClick={onRetake}
|
| 70 |
-
aria-label={t(lang, 'retake')}
|
| 71 |
-
>
|
| 72 |
<Camera size={17} />
|
| 73 |
</button>
|
| 74 |
-
<button
|
| 75 |
-
type="button"
|
| 76 |
-
className="flex h-9 w-9 items-center justify-center rounded-xl bg-white/7 text-white/70 transition-all duration-150 active:scale-95 active:bg-white/12"
|
| 77 |
-
onClick={onGallery}
|
| 78 |
-
aria-label={t(lang, 'chooseFile')}
|
| 79 |
-
>
|
| 80 |
<ImagePlus size={17} />
|
| 81 |
</button>
|
| 82 |
</div>
|
| 83 |
</div>
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
{/* Image dimension tag */}
|
| 94 |
-
<p className="mt-1.5 px-5 text-[11px] text-white/30 tabular-nums">
|
| 95 |
-
{imageDims.w} Γ {imageDims.h}
|
| 96 |
-
</p>
|
| 97 |
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
<
|
| 101 |
-
lang={lang}
|
| 102 |
-
open={true}
|
| 103 |
-
groupCount={groupCount}
|
| 104 |
-
inferenceMode={inferenceMode}
|
| 105 |
-
serverAvailable={serverAvailable}
|
| 106 |
-
useTiling={useTiling}
|
| 107 |
-
filterOutliers={filterOutliers}
|
| 108 |
-
onGroupCount={onGroupCount}
|
| 109 |
-
onInferenceMode={onInferenceMode}
|
| 110 |
-
onUseTiling={onUseTiling}
|
| 111 |
-
onFilterOutliers={onFilterOutliers}
|
| 112 |
-
onRecluster={onRecluster}
|
| 113 |
-
/>
|
| 114 |
</div>
|
| 115 |
|
| 116 |
-
{/* ββ Sticky CTA βββββββββββββββββββββββββββββββββββββββββββββββ */}
|
| 117 |
<div
|
| 118 |
-
className="shrink-0 px-4 pt-3"
|
| 119 |
style={{ paddingBottom: 'max(1rem, env(safe-area-inset-bottom))' }}
|
| 120 |
>
|
| 121 |
-
{/* Separator */}
|
| 122 |
-
<div className="mb-3 h-px bg-gradient-to-r from-transparent via-white/10 to-transparent" />
|
| 123 |
-
|
| 124 |
<button
|
| 125 |
type="button"
|
| 126 |
disabled={busy || !modelReady}
|
| 127 |
-
className="
|
| 128 |
-
style={{
|
| 129 |
-
background: 'linear-gradient(135deg, #059669 0%, #047857 60%, #065f46 100%)',
|
| 130 |
-
boxShadow: '0 8px 28px rgba(5,150,105,0.4)',
|
| 131 |
-
}}
|
| 132 |
onClick={onCount}
|
| 133 |
>
|
| 134 |
-
<span className="pointer-events-none absolute inset-0 bg-gradient-to-r from-transparent via-white/8 to-transparent" />
|
| 135 |
{busy ? <Loader2 className="animate-spin" size={22} /> : null}
|
| 136 |
{t(lang, 'countNow')}
|
| 137 |
</button>
|
|
|
|
| 1 |
import { Camera, ChevronLeft, ImagePlus, Loader2 } from 'lucide-react'
|
| 2 |
import { t } from '../lib/i18n'
|
| 3 |
+
import type { Lang } from '../lib/types'
|
|
|
|
| 4 |
|
| 5 |
interface Props {
|
| 6 |
lang: Lang
|
|
|
|
| 8 |
imageDims: { w: number; h: number }
|
| 9 |
busy: boolean
|
| 10 |
modelReady: boolean
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
onBack: () => void
|
| 12 |
onRetake: () => void
|
| 13 |
onGallery: () => void
|
| 14 |
onCount: () => void
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
}
|
| 16 |
|
| 17 |
export function StepPreview({
|
|
|
|
| 20 |
imageDims,
|
| 21 |
busy,
|
| 22 |
modelReady,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
onBack,
|
| 24 |
onRetake,
|
| 25 |
onGallery,
|
| 26 |
onCount,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}: Props) {
|
| 28 |
const ar = imageDims.h / Math.max(imageDims.w, 1)
|
| 29 |
+
const maxPreviewH = Math.min(ar * 100, 62)
|
| 30 |
|
| 31 |
return (
|
| 32 |
+
<div className="flex flex-1 flex-col overflow-hidden bg-[var(--bg)]">
|
|
|
|
| 33 |
<div className="flex items-center justify-between px-4 py-2.5">
|
| 34 |
+
<button type="button" className="ct-btn-ghost flex h-9 items-center gap-1 px-3 text-sm" onClick={onBack}>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
<ChevronLeft size={16} strokeWidth={2.5} />
|
| 36 |
{t(lang, 'previewBack')}
|
| 37 |
</button>
|
| 38 |
|
| 39 |
<div className="flex gap-2">
|
| 40 |
+
<button type="button" className="ct-btn-ghost h-9 w-9" onClick={onRetake} aria-label={t(lang, 'retake')}>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
<Camera size={17} />
|
| 42 |
</button>
|
| 43 |
+
<button type="button" className="ct-btn-ghost h-9 w-9" onClick={onGallery} aria-label={t(lang, 'chooseFile')}>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
<ImagePlus size={17} />
|
| 45 |
</button>
|
| 46 |
</div>
|
| 47 |
</div>
|
| 48 |
|
| 49 |
+
<div className="flex flex-1 flex-col px-4">
|
| 50 |
+
<div
|
| 51 |
+
className="overflow-hidden rounded-2xl border border-[var(--hairline)] bg-black shadow-[var(--shadow-md)]"
|
| 52 |
+
style={{ flex: '1 1 auto', minHeight: '40vh', maxHeight: `${maxPreviewH}vh` }}
|
| 53 |
+
>
|
| 54 |
+
<img src={imageSrc} alt="Preview" className="h-full w-full object-contain" />
|
| 55 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
+
<p className="mt-2 text-center text-[11px] tabular-nums text-[var(--text-faint)]">
|
| 58 |
+
{imageDims.w} Γ {imageDims.h}
|
| 59 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
</div>
|
| 61 |
|
|
|
|
| 62 |
<div
|
| 63 |
+
className="shrink-0 border-t border-[var(--hairline)] bg-[var(--header-bg)] px-4 pt-3"
|
| 64 |
style={{ paddingBottom: 'max(1rem, env(safe-area-inset-bottom))' }}
|
| 65 |
>
|
|
|
|
|
|
|
|
|
|
| 66 |
<button
|
| 67 |
type="button"
|
| 68 |
disabled={busy || !modelReady}
|
| 69 |
+
className="ct-btn-primary"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
onClick={onCount}
|
| 71 |
>
|
|
|
|
| 72 |
{busy ? <Loader2 className="animate-spin" size={22} /> : null}
|
| 73 |
{t(lang, 'countNow')}
|
| 74 |
</button>
|
frontend/src/components/StepResults.tsx
CHANGED
|
@@ -1,10 +1,8 @@
|
|
| 1 |
import { useRef, useState } from 'react'
|
| 2 |
-
import { Camera, Download, RotateCcw } from 'lucide-react'
|
| 3 |
import { t } from '../lib/i18n'
|
| 4 |
import type { Detection, DiameterGroup, Lang, ToolMode } from '../lib/types'
|
| 5 |
import { ResultCanvas } from './ResultCanvas'
|
| 6 |
-
import {
|
| 7 |
-
import { ToolBar } from './ToolBar'
|
| 8 |
import { ExportSheet } from './ExportSheet'
|
| 9 |
import { exportCanvasPng, exportCsv, exportJson } from '../lib/export'
|
| 10 |
|
|
@@ -39,106 +37,54 @@ export function StepResults({
|
|
| 39 |
const canvasRef = useRef<HTMLCanvasElement | null>(null)
|
| 40 |
|
| 41 |
return (
|
| 42 |
-
<div className="flex flex-1 flex-col overflow-hidden">
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
{
|
| 53 |
-
|
|
|
|
| 54 |
|
| 55 |
-
{
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
{/* Actions */}
|
| 69 |
-
<div className="flex gap-2">
|
| 70 |
-
<button
|
| 71 |
-
type="button"
|
| 72 |
-
className="flex h-9 w-9 items-center justify-center rounded-xl bg-white/7 text-white/70 transition-all duration-150 active:scale-95 active:bg-white/12"
|
| 73 |
-
onClick={() => setExportOpen(true)}
|
| 74 |
-
aria-label={t(lang, 'export')}
|
| 75 |
-
>
|
| 76 |
-
<Download size={17} />
|
| 77 |
-
</button>
|
| 78 |
-
<button
|
| 79 |
-
type="button"
|
| 80 |
-
className="flex h-9 w-9 items-center justify-center rounded-xl bg-emerald-600/80 text-white transition-all duration-150 active:scale-95 active:bg-emerald-500"
|
| 81 |
-
onClick={onRecount}
|
| 82 |
-
aria-label={t(lang, 'recount')}
|
| 83 |
-
>
|
| 84 |
-
<RotateCcw size={17} />
|
| 85 |
-
</button>
|
| 86 |
-
</div>
|
| 87 |
-
</div>
|
| 88 |
-
|
| 89 |
-
{/* ββ Scrollable body ββββββββββββββββββββββββββββββββββββββββββ */}
|
| 90 |
-
<div
|
| 91 |
-
className="native-scroll flex-1 overflow-y-auto px-4"
|
| 92 |
-
style={{ paddingBottom: 'max(1.5rem, env(safe-area-inset-bottom))' }}
|
| 93 |
-
>
|
| 94 |
-
<div className="space-y-4">
|
| 95 |
-
{/* Group summary chips */}
|
| 96 |
-
{groups.length > 1 && (
|
| 97 |
-
<div className="flex flex-wrap gap-2">
|
| 98 |
-
{groups.map((g) => (
|
| 99 |
-
<span
|
| 100 |
-
key={g.id}
|
| 101 |
-
className="inline-flex items-center gap-1.5 rounded-full bg-white/7 px-3 py-1 text-sm font-medium text-white/80 ring-1 ring-white/10"
|
| 102 |
-
>
|
| 103 |
-
<span className="h-2 w-2 rounded-full" style={{ background: g.color }} />
|
| 104 |
-
{g.label}: {counts[g.id] ?? 0}
|
| 105 |
-
</span>
|
| 106 |
-
))}
|
| 107 |
</div>
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
{/* Detection canvas */}
|
| 111 |
-
<ResultCanvas
|
| 112 |
-
image={image}
|
| 113 |
-
detections={detections}
|
| 114 |
-
groups={groups}
|
| 115 |
-
tool={tool}
|
| 116 |
-
selectedGroupId={selectedGroupId}
|
| 117 |
-
onUpdate={onUpdate}
|
| 118 |
-
onCanvasReady={(c) => { canvasRef.current = c }}
|
| 119 |
-
onAnimationComplete={() => setAnimDone(true)}
|
| 120 |
-
countDisplayRef={countDisplayRef}
|
| 121 |
-
/>
|
| 122 |
-
|
| 123 |
-
{/* Correction tools β slide in after animation */}
|
| 124 |
-
{animDone && (
|
| 125 |
-
<div className="rise-enter space-y-4">
|
| 126 |
-
{groups.length > 0 && (
|
| 127 |
-
<GroupPanel
|
| 128 |
-
lang={lang}
|
| 129 |
-
groups={groups}
|
| 130 |
-
counts={counts}
|
| 131 |
-
selectedGroupId={selectedGroupId}
|
| 132 |
-
onSelectGroup={setSelectedGroupId}
|
| 133 |
-
onExpectedChange={onExpectedChange}
|
| 134 |
-
/>
|
| 135 |
-
)}
|
| 136 |
-
<ToolBar lang={lang} tool={tool} onToolChange={setTool} />
|
| 137 |
-
</div>
|
| 138 |
-
)}
|
| 139 |
-
</div>
|
| 140 |
</div>
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
<ExportSheet
|
| 143 |
lang={lang}
|
| 144 |
open={exportOpen}
|
|
|
|
| 1 |
import { useRef, useState } from 'react'
|
|
|
|
| 2 |
import { t } from '../lib/i18n'
|
| 3 |
import type { Detection, DiameterGroup, Lang, ToolMode } from '../lib/types'
|
| 4 |
import { ResultCanvas } from './ResultCanvas'
|
| 5 |
+
import { ResultsDock } from './ResultsDock'
|
|
|
|
| 6 |
import { ExportSheet } from './ExportSheet'
|
| 7 |
import { exportCanvasPng, exportCsv, exportJson } from '../lib/export'
|
| 8 |
|
|
|
|
| 37 |
const canvasRef = useRef<HTMLCanvasElement | null>(null)
|
| 38 |
|
| 39 |
return (
|
| 40 |
+
<div className="flex flex-1 flex-col overflow-hidden bg-[var(--bg)]">
|
| 41 |
+
<div className="native-scroll relative min-h-0 flex-1 overflow-y-auto px-2 pt-2">
|
| 42 |
+
<ResultCanvas
|
| 43 |
+
image={image}
|
| 44 |
+
detections={detections}
|
| 45 |
+
groups={groups}
|
| 46 |
+
tool={tool}
|
| 47 |
+
selectedGroupId={selectedGroupId}
|
| 48 |
+
onUpdate={onUpdate}
|
| 49 |
+
onCanvasReady={(c) => { canvasRef.current = c }}
|
| 50 |
+
onAnimationComplete={() => setAnimDone(true)}
|
| 51 |
+
countDisplayRef={countDisplayRef}
|
| 52 |
+
/>
|
| 53 |
|
| 54 |
+
{!animDone && (
|
| 55 |
+
<div className="pointer-events-none absolute left-1/2 top-3 -translate-x-1/2">
|
| 56 |
+
<div className="rounded-full border border-[var(--hairline)] bg-[var(--surface)]/95 px-5 py-2 shadow-[var(--shadow-md)] backdrop-blur-sm">
|
| 57 |
+
<span
|
| 58 |
+
ref={countDisplayRef}
|
| 59 |
+
className="text-3xl font-bold tabular-nums text-[var(--brand)]"
|
| 60 |
+
>
|
| 61 |
+
0
|
| 62 |
+
</span>
|
| 63 |
+
<span className="ml-2 text-[10px] font-semibold uppercase tracking-widest text-[var(--text-faint)]">
|
| 64 |
+
{t(lang, 'total')}
|
| 65 |
+
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
</div>
|
| 67 |
+
</div>
|
| 68 |
+
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
</div>
|
| 70 |
|
| 71 |
+
{animDone && (
|
| 72 |
+
<ResultsDock
|
| 73 |
+
lang={lang}
|
| 74 |
+
total={detections.length}
|
| 75 |
+
tool={tool}
|
| 76 |
+
groups={groups}
|
| 77 |
+
counts={counts}
|
| 78 |
+
selectedGroupId={selectedGroupId}
|
| 79 |
+
onToolChange={setTool}
|
| 80 |
+
onSelectGroup={setSelectedGroupId}
|
| 81 |
+
onExpectedChange={onExpectedChange}
|
| 82 |
+
onNewPhoto={onNewPhoto}
|
| 83 |
+
onRecount={onRecount}
|
| 84 |
+
onExport={() => setExportOpen(true)}
|
| 85 |
+
/>
|
| 86 |
+
)}
|
| 87 |
+
|
| 88 |
<ExportSheet
|
| 89 |
lang={lang}
|
| 90 |
open={exportOpen}
|
frontend/src/components/ToolBar.tsx
CHANGED
|
@@ -7,13 +7,13 @@ const TOOLS: {
|
|
| 7 |
id: ToolMode
|
| 8 |
icon: typeof Eye
|
| 9 |
labelKey: 'toolView' | 'toolDelete' | 'toolAdd' | 'toolReassign' | 'toolArea'
|
| 10 |
-
|
| 11 |
}[] = [
|
| 12 |
-
{ id: 'view', icon: Eye, labelKey: 'toolView',
|
| 13 |
-
{ id: 'delete', icon: Trash2, labelKey: 'toolDelete',
|
| 14 |
-
{ id: 'add', icon: Plus, labelKey: 'toolAdd',
|
| 15 |
-
{ id: 'reassign', icon: Tag, labelKey: 'toolReassign',
|
| 16 |
-
{ id: 'area', icon: SquareDashed, labelKey: 'toolArea',
|
| 17 |
]
|
| 18 |
|
| 19 |
interface Props {
|
|
@@ -25,14 +25,11 @@ interface Props {
|
|
| 25 |
export function ToolBar({ lang, tool, onToolChange }: Props) {
|
| 26 |
return (
|
| 27 |
<section>
|
| 28 |
-
<p className="mb-2 px-1
|
| 29 |
-
{t(lang, 'tools')}
|
| 30 |
-
</p>
|
| 31 |
|
| 32 |
-
|
| 33 |
-
<div className="overflow-hidden rounded-2xl bg-white/6 p-1.5 ring-1 ring-white/8">
|
| 34 |
<div className="flex gap-1 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
| 35 |
-
{TOOLS.map(({ id, icon: Icon, labelKey,
|
| 36 |
const active = tool === id
|
| 37 |
return (
|
| 38 |
<button
|
|
@@ -41,13 +38,13 @@ export function ToolBar({ lang, tool, onToolChange }: Props) {
|
|
| 41 |
className={cn(
|
| 42 |
'flex shrink-0 items-center gap-1.5 rounded-xl px-3.5 py-2 text-sm font-semibold transition-all duration-200 active:scale-[0.96]',
|
| 43 |
active
|
| 44 |
-
? `${
|
| 45 |
-
: 'text-
|
| 46 |
)}
|
| 47 |
onClick={() => onToolChange(id)}
|
| 48 |
>
|
| 49 |
<Icon size={15} strokeWidth={active ? 2.5 : 2} />
|
| 50 |
-
<span className={active ? 'opacity-100' : 'opacity-
|
| 51 |
{t(lang, labelKey)}
|
| 52 |
</span>
|
| 53 |
</button>
|
|
|
|
| 7 |
id: ToolMode
|
| 8 |
icon: typeof Eye
|
| 9 |
labelKey: 'toolView' | 'toolDelete' | 'toolAdd' | 'toolReassign' | 'toolArea'
|
| 10 |
+
activeClass: string
|
| 11 |
}[] = [
|
| 12 |
+
{ id: 'view', icon: Eye, labelKey: 'toolView', activeClass: 'bg-[var(--text)] text-white' },
|
| 13 |
+
{ id: 'delete', icon: Trash2, labelKey: 'toolDelete', activeClass: 'bg-[var(--danger)] text-white' },
|
| 14 |
+
{ id: 'add', icon: Plus, labelKey: 'toolAdd', activeClass: 'bg-[var(--success)] text-white' },
|
| 15 |
+
{ id: 'reassign', icon: Tag, labelKey: 'toolReassign', activeClass: 'bg-[var(--info)] text-white' },
|
| 16 |
+
{ id: 'area', icon: SquareDashed, labelKey: 'toolArea', activeClass: 'bg-[#7c3aed] text-white' },
|
| 17 |
]
|
| 18 |
|
| 19 |
interface Props {
|
|
|
|
| 25 |
export function ToolBar({ lang, tool, onToolChange }: Props) {
|
| 26 |
return (
|
| 27 |
<section>
|
| 28 |
+
<p className="ct-section-label mb-2 px-1">{t(lang, 'tools')}</p>
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
<div className="ct-card overflow-hidden p-1.5">
|
|
|
|
| 31 |
<div className="flex gap-1 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
| 32 |
+
{TOOLS.map(({ id, icon: Icon, labelKey, activeClass }) => {
|
| 33 |
const active = tool === id
|
| 34 |
return (
|
| 35 |
<button
|
|
|
|
| 38 |
className={cn(
|
| 39 |
'flex shrink-0 items-center gap-1.5 rounded-xl px-3.5 py-2 text-sm font-semibold transition-all duration-200 active:scale-[0.96]',
|
| 40 |
active
|
| 41 |
+
? `${activeClass} shadow-sm`
|
| 42 |
+
: 'text-[var(--text-dim)] active:bg-[var(--surface-2)]',
|
| 43 |
)}
|
| 44 |
onClick={() => onToolChange(id)}
|
| 45 |
>
|
| 46 |
<Icon size={15} strokeWidth={active ? 2.5 : 2} />
|
| 47 |
+
<span className={active ? 'opacity-100' : 'opacity-80'}>
|
| 48 |
{t(lang, labelKey)}
|
| 49 |
</span>
|
| 50 |
</button>
|
frontend/src/index.css
CHANGED
|
@@ -1,37 +1,54 @@
|
|
| 1 |
@import 'tailwindcss';
|
| 2 |
|
| 3 |
/* ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 4 |
-
|
| 5 |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 6 |
:root {
|
| 7 |
-
/* Platform-native font stack: SF Pro on iOS/macOS, Roboto on Android, Segoe UI on Windows */
|
| 8 |
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue',
|
| 9 |
system-ui, 'Segoe UI', Roboto, sans-serif;
|
| 10 |
|
| 11 |
-
/*
|
| 12 |
-
--bg: #
|
| 13 |
-
--
|
| 14 |
-
--surface
|
| 15 |
-
--surface-
|
| 16 |
-
--
|
|
|
|
|
|
|
| 17 |
|
| 18 |
/* text */
|
| 19 |
-
--text: #
|
| 20 |
-
--text-dim:
|
| 21 |
-
--text-faint:
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
--
|
| 26 |
-
--
|
| 27 |
-
--
|
| 28 |
-
--
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
--
|
| 33 |
-
--
|
| 34 |
-
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
/* motion */
|
| 37 |
--ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
|
|
@@ -51,12 +68,10 @@ body {
|
|
| 51 |
margin: 0;
|
| 52 |
min-height: 100dvh;
|
| 53 |
background: var(--bg);
|
| 54 |
-
/* prevent text selection flashes on tap, like a native app */
|
| 55 |
-webkit-user-select: none;
|
| 56 |
user-select: none;
|
| 57 |
}
|
| 58 |
|
| 59 |
-
/* re-enable selection only where it's useful */
|
| 60 |
input,
|
| 61 |
textarea {
|
| 62 |
-webkit-user-select: text;
|
|
@@ -87,7 +102,6 @@ input[type='number']::-webkit-inner-spin-button {
|
|
| 87 |
margin: 0;
|
| 88 |
}
|
| 89 |
|
| 90 |
-
/* momentum scrolling, hidden scrollbars (native feel) */
|
| 91 |
.native-scroll {
|
| 92 |
-webkit-overflow-scrolling: touch;
|
| 93 |
scrollbar-width: none;
|
|
@@ -96,9 +110,101 @@ input[type='number']::-webkit-inner-spin-button {
|
|
| 96 |
display: none;
|
| 97 |
}
|
| 98 |
|
| 99 |
-
/* βββββββββββββββββββββββββββββββββββββ
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
@keyframes nav-push {
|
| 103 |
from { opacity: 0; transform: translateX(28px); }
|
| 104 |
to { opacity: 1; transform: translateX(0); }
|
|
@@ -110,9 +216,12 @@ input[type='number']::-webkit-inner-spin-button {
|
|
| 110 |
.nav-push { animation: nav-push 0.36s var(--ease-ios) both; }
|
| 111 |
.nav-pop { animation: nav-pop 0.36s var(--ease-ios) both; }
|
| 112 |
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
| 116 |
@keyframes sheet-up {
|
| 117 |
from { transform: translateY(100%); }
|
| 118 |
to { transform: translateY(0); }
|
|
@@ -124,23 +233,19 @@ input[type='number']::-webkit-inner-spin-button {
|
|
| 124 |
.sheet-enter { animation: sheet-up 0.42s var(--ease-ios) both; }
|
| 125 |
.overlay-enter { animation: fade-in 0.22s ease-out both; }
|
| 126 |
|
| 127 |
-
/* generic content reveal */
|
| 128 |
@keyframes rise {
|
| 129 |
from { opacity: 0; transform: translateY(16px); }
|
| 130 |
to { opacity: 1; transform: translateY(0); }
|
| 131 |
}
|
| 132 |
.rise-enter { animation: rise 0.34s var(--ease-out) both; }
|
| 133 |
|
| 134 |
-
/* ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 135 |
-
Ambient / loading flourishes
|
| 136 |
-
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 137 |
@keyframes breathe {
|
| 138 |
0%, 100% { transform: scale(1); }
|
| 139 |
-
50% { transform: scale(1.
|
| 140 |
}
|
| 141 |
@keyframes glow-pulse {
|
| 142 |
-
0%, 100% { opacity: 0.
|
| 143 |
-
50% { opacity: 0.
|
| 144 |
}
|
| 145 |
@keyframes spin {
|
| 146 |
to { transform: rotate(360deg); }
|
|
@@ -151,7 +256,6 @@ input[type='number']::-webkit-inner-spin-button {
|
|
| 151 |
100% { transform: translateX(380%); }
|
| 152 |
}
|
| 153 |
|
| 154 |
-
/* respect reduced motion */
|
| 155 |
@media (prefers-reduced-motion: reduce) {
|
| 156 |
*,
|
| 157 |
*::before,
|
|
|
|
| 1 |
@import 'tailwindcss';
|
| 2 |
|
| 3 |
/* ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 4 |
+
CountThings-inspired light industrial theme
|
| 5 |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 6 |
:root {
|
|
|
|
| 7 |
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue',
|
| 8 |
system-ui, 'Segoe UI', Roboto, sans-serif;
|
| 9 |
|
| 10 |
+
/* canvas */
|
| 11 |
+
--bg: #eef0f4;
|
| 12 |
+
--header-bg: #ffffff;
|
| 13 |
+
--surface: #ffffff;
|
| 14 |
+
--surface-2: #f8f9fb;
|
| 15 |
+
--surface-active: #fff4eb;
|
| 16 |
+
--hairline: #e2e8f0;
|
| 17 |
+
--border: #d8dee8;
|
| 18 |
|
| 19 |
/* text */
|
| 20 |
+
--text: #1e293b;
|
| 21 |
+
--text-dim: #64748b;
|
| 22 |
+
--text-faint: #94a3b8;
|
| 23 |
+
--text-inverse: #ffffff;
|
| 24 |
+
|
| 25 |
+
/* brand β CountThings orange */
|
| 26 |
+
--brand: #e85d04;
|
| 27 |
+
--brand-hover: #cf5203;
|
| 28 |
+
--brand-light: #fff4eb;
|
| 29 |
+
--brand-muted: #fdba74;
|
| 30 |
+
--brand-ring: rgba(232, 93, 4, 0.22);
|
| 31 |
+
|
| 32 |
+
/* semantic */
|
| 33 |
+
--success: #16a34a;
|
| 34 |
+
--success-light: #dcfce7;
|
| 35 |
+
--info: #2563eb;
|
| 36 |
+
--info-light: #dbeafe;
|
| 37 |
+
--danger: #dc2626;
|
| 38 |
+
--danger-light: #fee2e2;
|
| 39 |
+
--warning: #d97706;
|
| 40 |
+
--warning-light: #fef3c7;
|
| 41 |
+
|
| 42 |
+
--ios-toggle: #e85d04;
|
| 43 |
+
|
| 44 |
+
/* shape & elevation */
|
| 45 |
+
--r-sm: 0.625rem;
|
| 46 |
+
--r-md: 0.875rem;
|
| 47 |
+
--r-lg: 1rem;
|
| 48 |
+
--r-xl: 1.25rem;
|
| 49 |
+
--shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
|
| 50 |
+
--shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
|
| 51 |
+
--shadow-brand: 0 6px 20px rgba(232, 93, 4, 0.28);
|
| 52 |
|
| 53 |
/* motion */
|
| 54 |
--ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
|
|
|
|
| 68 |
margin: 0;
|
| 69 |
min-height: 100dvh;
|
| 70 |
background: var(--bg);
|
|
|
|
| 71 |
-webkit-user-select: none;
|
| 72 |
user-select: none;
|
| 73 |
}
|
| 74 |
|
|
|
|
| 75 |
input,
|
| 76 |
textarea {
|
| 77 |
-webkit-user-select: text;
|
|
|
|
| 102 |
margin: 0;
|
| 103 |
}
|
| 104 |
|
|
|
|
| 105 |
.native-scroll {
|
| 106 |
-webkit-overflow-scrolling: touch;
|
| 107 |
scrollbar-width: none;
|
|
|
|
| 110 |
display: none;
|
| 111 |
}
|
| 112 |
|
| 113 |
+
/* ββ Reusable UI primitives βββββββββββββββββββββββββββββββββββ */
|
| 114 |
+
.ct-header {
|
| 115 |
+
background: var(--header-bg);
|
| 116 |
+
border-bottom: 1px solid var(--hairline);
|
| 117 |
+
box-shadow: var(--shadow-sm);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
.ct-card {
|
| 121 |
+
background: var(--surface);
|
| 122 |
+
border: 1px solid var(--hairline);
|
| 123 |
+
border-radius: var(--r-lg);
|
| 124 |
+
box-shadow: var(--shadow-sm);
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
.ct-section-label {
|
| 128 |
+
font-size: 0.6875rem;
|
| 129 |
+
font-weight: 600;
|
| 130 |
+
letter-spacing: 0.08em;
|
| 131 |
+
text-transform: uppercase;
|
| 132 |
+
color: var(--text-faint);
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
.ct-btn-primary {
|
| 136 |
+
display: flex;
|
| 137 |
+
align-items: center;
|
| 138 |
+
justify-content: center;
|
| 139 |
+
gap: 0.75rem;
|
| 140 |
+
min-height: 3.5rem;
|
| 141 |
+
width: 100%;
|
| 142 |
+
border-radius: var(--r-lg);
|
| 143 |
+
background: var(--brand);
|
| 144 |
+
color: var(--text-inverse);
|
| 145 |
+
font-size: 1rem;
|
| 146 |
+
font-weight: 700;
|
| 147 |
+
box-shadow: var(--shadow-brand);
|
| 148 |
+
transition: transform 0.15s, background 0.15s;
|
| 149 |
+
}
|
| 150 |
+
.ct-btn-primary:active:not(:disabled) {
|
| 151 |
+
transform: scale(0.98);
|
| 152 |
+
background: var(--brand-hover);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.ct-btn-secondary {
|
| 156 |
+
display: flex;
|
| 157 |
+
align-items: center;
|
| 158 |
+
justify-content: center;
|
| 159 |
+
gap: 0.75rem;
|
| 160 |
+
min-height: 3.5rem;
|
| 161 |
+
width: 100%;
|
| 162 |
+
border-radius: var(--r-lg);
|
| 163 |
+
border: 1px solid var(--border);
|
| 164 |
+
background: var(--surface);
|
| 165 |
+
color: var(--text);
|
| 166 |
+
font-size: 1rem;
|
| 167 |
+
font-weight: 600;
|
| 168 |
+
box-shadow: var(--shadow-sm);
|
| 169 |
+
transition: transform 0.15s, background 0.15s;
|
| 170 |
+
}
|
| 171 |
+
.ct-btn-secondary:active:not(:disabled) {
|
| 172 |
+
transform: scale(0.98);
|
| 173 |
+
background: var(--surface-2);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
.ct-btn-ghost {
|
| 177 |
+
display: flex;
|
| 178 |
+
align-items: center;
|
| 179 |
+
justify-content: center;
|
| 180 |
+
border-radius: var(--r-md);
|
| 181 |
+
background: var(--surface-2);
|
| 182 |
+
border: 1px solid var(--hairline);
|
| 183 |
+
color: var(--text-dim);
|
| 184 |
+
font-weight: 600;
|
| 185 |
+
transition: background 0.15s, transform 0.15s;
|
| 186 |
+
}
|
| 187 |
+
.ct-btn-ghost:active {
|
| 188 |
+
transform: scale(0.96);
|
| 189 |
+
background: var(--surface-active);
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
.ct-badge {
|
| 193 |
+
display: inline-flex;
|
| 194 |
+
align-items: center;
|
| 195 |
+
gap: 0.375rem;
|
| 196 |
+
border-radius: 9999px;
|
| 197 |
+
padding: 0.25rem 0.75rem;
|
| 198 |
+
font-size: 0.75rem;
|
| 199 |
+
font-weight: 600;
|
| 200 |
+
}
|
| 201 |
+
.ct-badge--brand { background: var(--brand-light); color: var(--brand); }
|
| 202 |
+
.ct-badge--success { background: var(--success-light); color: var(--success); }
|
| 203 |
+
.ct-badge--info { background: var(--info-light); color: var(--info); }
|
| 204 |
+
.ct-badge--warning { background: var(--warning-light); color: var(--warning); }
|
| 205 |
+
.ct-badge--danger { background: var(--danger-light); color: var(--danger); }
|
| 206 |
+
|
| 207 |
+
/* ββ Navigation transitions βββββββββββββββββββββββββββββββββββ */
|
| 208 |
@keyframes nav-push {
|
| 209 |
from { opacity: 0; transform: translateX(28px); }
|
| 210 |
to { opacity: 1; transform: translateX(0); }
|
|
|
|
| 216 |
.nav-push { animation: nav-push 0.36s var(--ease-ios) both; }
|
| 217 |
.nav-pop { animation: nav-pop 0.36s var(--ease-ios) both; }
|
| 218 |
|
| 219 |
+
@keyframes drawer-in {
|
| 220 |
+
from { transform: translateX(100%); }
|
| 221 |
+
to { transform: translateX(0); }
|
| 222 |
+
}
|
| 223 |
+
.drawer-enter { animation: drawer-in 0.38s var(--ease-ios) both; }
|
| 224 |
+
|
| 225 |
@keyframes sheet-up {
|
| 226 |
from { transform: translateY(100%); }
|
| 227 |
to { transform: translateY(0); }
|
|
|
|
| 233 |
.sheet-enter { animation: sheet-up 0.42s var(--ease-ios) both; }
|
| 234 |
.overlay-enter { animation: fade-in 0.22s ease-out both; }
|
| 235 |
|
|
|
|
| 236 |
@keyframes rise {
|
| 237 |
from { opacity: 0; transform: translateY(16px); }
|
| 238 |
to { opacity: 1; transform: translateY(0); }
|
| 239 |
}
|
| 240 |
.rise-enter { animation: rise 0.34s var(--ease-out) both; }
|
| 241 |
|
|
|
|
|
|
|
|
|
|
| 242 |
@keyframes breathe {
|
| 243 |
0%, 100% { transform: scale(1); }
|
| 244 |
+
50% { transform: scale(1.03); }
|
| 245 |
}
|
| 246 |
@keyframes glow-pulse {
|
| 247 |
+
0%, 100% { opacity: 0.5; transform: scale(1); }
|
| 248 |
+
50% { opacity: 0.75; transform: scale(1.06); }
|
| 249 |
}
|
| 250 |
@keyframes spin {
|
| 251 |
to { transform: rotate(360deg); }
|
|
|
|
| 256 |
100% { transform: translateX(380%); }
|
| 257 |
}
|
| 258 |
|
|
|
|
| 259 |
@media (prefers-reduced-motion: reduce) {
|
| 260 |
*,
|
| 261 |
*::before,
|
frontend/src/lib/constants.ts
CHANGED
|
@@ -3,7 +3,7 @@ export const MODEL_640_URL = '/models/countmodel-640.onnx'
|
|
| 3 |
export const MODEL_INT8_URL = '/models/countmodel-int8.onnx'
|
| 4 |
export const INFERENCE_SIZE = 1024
|
| 5 |
export const INFERENCE_SIZE_SMALL = 640
|
| 6 |
-
export const CONFIDENCE_THRESHOLD = 0.
|
| 7 |
export const IOU_THRESHOLD = 0.45
|
| 8 |
export const MAX_DETECTIONS = 4000
|
| 9 |
|
|
|
|
| 3 |
export const MODEL_INT8_URL = '/models/countmodel-int8.onnx'
|
| 4 |
export const INFERENCE_SIZE = 1024
|
| 5 |
export const INFERENCE_SIZE_SMALL = 640
|
| 6 |
+
export const CONFIDENCE_THRESHOLD = 0.72
|
| 7 |
export const IOU_THRESHOLD = 0.45
|
| 8 |
export const MAX_DETECTIONS = 4000
|
| 9 |
|
frontend/vite.config.ts
CHANGED
|
@@ -14,8 +14,8 @@ export default defineConfig({
|
|
| 14 |
name: 'NPI Pipe Count',
|
| 15 |
short_name: 'Pipe Count',
|
| 16 |
description: 'Offline pipe counting with diameter sorting',
|
| 17 |
-
theme_color: '#
|
| 18 |
-
background_color: '#
|
| 19 |
display: 'standalone',
|
| 20 |
orientation: 'portrait',
|
| 21 |
start_url: '/',
|
|
|
|
| 14 |
name: 'NPI Pipe Count',
|
| 15 |
short_name: 'Pipe Count',
|
| 16 |
description: 'Offline pipe counting with diameter sorting',
|
| 17 |
+
theme_color: '#e85d04',
|
| 18 |
+
background_color: '#eef0f4',
|
| 19 |
display: 'standalone',
|
| 20 |
orientation: 'portrait',
|
| 21 |
start_url: '/',
|
scripts/test_samples.py
CHANGED
|
@@ -15,7 +15,7 @@ ROOT = Path(__file__).resolve().parents[1]
|
|
| 15 |
MODEL_DIR = ROOT / "frontend" / "public" / "models"
|
| 16 |
INFERENCE_SIZE = 1024
|
| 17 |
INFERENCE_SIZE_SMALL = 640
|
| 18 |
-
CONF_THRESHOLD = 0.
|
| 19 |
IOU_THRESHOLD = 0.45
|
| 20 |
MAX_DET = 4000
|
| 21 |
TILE_OVERLAP = 0.2
|
|
|
|
| 15 |
MODEL_DIR = ROOT / "frontend" / "public" / "models"
|
| 16 |
INFERENCE_SIZE = 1024
|
| 17 |
INFERENCE_SIZE_SMALL = 640
|
| 18 |
+
CONF_THRESHOLD = 0.72
|
| 19 |
IOU_THRESHOLD = 0.45
|
| 20 |
MAX_DET = 4000
|
| 21 |
TILE_OVERLAP = 0.2
|