Spaces:
Runtime error
Runtime error
Khunndev Cursor commited on
Commit Β·
445c3cc
1
Parent(s): 7a0d096
Improve UX/UI for native mobile app feel
Browse filesCo-authored-by: Cursor <cursoragent@cursor.com>
- frontend/src/App.tsx +107 -67
- frontend/src/components/ExportSheet.tsx +59 -29
- frontend/src/components/GroupPanel.tsx +58 -37
- frontend/src/components/SettingsPanel.tsx +92 -48
- frontend/src/components/StepCapture.tsx +96 -34
- frontend/src/components/StepCounting.tsx +69 -23
- frontend/src/components/StepPreview.tsx +30 -23
- frontend/src/components/StepResults.tsx +39 -27
- frontend/src/components/ToolBar.tsx +40 -25
- frontend/src/index.css +40 -2
frontend/src/App.tsx
CHANGED
|
@@ -10,6 +10,8 @@ import { StepResults } from './components/StepResults'
|
|
| 10 |
|
| 11 |
type Step = 'capture' | 'preview' | 'counting' | 'results'
|
| 12 |
|
|
|
|
|
|
|
| 13 |
export default function App() {
|
| 14 |
const [step, setStep] = useState<Step>('capture')
|
| 15 |
const [lang, setLang] = useState<Lang>('th')
|
|
@@ -110,95 +112,133 @@ export default function App() {
|
|
| 110 |
}
|
| 111 |
|
| 112 |
// -------------------------------------------------------------------------
|
| 113 |
-
//
|
| 114 |
// -------------------------------------------------------------------------
|
| 115 |
-
const STEPS: Step[] = ['capture', 'preview', 'counting', 'results']
|
| 116 |
const stepIdx = STEPS.indexOf(step)
|
| 117 |
|
| 118 |
return (
|
| 119 |
-
<div className="fixed inset-0 flex flex-col overflow-hidden bg-
|
| 120 |
-
{/*
|
| 121 |
-
<header
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
<div className="flex items-center gap-2.5">
|
| 123 |
-
<
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
</div>
|
| 126 |
|
| 127 |
-
{/*
|
| 128 |
-
<div className="flex items-center gap-1
|
| 129 |
{STEPS.map((s, i) => (
|
| 130 |
<span
|
| 131 |
key={s}
|
| 132 |
-
className={`h-1
|
| 133 |
-
i === stepIdx
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
}`}
|
| 135 |
/>
|
| 136 |
))}
|
| 137 |
</div>
|
| 138 |
|
|
|
|
| 139 |
<button
|
| 140 |
type="button"
|
| 141 |
-
className="rounded-lg bg-
|
| 142 |
onClick={() => setLang(lang === 'th' ? 'en' : 'th')}
|
| 143 |
>
|
| 144 |
-
{lang === 'th' ? 'EN' : '
|
| 145 |
</button>
|
|
|
|
|
|
|
|
|
|
| 146 |
</header>
|
| 147 |
|
| 148 |
-
{/*
|
| 149 |
-
{step =
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
</div>
|
| 203 |
)
|
| 204 |
}
|
|
|
|
| 10 |
|
| 11 |
type Step = 'capture' | 'preview' | 'counting' | 'results'
|
| 12 |
|
| 13 |
+
const STEPS: Step[] = ['capture', 'preview', 'counting', 'results']
|
| 14 |
+
|
| 15 |
export default function App() {
|
| 16 |
const [step, setStep] = useState<Step>('capture')
|
| 17 |
const [lang, setLang] = useState<Lang>('th')
|
|
|
|
| 112 |
}
|
| 113 |
|
| 114 |
// -------------------------------------------------------------------------
|
| 115 |
+
// header step indicator
|
| 116 |
// -------------------------------------------------------------------------
|
|
|
|
| 117 |
const stepIdx = STEPS.indexOf(step)
|
| 118 |
|
| 119 |
return (
|
| 120 |
+
<div className="fixed inset-0 flex flex-col overflow-hidden bg-[#020617]">
|
| 121 |
+
{/* ββ Header ββββββββββββββββββββββββββββββββββββββββββββββββββββ */}
|
| 122 |
+
<header
|
| 123 |
+
className="relative flex shrink-0 items-center justify-between bg-[#020617] px-4"
|
| 124 |
+
style={{
|
| 125 |
+
paddingTop: 'max(0.75rem, env(safe-area-inset-top))',
|
| 126 |
+
paddingBottom: '0.625rem',
|
| 127 |
+
}}
|
| 128 |
+
>
|
| 129 |
+
{/* App brand */}
|
| 130 |
<div className="flex items-center gap-2.5">
|
| 131 |
+
<div className="relative">
|
| 132 |
+
<img src="/icon.svg" alt="" className="h-7 w-7 rounded-xl" />
|
| 133 |
+
<span
|
| 134 |
+
className={`absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full border-2 border-[#020617] transition-colors duration-700 ${
|
| 135 |
+
modelReady ? 'bg-emerald-400' : 'animate-pulse bg-amber-400'
|
| 136 |
+
}`}
|
| 137 |
+
/>
|
| 138 |
+
</div>
|
| 139 |
+
<span className="text-[15px] font-semibold tracking-tight text-white">
|
| 140 |
+
{t(lang, 'title')}
|
| 141 |
+
</span>
|
| 142 |
</div>
|
| 143 |
|
| 144 |
+
{/* Step progress pills */}
|
| 145 |
+
<div className="flex items-center gap-1">
|
| 146 |
{STEPS.map((s, i) => (
|
| 147 |
<span
|
| 148 |
key={s}
|
| 149 |
+
className={`h-1 rounded-full transition-all duration-500 ease-out ${
|
| 150 |
+
i === stepIdx
|
| 151 |
+
? 'w-6 bg-white'
|
| 152 |
+
: i < stepIdx
|
| 153 |
+
? 'w-2 bg-white/40'
|
| 154 |
+
: 'w-2 bg-white/15'
|
| 155 |
}`}
|
| 156 |
/>
|
| 157 |
))}
|
| 158 |
</div>
|
| 159 |
|
| 160 |
+
{/* Lang toggle */}
|
| 161 |
<button
|
| 162 |
type="button"
|
| 163 |
+
className="rounded-lg bg-white/8 px-3 py-1.5 text-xs font-semibold text-white/70 transition-all duration-150 active:scale-95 active:bg-white/15"
|
| 164 |
onClick={() => setLang(lang === 'th' ? 'en' : 'th')}
|
| 165 |
>
|
| 166 |
+
{lang === 'th' ? 'EN' : 'ΰΈ '}
|
| 167 |
</button>
|
| 168 |
+
|
| 169 |
+
{/* Bottom separator β subtle gradient line */}
|
| 170 |
+
<div className="absolute inset-x-0 bottom-0 h-px bg-gradient-to-r from-transparent via-white/10 to-transparent" />
|
| 171 |
</header>
|
| 172 |
|
| 173 |
+
{/* ββ Step views β key forces remount β triggers step-enter CSS animation ββ */}
|
| 174 |
+
<div key={step} className="step-enter flex flex-1 flex-col overflow-hidden">
|
| 175 |
+
{step === 'capture' && (
|
| 176 |
+
<StepCapture
|
| 177 |
+
lang={lang}
|
| 178 |
+
modelReady={modelReady}
|
| 179 |
+
onCamera={() => cameraRef.current?.click()}
|
| 180 |
+
onGallery={() => fileRef.current?.click()}
|
| 181 |
+
/>
|
| 182 |
+
)}
|
| 183 |
+
|
| 184 |
+
{step === 'preview' && image && (
|
| 185 |
+
<StepPreview
|
| 186 |
+
lang={lang}
|
| 187 |
+
imageSrc={imageSrc}
|
| 188 |
+
imageDims={imageDims}
|
| 189 |
+
busy={busy}
|
| 190 |
+
modelReady={modelReady}
|
| 191 |
+
groupCount={groupCount}
|
| 192 |
+
enhanceImage={enhanceImage}
|
| 193 |
+
useTiling={useTiling}
|
| 194 |
+
filterOutliers={filterOutliers}
|
| 195 |
+
onBack={resetToCapture}
|
| 196 |
+
onRetake={() => cameraRef.current?.click()}
|
| 197 |
+
onGallery={() => fileRef.current?.click()}
|
| 198 |
+
onCount={runCount}
|
| 199 |
+
onGroupCount={setGroupCount}
|
| 200 |
+
onEnhanceImage={setEnhanceImage}
|
| 201 |
+
onUseTiling={setUseTiling}
|
| 202 |
+
onFilterOutliers={setFilterOutliers}
|
| 203 |
+
onRecluster={recluster}
|
| 204 |
+
/>
|
| 205 |
+
)}
|
| 206 |
+
|
| 207 |
+
{step === 'counting' && (
|
| 208 |
+
<StepCounting lang={lang} status={status} imageSrc={imageSrc} />
|
| 209 |
+
)}
|
| 210 |
+
|
| 211 |
+
{step === 'results' && image && (
|
| 212 |
+
<StepResults
|
| 213 |
+
lang={lang}
|
| 214 |
+
image={image}
|
| 215 |
+
detections={detections}
|
| 216 |
+
groups={groups}
|
| 217 |
+
counts={counts}
|
| 218 |
+
onUpdate={setDetections}
|
| 219 |
+
onExpectedChange={handleExpectedChange}
|
| 220 |
+
onRecount={() => { setStep('preview') }}
|
| 221 |
+
onNewPhoto={resetToCapture}
|
| 222 |
+
/>
|
| 223 |
+
)}
|
| 224 |
+
</div>
|
| 225 |
+
|
| 226 |
+
{/* ββ Hidden file inputs βββββββββββββββββββββββββββββββββββββββ */}
|
| 227 |
+
<input
|
| 228 |
+
ref={fileRef}
|
| 229 |
+
type="file"
|
| 230 |
+
accept="image/*"
|
| 231 |
+
className="hidden"
|
| 232 |
+
onChange={(e) => e.target.files?.[0] && loadFile(e.target.files[0])}
|
| 233 |
+
/>
|
| 234 |
+
<input
|
| 235 |
+
ref={cameraRef}
|
| 236 |
+
type="file"
|
| 237 |
+
accept="image/*"
|
| 238 |
+
capture="environment"
|
| 239 |
+
className="hidden"
|
| 240 |
+
onChange={(e) => e.target.files?.[0] && loadFile(e.target.files[0])}
|
| 241 |
+
/>
|
| 242 |
</div>
|
| 243 |
)
|
| 244 |
}
|
frontend/src/components/ExportSheet.tsx
CHANGED
|
@@ -23,57 +23,87 @@ export function ExportSheet({
|
|
| 23 |
canExportPng,
|
| 24 |
canExportData,
|
| 25 |
}: Props) {
|
| 26 |
-
if (!open)
|
| 27 |
-
return null
|
| 28 |
-
}
|
| 29 |
|
| 30 |
return (
|
| 31 |
<>
|
|
|
|
| 32 |
<button
|
| 33 |
type="button"
|
| 34 |
-
className="fixed inset-0 z-50 bg-
|
| 35 |
aria-label="Close"
|
| 36 |
onClick={onClose}
|
| 37 |
/>
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
<button
|
| 43 |
type="button"
|
| 44 |
disabled={!canExportPng}
|
| 45 |
-
className="flex min-h-
|
| 46 |
-
onClick={() => {
|
| 47 |
-
onExportPng()
|
| 48 |
-
onClose()
|
| 49 |
-
}}
|
| 50 |
>
|
| 51 |
-
<
|
| 52 |
-
|
|
|
|
|
|
|
| 53 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
<button
|
| 55 |
type="button"
|
| 56 |
disabled={!canExportData}
|
| 57 |
-
className="flex min-h-
|
| 58 |
-
onClick={() => {
|
| 59 |
-
onExportJson()
|
| 60 |
-
onClose()
|
| 61 |
-
}}
|
| 62 |
>
|
| 63 |
-
<
|
| 64 |
-
|
|
|
|
|
|
|
| 65 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
<button
|
| 67 |
type="button"
|
| 68 |
disabled={!canExportData}
|
| 69 |
-
className="flex min-h-
|
| 70 |
-
onClick={() => {
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
>
|
| 75 |
-
|
| 76 |
-
{t(lang, 'exportCsv')}
|
| 77 |
</button>
|
| 78 |
</div>
|
| 79 |
</div>
|
|
|
|
| 23 |
canExportPng,
|
| 24 |
canExportData,
|
| 25 |
}: Props) {
|
| 26 |
+
if (!open) return null
|
|
|
|
|
|
|
| 27 |
|
| 28 |
return (
|
| 29 |
<>
|
| 30 |
+
{/* Backdrop */}
|
| 31 |
<button
|
| 32 |
type="button"
|
| 33 |
+
className="overlay-enter fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"
|
| 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-[#111827] ring-1 ring-white/10 shadow-2xl"
|
| 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-white/20" />
|
| 46 |
+
</div>
|
| 47 |
+
|
| 48 |
+
{/* Title */}
|
| 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 |
+
{/* Actions */}
|
| 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-white/8"
|
| 60 |
+
onClick={() => { onExportPng(); onClose() }}
|
|
|
|
|
|
|
|
|
|
| 61 |
>
|
| 62 |
+
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-blue-500/20">
|
| 63 |
+
<Image size={18} className="text-blue-400" />
|
| 64 |
+
</span>
|
| 65 |
+
<span className="text-[15px] font-medium text-white/90">{t(lang, 'exportPng')}</span>
|
| 66 |
</button>
|
| 67 |
+
|
| 68 |
+
<div className="ml-[3.25rem] h-px bg-white/8" />
|
| 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-white/8"
|
| 75 |
+
onClick={() => { onExportJson(); onClose() }}
|
|
|
|
|
|
|
|
|
|
| 76 |
>
|
| 77 |
+
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-amber-500/20">
|
| 78 |
+
<FileJson size={18} className="text-amber-400" />
|
| 79 |
+
</span>
|
| 80 |
+
<span className="text-[15px] font-medium text-white/90">{t(lang, 'exportJson')}</span>
|
| 81 |
</button>
|
| 82 |
+
|
| 83 |
+
<div className="ml-[3.25rem] h-px bg-white/8" />
|
| 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-white/8"
|
| 90 |
+
onClick={() => { onExportCsv(); onClose() }}
|
| 91 |
+
>
|
| 92 |
+
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-emerald-500/20">
|
| 93 |
+
<FileSpreadsheet size={18} className="text-emerald-400" />
|
| 94 |
+
</span>
|
| 95 |
+
<span className="text-[15px] font-medium text-white/90">{t(lang, 'exportCsv')}</span>
|
| 96 |
+
</button>
|
| 97 |
+
</div>
|
| 98 |
+
|
| 99 |
+
{/* Cancel */}
|
| 100 |
+
<div className="mx-4 mt-2.5">
|
| 101 |
+
<button
|
| 102 |
+
type="button"
|
| 103 |
+
className="flex min-h-[50px] w-full items-center justify-center rounded-2xl bg-white/7 text-[15px] font-semibold text-white/70 transition-colors duration-150 active:bg-white/12"
|
| 104 |
+
onClick={onClose}
|
| 105 |
>
|
| 106 |
+
Cancel
|
|
|
|
| 107 |
</button>
|
| 108 |
</div>
|
| 109 |
</div>
|
frontend/src/components/GroupPanel.tsx
CHANGED
|
@@ -22,51 +22,72 @@ export function GroupPanel({
|
|
| 22 |
}: Props) {
|
| 23 |
return (
|
| 24 |
<section>
|
| 25 |
-
<
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
const count = counts[g.id] ?? 0
|
| 29 |
const mismatch = g.expected !== undefined && g.expected !== count
|
| 30 |
const selected = selectedGroupId === g.id
|
|
|
|
| 31 |
return (
|
| 32 |
-
<
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
<span
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
</div>
|
| 48 |
-
<div className="mt-3 flex items-center gap-2 text-xs text-slate-400">
|
| 49 |
-
<label htmlFor={`exp-${g.id}`}>{t(lang, 'expected')}:</label>
|
| 50 |
-
<input
|
| 51 |
-
id={`exp-${g.id}`}
|
| 52 |
-
type="number"
|
| 53 |
-
inputMode="numeric"
|
| 54 |
-
min={0}
|
| 55 |
-
className="h-9 w-20 rounded-lg border border-slate-600 bg-slate-950 px-2 text-sm text-white"
|
| 56 |
-
value={g.expected ?? ''}
|
| 57 |
-
onChange={(e) => {
|
| 58 |
-
const v = e.target.value
|
| 59 |
-
onExpectedChange(g.id, v === '' ? undefined : Number(v))
|
| 60 |
-
}}
|
| 61 |
-
onClick={(e) => e.stopPropagation()}
|
| 62 |
/>
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
)
|
| 67 |
})}
|
| 68 |
</div>
|
| 69 |
-
|
|
|
|
| 70 |
</section>
|
| 71 |
)
|
| 72 |
}
|
|
|
|
| 22 |
}: Props) {
|
| 23 |
return (
|
| 24 |
<section>
|
| 25 |
+
<p className="mb-2 px-1 text-[11px] font-medium uppercase tracking-widest text-white/30">
|
| 26 |
+
{t(lang, 'groups')}
|
| 27 |
+
</p>
|
| 28 |
+
|
| 29 |
+
<div className="overflow-hidden rounded-2xl bg-white/6 ring-1 ring-white/8">
|
| 30 |
+
{groups.map((g, idx) => {
|
| 31 |
const count = counts[g.id] ?? 0
|
| 32 |
const mismatch = g.expected !== undefined && g.expected !== count
|
| 33 |
const selected = selectedGroupId === g.id
|
| 34 |
+
|
| 35 |
return (
|
| 36 |
+
<div key={g.id}>
|
| 37 |
+
{idx > 0 && <div className="ml-4 h-px bg-white/8" />}
|
| 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-white/8' : 'active:bg-white/5',
|
| 45 |
+
)}
|
| 46 |
+
>
|
| 47 |
+
{/* Color swatch */}
|
| 48 |
+
<span
|
| 49 |
+
className="h-3 w-3 shrink-0 rounded-full ring-2 ring-white/20"
|
| 50 |
+
style={{ background: g.color }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
/>
|
| 52 |
+
|
| 53 |
+
{/* Label */}
|
| 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-amber-400">β {g.expected}</span>
|
| 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-white/12 bg-white/8 px-2.5 text-center text-sm text-white placeholder:text-white/25 focus:outline-none focus:ring-1 focus:ring-white/30"
|
| 67 |
+
value={g.expected ?? ''}
|
| 68 |
+
onChange={(e) => {
|
| 69 |
+
const v = e.target.value
|
| 70 |
+
onExpectedChange(g.id, v === '' ? undefined : Number(v))
|
| 71 |
+
}}
|
| 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-amber-400' : 'text-white',
|
| 80 |
+
)}
|
| 81 |
+
>
|
| 82 |
+
{count}
|
| 83 |
+
</span>
|
| 84 |
+
</button>
|
| 85 |
+
</div>
|
| 86 |
)
|
| 87 |
})}
|
| 88 |
</div>
|
| 89 |
+
|
| 90 |
+
<p className="mt-1.5 px-1 text-[11px] text-white/25">{t(lang, 'selectGroup')}</p>
|
| 91 |
</section>
|
| 92 |
)
|
| 93 |
}
|
frontend/src/components/SettingsPanel.tsx
CHANGED
|
@@ -15,31 +15,54 @@ interface Props {
|
|
| 15 |
onRecluster: () => void
|
| 16 |
}
|
| 17 |
|
|
|
|
| 18 |
function Toggle({
|
| 19 |
checked,
|
| 20 |
onChange,
|
| 21 |
label,
|
|
|
|
| 22 |
}: {
|
| 23 |
checked: boolean
|
| 24 |
onChange: (v: boolean) => void
|
| 25 |
label: string
|
|
|
|
| 26 |
}) {
|
| 27 |
return (
|
| 28 |
-
<
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
>
|
| 38 |
<span
|
| 39 |
-
className={`absolute top-
|
|
|
|
|
|
|
|
|
|
| 40 |
/>
|
| 41 |
-
</
|
| 42 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
)
|
| 44 |
}
|
| 45 |
|
|
@@ -56,49 +79,70 @@ export function SettingsPanel({
|
|
| 56 |
onFilterOutliers,
|
| 57 |
onRecluster,
|
| 58 |
}: Props) {
|
| 59 |
-
if (!open)
|
| 60 |
-
return null
|
| 61 |
-
}
|
| 62 |
|
| 63 |
return (
|
| 64 |
-
<
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
<
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
<button
|
| 79 |
-
key={n}
|
| 80 |
type="button"
|
| 81 |
-
className=
|
| 82 |
-
onClick={
|
| 83 |
>
|
| 84 |
-
{
|
| 85 |
</button>
|
| 86 |
-
|
| 87 |
-
<button
|
| 88 |
-
type="button"
|
| 89 |
-
className="min-h-10 rounded-lg bg-slate-700 px-3 text-sm font-medium text-slate-200"
|
| 90 |
-
onClick={onRecluster}
|
| 91 |
-
>
|
| 92 |
-
{t(lang, 'apply')}
|
| 93 |
-
</button>
|
| 94 |
</div>
|
| 95 |
-
</
|
| 96 |
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
<
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
)
|
| 104 |
}
|
|
|
|
| 15 |
onRecluster: () => void
|
| 16 |
}
|
| 17 |
|
| 18 |
+
/** iOS-style toggle switch */
|
| 19 |
function Toggle({
|
| 20 |
checked,
|
| 21 |
onChange,
|
| 22 |
label,
|
| 23 |
+
description,
|
| 24 |
}: {
|
| 25 |
checked: boolean
|
| 26 |
onChange: (v: boolean) => void
|
| 27 |
label: string
|
| 28 |
+
description?: string
|
| 29 |
}) {
|
| 30 |
return (
|
| 31 |
+
<button
|
| 32 |
+
type="button"
|
| 33 |
+
role="switch"
|
| 34 |
+
aria-checked={checked}
|
| 35 |
+
className="flex min-h-[52px] w-full items-center justify-between gap-3 px-4 text-left transition-colors duration-150 active:bg-white/5"
|
| 36 |
+
onClick={() => onChange(!checked)}
|
| 37 |
+
>
|
| 38 |
+
<span className="flex flex-col gap-0.5">
|
| 39 |
+
<span className="text-[15px] text-white/90">{label}</span>
|
| 40 |
+
{description && (
|
| 41 |
+
<span className="text-xs text-white/35">{description}</span>
|
| 42 |
+
)}
|
| 43 |
+
</span>
|
| 44 |
+
{/* Native-size iOS toggle */}
|
| 45 |
+
<span
|
| 46 |
+
className={`relative h-[31px] w-[51px] shrink-0 rounded-full transition-colors duration-200 ${
|
| 47 |
+
checked ? 'bg-[#34c759]' : 'bg-white/20'
|
| 48 |
+
}`}
|
| 49 |
+
style={{ boxShadow: 'inset 0 0 0 1px rgba(0,0,0,0.2)' }}
|
| 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.3)' }}
|
| 56 |
/>
|
| 57 |
+
</span>
|
| 58 |
+
</button>
|
| 59 |
+
)
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/** Inset separator line between list rows */
|
| 63 |
+
function Separator() {
|
| 64 |
+
return (
|
| 65 |
+
<div className="ml-4 h-px bg-white/8" />
|
| 66 |
)
|
| 67 |
}
|
| 68 |
|
|
|
|
| 79 |
onFilterOutliers,
|
| 80 |
onRecluster,
|
| 81 |
}: Props) {
|
| 82 |
+
if (!open) return null
|
|
|
|
|
|
|
| 83 |
|
| 84 |
return (
|
| 85 |
+
<div className="space-y-4">
|
| 86 |
+
{/* ββ Group count section ββββββββββββββββββββββββββββββββββββ */}
|
| 87 |
+
<section>
|
| 88 |
+
<p className="mb-2 px-1 text-xs font-medium uppercase tracking-widest text-white/35">
|
| 89 |
+
{t(lang, 'groupCount')}
|
| 90 |
+
</p>
|
| 91 |
+
<div className="overflow-hidden rounded-2xl bg-white/6 ring-1 ring-white/8">
|
| 92 |
+
<div className="flex flex-wrap gap-2 p-3">
|
| 93 |
+
{(['auto', 1, 2, 3, 4, 5, 6] as (number | 'auto')[]).map((n) => {
|
| 94 |
+
const active = groupCount === n
|
| 95 |
+
return (
|
| 96 |
+
<button
|
| 97 |
+
key={String(n)}
|
| 98 |
+
type="button"
|
| 99 |
+
className={`min-h-9 rounded-xl px-4 text-sm font-semibold transition-all duration-150 active:scale-95 ${
|
| 100 |
+
active
|
| 101 |
+
? 'bg-blue-500 text-white shadow-md shadow-blue-900/40'
|
| 102 |
+
: 'bg-white/8 text-white/65 active:bg-white/15'
|
| 103 |
+
}`}
|
| 104 |
+
onClick={() => onGroupCount(n)}
|
| 105 |
+
>
|
| 106 |
+
{n === 'auto' ? t(lang, 'auto') : n}
|
| 107 |
+
</button>
|
| 108 |
+
)
|
| 109 |
+
})}
|
| 110 |
<button
|
|
|
|
| 111 |
type="button"
|
| 112 |
+
className="min-h-9 rounded-xl bg-white/8 px-4 text-sm font-semibold text-white/65 transition-all duration-150 active:scale-95 active:bg-white/15"
|
| 113 |
+
onClick={onRecluster}
|
| 114 |
>
|
| 115 |
+
{t(lang, 'apply')}
|
| 116 |
</button>
|
| 117 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
</div>
|
| 119 |
+
</section>
|
| 120 |
|
| 121 |
+
{/* ββ Toggle settings section ββββββββββββββββββββββββββββββββ */}
|
| 122 |
+
<section>
|
| 123 |
+
<p className="mb-2 px-1 text-xs font-medium uppercase tracking-widest text-white/35">
|
| 124 |
+
{t(lang, 'settings')}
|
| 125 |
+
</p>
|
| 126 |
+
<div className="overflow-hidden rounded-2xl bg-white/6 ring-1 ring-white/8">
|
| 127 |
+
<Toggle
|
| 128 |
+
checked={enhanceImage}
|
| 129 |
+
onChange={onEnhanceImage}
|
| 130 |
+
label={t(lang, 'enhanceImage')}
|
| 131 |
+
/>
|
| 132 |
+
<Separator />
|
| 133 |
+
<Toggle
|
| 134 |
+
checked={useTiling}
|
| 135 |
+
onChange={onUseTiling}
|
| 136 |
+
label={t(lang, 'highAccuracy')}
|
| 137 |
+
/>
|
| 138 |
+
<Separator />
|
| 139 |
+
<Toggle
|
| 140 |
+
checked={filterOutliers}
|
| 141 |
+
onChange={onFilterOutliers}
|
| 142 |
+
label={t(lang, 'filterOutliers')}
|
| 143 |
+
/>
|
| 144 |
+
</div>
|
| 145 |
+
</section>
|
| 146 |
+
</div>
|
| 147 |
)
|
| 148 |
}
|
frontend/src/components/StepCapture.tsx
CHANGED
|
@@ -11,47 +11,109 @@ interface Props {
|
|
| 11 |
|
| 12 |
export function StepCapture({ lang, modelReady, onCamera, onGallery }: Props) {
|
| 13 |
return (
|
| 14 |
-
<div className="flex flex-1 flex-col
|
| 15 |
-
{/*
|
| 16 |
-
<div className="
|
| 17 |
-
<div
|
| 18 |
-
|
| 19 |
-
{
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
modelReady
|
| 23 |
-
? 'bg-emerald-
|
| 24 |
-
: '
|
| 25 |
}`}
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
</div>
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
</div>
|
| 32 |
</div>
|
| 33 |
|
| 34 |
-
{/*
|
| 35 |
-
<div className="
|
| 36 |
-
<
|
| 37 |
-
type="button"
|
| 38 |
-
className="flex h-14 w-full items-center justify-center gap-3 rounded-2xl bg-blue-600 text-base font-bold text-white shadow-lg shadow-blue-900/40 active:scale-[0.98]"
|
| 39 |
-
onClick={onCamera}
|
| 40 |
-
>
|
| 41 |
-
<Camera size={22} />
|
| 42 |
-
{t(lang, 'takePhoto')}
|
| 43 |
-
</button>
|
| 44 |
-
<button
|
| 45 |
-
type="button"
|
| 46 |
-
className="flex h-14 w-full items-center justify-center gap-3 rounded-2xl bg-slate-800 text-base font-medium text-slate-200 ring-1 ring-slate-700 active:scale-[0.98]"
|
| 47 |
-
onClick={onGallery}
|
| 48 |
-
>
|
| 49 |
-
<ImagePlus size={22} />
|
| 50 |
-
{t(lang, 'chooseFile')}
|
| 51 |
-
</button>
|
| 52 |
</div>
|
| 53 |
-
|
| 54 |
-
<p className="mt-10 text-center text-xs text-slate-600">{t(lang, 'company')}</p>
|
| 55 |
</div>
|
| 56 |
)
|
| 57 |
}
|
|
|
|
| 11 |
|
| 12 |
export function StepCapture({ lang, modelReady, onCamera, onGallery }: Props) {
|
| 13 |
return (
|
| 14 |
+
<div className="relative flex flex-1 flex-col overflow-hidden">
|
| 15 |
+
{/* Background ambient glow */}
|
| 16 |
+
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
| 17 |
+
<div
|
| 18 |
+
className="h-[420px] w-[420px] rounded-full"
|
| 19 |
+
style={{
|
| 20 |
+
background: 'radial-gradient(circle, rgba(59,130,246,0.18) 0%, rgba(16,185,129,0.06) 50%, transparent 70%)',
|
| 21 |
+
animation: 'glow-pulse 4s ease-in-out infinite',
|
| 22 |
+
}}
|
| 23 |
+
/>
|
| 24 |
+
</div>
|
| 25 |
+
|
| 26 |
+
{/* Hero area */}
|
| 27 |
+
<div className="relative z-10 flex flex-1 flex-col items-center justify-center px-8">
|
| 28 |
+
{/* Logo mark */}
|
| 29 |
+
<div className="mb-8 flex flex-col items-center gap-4">
|
| 30 |
+
<div className="relative">
|
| 31 |
+
{/* Outer glow ring */}
|
| 32 |
+
<div
|
| 33 |
+
className="absolute -inset-4 rounded-full opacity-40"
|
| 34 |
+
style={{
|
| 35 |
+
background: 'radial-gradient(circle, rgba(59,130,246,0.5) 0%, transparent 70%)',
|
| 36 |
+
animation: 'breathe 3.5s ease-in-out infinite',
|
| 37 |
+
}}
|
| 38 |
+
/>
|
| 39 |
+
{/* Icon container */}
|
| 40 |
+
<div
|
| 41 |
+
className="relative flex h-28 w-28 items-center justify-center rounded-[2rem] bg-gradient-to-br from-slate-800 to-slate-900 shadow-2xl ring-1 ring-white/10"
|
| 42 |
+
style={{ animation: 'breathe 3.5s ease-in-out infinite' }}
|
| 43 |
+
>
|
| 44 |
+
<img src="/icon.svg" alt="" className="h-18 w-18" style={{ width: 72, height: 72 }} />
|
| 45 |
+
|
| 46 |
+
{/* Model-ready dot */}
|
| 47 |
+
<span
|
| 48 |
+
className={`absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full border-[3px] border-[#020617] transition-all duration-700 ${
|
| 49 |
+
modelReady
|
| 50 |
+
? 'bg-emerald-400 shadow-[0_0_12px_rgba(52,211,153,0.8)]'
|
| 51 |
+
: 'animate-pulse bg-amber-400 shadow-[0_0_10px_rgba(251,191,36,0.7)]'
|
| 52 |
+
}`}
|
| 53 |
+
/>
|
| 54 |
+
</div>
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
<div className="text-center">
|
| 58 |
+
<h1 className="text-[26px] font-bold tracking-tight text-white">
|
| 59 |
+
{t(lang, 'title')}
|
| 60 |
+
</h1>
|
| 61 |
+
<p className="mt-1.5 text-sm text-white/45">
|
| 62 |
+
{t(lang, 'captureSubtitle')}
|
| 63 |
+
</p>
|
| 64 |
+
</div>
|
| 65 |
+
|
| 66 |
+
{/* Model status badge */}
|
| 67 |
+
<div
|
| 68 |
+
className={`flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium transition-colors duration-500 ${
|
| 69 |
modelReady
|
| 70 |
+
? 'bg-emerald-500/15 text-emerald-300'
|
| 71 |
+
: 'bg-amber-500/15 text-amber-300'
|
| 72 |
}`}
|
| 73 |
+
>
|
| 74 |
+
<span
|
| 75 |
+
className={`h-1.5 w-1.5 rounded-full ${
|
| 76 |
+
modelReady ? 'bg-emerald-400' : 'animate-pulse bg-amber-400'
|
| 77 |
+
}`}
|
| 78 |
+
/>
|
| 79 |
+
{modelReady ? t(lang, 'modelReady') : t(lang, 'loadingModel')}
|
| 80 |
+
</div>
|
| 81 |
</div>
|
| 82 |
+
|
| 83 |
+
{/* CTA buttons */}
|
| 84 |
+
<div className="w-full max-w-sm space-y-3">
|
| 85 |
+
{/* Primary: Camera */}
|
| 86 |
+
<button
|
| 87 |
+
type="button"
|
| 88 |
+
className="relative flex h-[58px] w-full items-center justify-center gap-3 overflow-hidden rounded-2xl text-base font-bold text-white shadow-xl transition-all duration-150 active:scale-[0.97]"
|
| 89 |
+
style={{
|
| 90 |
+
background: 'linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%)',
|
| 91 |
+
boxShadow: '0 8px 32px rgba(37,99,235,0.45)',
|
| 92 |
+
}}
|
| 93 |
+
onClick={onCamera}
|
| 94 |
+
>
|
| 95 |
+
{/* Shimmer overlay */}
|
| 96 |
+
<span className="pointer-events-none absolute inset-0 bg-gradient-to-r from-transparent via-white/10 to-transparent" />
|
| 97 |
+
<Camera size={22} strokeWidth={2.5} />
|
| 98 |
+
{t(lang, 'takePhoto')}
|
| 99 |
+
</button>
|
| 100 |
+
|
| 101 |
+
{/* Secondary: Gallery */}
|
| 102 |
+
<button
|
| 103 |
+
type="button"
|
| 104 |
+
className="flex h-[58px] w-full items-center justify-center gap-3 rounded-2xl border border-white/12 bg-white/6 text-base font-medium text-white/85 backdrop-blur-sm transition-all duration-150 active:scale-[0.97] active:bg-white/10"
|
| 105 |
+
onClick={onGallery}
|
| 106 |
+
>
|
| 107 |
+
<ImagePlus size={22} strokeWidth={2} />
|
| 108 |
+
{t(lang, 'chooseFile')}
|
| 109 |
+
</button>
|
| 110 |
</div>
|
| 111 |
</div>
|
| 112 |
|
| 113 |
+
{/* Footer */}
|
| 114 |
+
<div className="relative z-10 pb-[max(1.5rem,env(safe-area-inset-bottom))] text-center">
|
| 115 |
+
<p className="text-[11px] tracking-wide text-white/25">{t(lang, 'company')}</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
</div>
|
|
|
|
|
|
|
| 117 |
</div>
|
| 118 |
)
|
| 119 |
}
|
frontend/src/components/StepCounting.tsx
CHANGED
|
@@ -18,50 +18,96 @@ export function StepCounting({ lang, status, imageSrc }: Props) {
|
|
| 18 |
|
| 19 |
return (
|
| 20 |
<div className="relative flex flex-1 flex-col items-center justify-center overflow-hidden">
|
| 21 |
-
{/*
|
| 22 |
{imageSrc && (
|
| 23 |
<img
|
| 24 |
src={imageSrc}
|
| 25 |
alt=""
|
| 26 |
aria-hidden
|
| 27 |
-
className="absolute inset-0 h-full w-full object-cover opacity-
|
| 28 |
/>
|
| 29 |
)}
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
</div>
|
| 44 |
|
|
|
|
| 45 |
<div>
|
| 46 |
-
<h2 className="text-xl font-
|
| 47 |
{t(lang, 'countingTitle')}{''.padEnd(dots, '.')}
|
| 48 |
</h2>
|
| 49 |
-
<p className="mt-2 min-h-
|
| 50 |
-
{status || t(lang, '
|
| 51 |
</p>
|
| 52 |
</div>
|
| 53 |
|
| 54 |
-
{/*
|
| 55 |
-
<div className="h-
|
| 56 |
-
<div
|
|
|
|
|
|
|
|
|
|
| 57 |
</div>
|
| 58 |
</div>
|
| 59 |
|
| 60 |
<style>{`
|
|
|
|
|
|
|
|
|
|
| 61 |
@keyframes slide {
|
| 62 |
-
0%
|
| 63 |
-
|
| 64 |
-
100% { transform: translateX(
|
| 65 |
}
|
| 66 |
`}</style>
|
| 67 |
</div>
|
|
|
|
| 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-10 blur-2xl"
|
| 28 |
/>
|
| 29 |
)}
|
| 30 |
|
| 31 |
+
{/* Radial vignette overlay */}
|
| 32 |
+
<div
|
| 33 |
+
className="pointer-events-none absolute inset-0"
|
| 34 |
+
style={{
|
| 35 |
+
background: 'radial-gradient(ellipse 70% 60% at 50% 50%, transparent 20%, #020617 100%)',
|
| 36 |
+
}}
|
| 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-emerald-500/30"
|
| 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-emerald-400/25"
|
| 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-emerald-300/20"
|
| 53 |
+
style={{ animation: 'ping 2s cubic-bezier(0,0,0.2,1) 1s infinite' }}
|
| 54 |
+
/>
|
| 55 |
+
|
| 56 |
+
{/* Static inner circle */}
|
| 57 |
+
<div className="absolute inset-10 rounded-full bg-emerald-500/8 ring-1 ring-emerald-500/40" />
|
| 58 |
+
|
| 59 |
+
{/* Rotating arc */}
|
| 60 |
+
<svg
|
| 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="rgba(16,185,129,0.15)"
|
| 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 |
+
{/* Logo */}
|
| 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-semibold tracking-tight text-white">
|
| 87 |
{t(lang, 'countingTitle')}{''.padEnd(dots, '.')}
|
| 88 |
</h2>
|
| 89 |
+
<p className="mt-2 min-h-6 text-sm text-white/45">
|
| 90 |
+
{status || t(lang, 'pleaseWait')}
|
| 91 |
</p>
|
| 92 |
</div>
|
| 93 |
|
| 94 |
+
{/* Progress bar */}
|
| 95 |
+
<div className="h-0.5 w-48 overflow-hidden rounded-full bg-white/10">
|
| 96 |
+
<div
|
| 97 |
+
className="h-full rounded-full bg-emerald-400"
|
| 98 |
+
style={{ animation: 'slide 1.8s ease-in-out infinite', width: '35%' }}
|
| 99 |
+
/>
|
| 100 |
</div>
|
| 101 |
</div>
|
| 102 |
|
| 103 |
<style>{`
|
| 104 |
+
@keyframes spin {
|
| 105 |
+
to { transform: rotate(360deg); }
|
| 106 |
+
}
|
| 107 |
@keyframes slide {
|
| 108 |
+
0% { transform: translateX(-200%); }
|
| 109 |
+
60% { transform: translateX(380%); }
|
| 110 |
+
100% { transform: translateX(380%); }
|
| 111 |
}
|
| 112 |
`}</style>
|
| 113 |
</div>
|
frontend/src/components/StepPreview.tsx
CHANGED
|
@@ -45,25 +45,25 @@ export function StepPreview({
|
|
| 45 |
onRecluster,
|
| 46 |
}: Props) {
|
| 47 |
const ar = imageDims.h / Math.max(imageDims.w, 1)
|
| 48 |
-
|
| 49 |
-
const maxPreviewH = Math.min(ar * 100, 50)
|
| 50 |
|
| 51 |
return (
|
| 52 |
<div className="flex flex-1 flex-col overflow-hidden">
|
| 53 |
-
{/*
|
| 54 |
-
<div className="flex items-center justify-between px-4 py-2">
|
| 55 |
<button
|
| 56 |
type="button"
|
| 57 |
-
className="flex items-center gap-1 rounded-xl bg-
|
| 58 |
onClick={onBack}
|
| 59 |
>
|
| 60 |
-
<ChevronLeft size={16} />
|
| 61 |
{t(lang, 'previewBack')}
|
| 62 |
</button>
|
|
|
|
| 63 |
<div className="flex gap-2">
|
| 64 |
<button
|
| 65 |
type="button"
|
| 66 |
-
className="flex h-9 w-9 items-center justify-center rounded-xl bg-
|
| 67 |
onClick={onRetake}
|
| 68 |
aria-label={t(lang, 'retake')}
|
| 69 |
>
|
|
@@ -71,7 +71,7 @@ export function StepPreview({
|
|
| 71 |
</button>
|
| 72 |
<button
|
| 73 |
type="button"
|
| 74 |
-
className="flex h-9 w-9 items-center justify-center rounded-xl bg-
|
| 75 |
onClick={onGallery}
|
| 76 |
aria-label={t(lang, 'chooseFile')}
|
| 77 |
>
|
|
@@ -80,25 +80,21 @@ export function StepPreview({
|
|
| 80 |
</div>
|
| 81 |
</div>
|
| 82 |
|
| 83 |
-
{/*
|
| 84 |
<div
|
| 85 |
-
className="mx-4 overflow-hidden rounded-2xl
|
| 86 |
style={{ height: `${maxPreviewH}vh` }}
|
| 87 |
>
|
| 88 |
-
<img
|
| 89 |
-
src={imageSrc}
|
| 90 |
-
alt="Preview"
|
| 91 |
-
className="h-full w-full object-contain"
|
| 92 |
-
/>
|
| 93 |
</div>
|
| 94 |
|
| 95 |
-
{/*
|
| 96 |
-
<p className="mt-1.5 px-
|
| 97 |
-
{imageDims.w} Γ {imageDims.h}
|
| 98 |
</p>
|
| 99 |
|
| 100 |
-
{/*
|
| 101 |
-
<div className="flex-1 overflow-y-auto px-4 pb-2 pt-
|
| 102 |
<SettingsPanel
|
| 103 |
lang={lang}
|
| 104 |
open={true}
|
|
@@ -114,14 +110,25 @@ export function StepPreview({
|
|
| 114 |
/>
|
| 115 |
</div>
|
| 116 |
|
| 117 |
-
{/*
|
| 118 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
<button
|
| 120 |
type="button"
|
| 121 |
disabled={busy || !modelReady}
|
| 122 |
-
className="flex h-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
onClick={onCount}
|
| 124 |
>
|
|
|
|
| 125 |
{busy ? <Loader2 className="animate-spin" size={22} /> : null}
|
| 126 |
{t(lang, 'countNow')}
|
| 127 |
</button>
|
|
|
|
| 45 |
onRecluster,
|
| 46 |
}: Props) {
|
| 47 |
const ar = imageDims.h / Math.max(imageDims.w, 1)
|
| 48 |
+
const maxPreviewH = Math.min(ar * 100, 52)
|
|
|
|
| 49 |
|
| 50 |
return (
|
| 51 |
<div className="flex flex-1 flex-col overflow-hidden">
|
| 52 |
+
{/* ββ Navigation bar βββββββββββββββββββββββββββββββββββββββββββ */}
|
| 53 |
+
<div className="flex items-center justify-between px-4 py-2.5">
|
| 54 |
<button
|
| 55 |
type="button"
|
| 56 |
+
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"
|
| 57 |
onClick={onBack}
|
| 58 |
>
|
| 59 |
+
<ChevronLeft size={16} strokeWidth={2.5} />
|
| 60 |
{t(lang, 'previewBack')}
|
| 61 |
</button>
|
| 62 |
+
|
| 63 |
<div className="flex gap-2">
|
| 64 |
<button
|
| 65 |
type="button"
|
| 66 |
+
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"
|
| 67 |
onClick={onRetake}
|
| 68 |
aria-label={t(lang, 'retake')}
|
| 69 |
>
|
|
|
|
| 71 |
</button>
|
| 72 |
<button
|
| 73 |
type="button"
|
| 74 |
+
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"
|
| 75 |
onClick={onGallery}
|
| 76 |
aria-label={t(lang, 'chooseFile')}
|
| 77 |
>
|
|
|
|
| 80 |
</div>
|
| 81 |
</div>
|
| 82 |
|
| 83 |
+
{/* ββ Image preview ββββββββββββββββββββββββββββββββββββββββββββ */}
|
| 84 |
<div
|
| 85 |
+
className="mx-4 overflow-hidden rounded-2xl bg-black shadow-xl ring-1 ring-white/8"
|
| 86 |
style={{ height: `${maxPreviewH}vh` }}
|
| 87 |
>
|
| 88 |
+
<img src={imageSrc} alt="Preview" className="h-full w-full object-contain" />
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
</div>
|
| 90 |
|
| 91 |
+
{/* Image dimension tag */}
|
| 92 |
+
<p className="mt-1.5 px-5 text-[11px] text-white/30 tabular-nums">
|
| 93 |
+
{imageDims.w} Γ {imageDims.h}
|
| 94 |
</p>
|
| 95 |
|
| 96 |
+
{/* ββ Scrollable settings ββββββββββββββββββββββββββββββββββββββ */}
|
| 97 |
+
<div className="flex-1 overflow-y-auto px-4 pb-2 pt-2">
|
| 98 |
<SettingsPanel
|
| 99 |
lang={lang}
|
| 100 |
open={true}
|
|
|
|
| 110 |
/>
|
| 111 |
</div>
|
| 112 |
|
| 113 |
+
{/* ββ Sticky CTA βββββββββββββββββββββββββββββββββββββββββββββββ */}
|
| 114 |
+
<div
|
| 115 |
+
className="shrink-0 px-4 pt-3"
|
| 116 |
+
style={{ paddingBottom: 'max(1rem, env(safe-area-inset-bottom))' }}
|
| 117 |
+
>
|
| 118 |
+
{/* Separator */}
|
| 119 |
+
<div className="mb-3 h-px bg-gradient-to-r from-transparent via-white/10 to-transparent" />
|
| 120 |
+
|
| 121 |
<button
|
| 122 |
type="button"
|
| 123 |
disabled={busy || !modelReady}
|
| 124 |
+
className="relative flex h-[58px] w-full items-center justify-center gap-3 overflow-hidden rounded-2xl text-base font-bold text-white shadow-xl transition-all duration-150 active:scale-[0.98] disabled:opacity-50"
|
| 125 |
+
style={{
|
| 126 |
+
background: 'linear-gradient(135deg, #059669 0%, #047857 60%, #065f46 100%)',
|
| 127 |
+
boxShadow: '0 8px 28px rgba(5,150,105,0.4)',
|
| 128 |
+
}}
|
| 129 |
onClick={onCount}
|
| 130 |
>
|
| 131 |
+
<span className="pointer-events-none absolute inset-0 bg-gradient-to-r from-transparent via-white/8 to-transparent" />
|
| 132 |
{busy ? <Loader2 className="animate-spin" size={22} /> : null}
|
| 133 |
{t(lang, 'countNow')}
|
| 134 |
</button>
|
frontend/src/components/StepResults.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import { useRef, useState } from 'react'
|
| 2 |
-
import {
|
| 3 |
import { t } from '../lib/i18n'
|
| 4 |
import type { Detection, DiameterGroup, Lang, ToolMode } from '../lib/types'
|
| 5 |
import { ResultCanvas } from './ResultCanvas'
|
|
@@ -40,32 +40,36 @@ export function StepResults({
|
|
| 40 |
|
| 41 |
return (
|
| 42 |
<div className="flex flex-1 flex-col overflow-hidden">
|
| 43 |
-
{/*
|
| 44 |
-
<div className="flex items-center justify-between px-4 py-2">
|
|
|
|
| 45 |
<button
|
| 46 |
type="button"
|
| 47 |
-
className="flex h-9 items-center gap-1.5 rounded-xl bg-
|
| 48 |
onClick={onNewPhoto}
|
| 49 |
>
|
| 50 |
-
<
|
| 51 |
{t(lang, 'resultsBack')}
|
| 52 |
</button>
|
| 53 |
|
| 54 |
-
{/*
|
| 55 |
<div className="flex flex-col items-center">
|
| 56 |
<span
|
| 57 |
ref={countDisplayRef}
|
| 58 |
-
className="text-
|
| 59 |
>
|
| 60 |
{detections.length}
|
| 61 |
</span>
|
| 62 |
-
<span className="text-[10px] uppercase tracking-widest text-
|
|
|
|
|
|
|
| 63 |
</div>
|
| 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-
|
| 69 |
onClick={() => setExportOpen(true)}
|
| 70 |
aria-label={t(lang, 'export')}
|
| 71 |
>
|
|
@@ -73,7 +77,7 @@ export function StepResults({
|
|
| 73 |
</button>
|
| 74 |
<button
|
| 75 |
type="button"
|
| 76 |
-
className="flex h-9 w-9 items-center justify-center rounded-xl bg-emerald-
|
| 77 |
onClick={onRecount}
|
| 78 |
aria-label={t(lang, 'recount')}
|
| 79 |
>
|
|
@@ -82,25 +86,28 @@ export function StepResults({
|
|
| 82 |
</div>
|
| 83 |
</div>
|
| 84 |
|
| 85 |
-
{/*
|
| 86 |
-
<div
|
|
|
|
|
|
|
|
|
|
| 87 |
<div className="space-y-4">
|
| 88 |
-
{/*
|
| 89 |
{groups.length > 1 && (
|
| 90 |
<div className="flex flex-wrap gap-2">
|
| 91 |
{groups.map((g) => (
|
| 92 |
<span
|
| 93 |
key={g.id}
|
| 94 |
-
className="inline-flex items-center gap-1.5 rounded-full bg-
|
| 95 |
>
|
| 96 |
-
<span className="h-2
|
| 97 |
{g.label}: {counts[g.id] ?? 0}
|
| 98 |
</span>
|
| 99 |
))}
|
| 100 |
</div>
|
| 101 |
)}
|
| 102 |
|
| 103 |
-
{/* canvas
|
| 104 |
<ResultCanvas
|
| 105 |
image={image}
|
| 106 |
detections={detections}
|
|
@@ -113,19 +120,24 @@ export function StepResults({
|
|
| 113 |
countDisplayRef={countDisplayRef}
|
| 114 |
/>
|
| 115 |
|
| 116 |
-
{/*
|
| 117 |
{animDone && (
|
| 118 |
-
<
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
<ToolBar lang={lang} tool={tool} onToolChange={setTool} />
|
| 128 |
-
</>
|
| 129 |
)}
|
| 130 |
</div>
|
| 131 |
</div>
|
|
|
|
| 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'
|
|
|
|
| 40 |
|
| 41 |
return (
|
| 42 |
<div className="flex flex-1 flex-col overflow-hidden">
|
| 43 |
+
{/* ββ Top bar ββββββββββββββββββββββββββββββββββββββββββββββββ */}
|
| 44 |
+
<div className="flex shrink-0 items-center justify-between px-4 py-2">
|
| 45 |
+
{/* New photo */}
|
| 46 |
<button
|
| 47 |
type="button"
|
| 48 |
+
className="flex h-9 items-center gap-1.5 rounded-xl bg-white/7 px-3 text-sm font-medium text-white/70 transition-all duration-150 active:scale-95 active:bg-white/12"
|
| 49 |
onClick={onNewPhoto}
|
| 50 |
>
|
| 51 |
+
<Camera size={15} />
|
| 52 |
{t(lang, 'resultsBack')}
|
| 53 |
</button>
|
| 54 |
|
| 55 |
+
{/* Live count */}
|
| 56 |
<div className="flex flex-col items-center">
|
| 57 |
<span
|
| 58 |
ref={countDisplayRef}
|
| 59 |
+
className="text-[34px] font-bold tabular-nums leading-none text-white"
|
| 60 |
>
|
| 61 |
{detections.length}
|
| 62 |
</span>
|
| 63 |
+
<span className="mt-0.5 text-[10px] uppercase tracking-widest text-white/35">
|
| 64 |
+
{t(lang, 'total')}
|
| 65 |
+
</span>
|
| 66 |
</div>
|
| 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 |
>
|
|
|
|
| 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 |
>
|
|
|
|
| 86 |
</div>
|
| 87 |
</div>
|
| 88 |
|
| 89 |
+
{/* ββ Scrollable body ββββββββββββββββββββββββββββββββββββββββββ */}
|
| 90 |
+
<div
|
| 91 |
+
className="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}
|
|
|
|
| 120 |
countDisplayRef={countDisplayRef}
|
| 121 |
/>
|
| 122 |
|
| 123 |
+
{/* Correction tools β slide in after animation */}
|
| 124 |
{animDone && (
|
| 125 |
+
<div
|
| 126 |
+
className="space-y-4"
|
| 127 |
+
style={{ animation: 'step-enter 0.35s cubic-bezier(0.22,1,0.36,1) both' }}
|
| 128 |
+
>
|
| 129 |
+
{groups.length > 0 && (
|
| 130 |
+
<GroupPanel
|
| 131 |
+
lang={lang}
|
| 132 |
+
groups={groups}
|
| 133 |
+
counts={counts}
|
| 134 |
+
selectedGroupId={selectedGroupId}
|
| 135 |
+
onSelectGroup={setSelectedGroupId}
|
| 136 |
+
onExpectedChange={onExpectedChange}
|
| 137 |
+
/>
|
| 138 |
+
)}
|
| 139 |
<ToolBar lang={lang} tool={tool} onToolChange={setTool} />
|
| 140 |
+
</div>
|
| 141 |
)}
|
| 142 |
</div>
|
| 143 |
</div>
|
frontend/src/components/ToolBar.tsx
CHANGED
|
@@ -3,12 +3,17 @@ import { cn } from '../lib/utils'
|
|
| 3 |
import { t } from '../lib/i18n'
|
| 4 |
import type { Lang, ToolMode } from '../lib/types'
|
| 5 |
|
| 6 |
-
const TOOLS: {
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
]
|
| 13 |
|
| 14 |
interface Props {
|
|
@@ -20,25 +25,35 @@ interface Props {
|
|
| 20 |
export function ToolBar({ lang, tool, onToolChange }: Props) {
|
| 21 |
return (
|
| 22 |
<section>
|
| 23 |
-
<p className="mb-2 text-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
</div>
|
| 43 |
</section>
|
| 44 |
)
|
|
|
|
| 3 |
import { t } from '../lib/i18n'
|
| 4 |
import type { Lang, ToolMode } from '../lib/types'
|
| 5 |
|
| 6 |
+
const TOOLS: {
|
| 7 |
+
id: ToolMode
|
| 8 |
+
icon: typeof Eye
|
| 9 |
+
labelKey: 'toolView' | 'toolDelete' | 'toolAdd' | 'toolReassign' | 'toolArea'
|
| 10 |
+
activeColor: string
|
| 11 |
+
}[] = [
|
| 12 |
+
{ id: 'view', icon: Eye, labelKey: 'toolView', activeColor: 'bg-white text-slate-900' },
|
| 13 |
+
{ id: 'delete', icon: Trash2, labelKey: 'toolDelete', activeColor: 'bg-red-500 text-white' },
|
| 14 |
+
{ id: 'add', icon: Plus, labelKey: 'toolAdd', activeColor: 'bg-emerald-500 text-white' },
|
| 15 |
+
{ id: 'reassign', icon: Tag, labelKey: 'toolReassign', activeColor: 'bg-blue-500 text-white' },
|
| 16 |
+
{ id: 'area', icon: SquareDashed, labelKey: 'toolArea', activeColor: 'bg-violet-500 text-white' },
|
| 17 |
]
|
| 18 |
|
| 19 |
interface Props {
|
|
|
|
| 25 |
export function ToolBar({ lang, tool, onToolChange }: Props) {
|
| 26 |
return (
|
| 27 |
<section>
|
| 28 |
+
<p className="mb-2 px-1 text-[11px] font-medium uppercase tracking-widest text-white/30">
|
| 29 |
+
{t(lang, 'tools')}
|
| 30 |
+
</p>
|
| 31 |
+
|
| 32 |
+
{/* Floating pill container */}
|
| 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, activeColor }) => {
|
| 36 |
+
const active = tool === id
|
| 37 |
+
return (
|
| 38 |
+
<button
|
| 39 |
+
key={id}
|
| 40 |
+
type="button"
|
| 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 |
+
? `${activeColor} shadow-sm`
|
| 45 |
+
: 'text-white/55 hover:text-white/80 active:bg-white/10',
|
| 46 |
+
)}
|
| 47 |
+
onClick={() => onToolChange(id)}
|
| 48 |
+
>
|
| 49 |
+
<Icon size={15} strokeWidth={active ? 2.5 : 2} />
|
| 50 |
+
<span className={active ? 'opacity-100' : 'opacity-70'}>
|
| 51 |
+
{t(lang, labelKey)}
|
| 52 |
+
</span>
|
| 53 |
+
</button>
|
| 54 |
+
)
|
| 55 |
+
})}
|
| 56 |
+
</div>
|
| 57 |
</div>
|
| 58 |
</section>
|
| 59 |
)
|
frontend/src/index.css
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
@import 'tailwindcss';
|
| 2 |
|
| 3 |
:root {
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
color: #f8fafc;
|
| 6 |
background: #020617;
|
| 7 |
-webkit-tap-highlight-color: transparent;
|
|
@@ -15,7 +17,7 @@ html {
|
|
| 15 |
body {
|
| 16 |
margin: 0;
|
| 17 |
min-height: 100dvh;
|
| 18 |
-
background:
|
| 19 |
}
|
| 20 |
|
| 21 |
#root {
|
|
@@ -24,6 +26,7 @@ body {
|
|
| 24 |
|
| 25 |
button {
|
| 26 |
touch-action: manipulation;
|
|
|
|
| 27 |
}
|
| 28 |
|
| 29 |
button:disabled {
|
|
@@ -40,3 +43,38 @@ input[type='number']::-webkit-inner-spin-button {
|
|
| 40 |
-webkit-appearance: none;
|
| 41 |
margin: 0;
|
| 42 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
@import 'tailwindcss';
|
| 2 |
|
| 3 |
:root {
|
| 4 |
+
/* Platform-native font stack: SF Pro on iOS/macOS, Roboto on Android, Segoe UI on Windows */
|
| 5 |
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue',
|
| 6 |
+
system-ui, 'Segoe UI', Roboto, sans-serif;
|
| 7 |
color: #f8fafc;
|
| 8 |
background: #020617;
|
| 9 |
-webkit-tap-highlight-color: transparent;
|
|
|
|
| 17 |
body {
|
| 18 |
margin: 0;
|
| 19 |
min-height: 100dvh;
|
| 20 |
+
background: #020617;
|
| 21 |
}
|
| 22 |
|
| 23 |
#root {
|
|
|
|
| 26 |
|
| 27 |
button {
|
| 28 |
touch-action: manipulation;
|
| 29 |
+
-webkit-tap-highlight-color: transparent;
|
| 30 |
}
|
| 31 |
|
| 32 |
button:disabled {
|
|
|
|
| 43 |
-webkit-appearance: none;
|
| 44 |
margin: 0;
|
| 45 |
}
|
| 46 |
+
|
| 47 |
+
/* βββ Page-level step transition βββββββββββββββββββββββββββββββ */
|
| 48 |
+
@keyframes step-enter {
|
| 49 |
+
from { opacity: 0; transform: translateY(18px); }
|
| 50 |
+
to { opacity: 1; transform: translateY(0); }
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/* βββ Bottom-sheet entrance ββββββββββββββββββββββββββββββββββββ */
|
| 54 |
+
@keyframes sheet-up {
|
| 55 |
+
from { transform: translateY(100%); }
|
| 56 |
+
to { transform: translateY(0); }
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/* βββ Overlay fade βββββββββββββββββββββββββββββββββββββββββββββ */
|
| 60 |
+
@keyframes fade-in {
|
| 61 |
+
from { opacity: 0; }
|
| 62 |
+
to { opacity: 1; }
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
/* βββ Logo breathing βββββββββββββββββββββββββββββββββββββββββββ */
|
| 66 |
+
@keyframes breathe {
|
| 67 |
+
0%, 100% { transform: scale(1); }
|
| 68 |
+
50% { transform: scale(1.035); }
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/* βββ Glow pulse βββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 72 |
+
@keyframes glow-pulse {
|
| 73 |
+
0%, 100% { opacity: 0.35; transform: scale(1); }
|
| 74 |
+
50% { opacity: 0.55; transform: scale(1.08); }
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/* βββ Slide-in animation utility βββββββββββββββββββββββββββββββ */
|
| 78 |
+
.step-enter { animation: step-enter 0.32s cubic-bezier(0.22, 1, 0.36, 1) both; }
|
| 79 |
+
.sheet-enter { animation: sheet-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) both; }
|
| 80 |
+
.overlay-enter { animation: fade-in 0.2s ease-out both; }
|