Spaces:
Runtime error
Runtime error
Khunndev Cursor commited on
Commit ·
e205988
1
Parent(s): d30af0c
Add Nawaplastic brand assets, credit footer, and PWA icons.
Browse filesFetch PNG icons and background at build time from the legacy HF space (HF git rejects binaries). Apply branded capture screen and Digital Manufacturing credit.
Co-authored-by: Cursor <cursoragent@cursor.com>
- .gitignore +4 -0
- frontend/index.html +6 -3
- frontend/package.json +2 -1
- frontend/public/images/choose.svg +63 -0
- frontend/public/images/loading.svg +47 -0
- frontend/public/images/result.svg +61 -0
- frontend/scripts/fetch-brand-assets.mjs +61 -0
- frontend/src/App.tsx +5 -1
- frontend/src/components/CreditFooter.tsx +19 -0
- frontend/src/components/ResultsDock.tsx +4 -0
- frontend/src/components/StepCapture.tsx +36 -35
- frontend/src/components/StepCounting.tsx +7 -30
- frontend/src/lib/assets.ts +10 -0
- frontend/src/lib/i18n.ts +2 -0
- frontend/vite.config.ts +17 -5
.gitignore
CHANGED
|
@@ -8,5 +8,9 @@ model.py
|
|
| 8 |
requirements.txt
|
| 9 |
frontend/node_modules/
|
| 10 |
frontend/dist/
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
node_modules/
|
| 12 |
dist/
|
|
|
|
| 8 |
requirements.txt
|
| 9 |
frontend/node_modules/
|
| 10 |
frontend/dist/
|
| 11 |
+
frontend/public/icon.png
|
| 12 |
+
frontend/public/images/bg.png
|
| 13 |
+
frontend/public/images/touch/*.png
|
| 14 |
+
frontend/public/images/touch/*.ico
|
| 15 |
node_modules/
|
| 16 |
dist/
|
frontend/index.html
CHANGED
|
@@ -3,11 +3,14 @@
|
|
| 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="
|
|
|
|
|
|
|
|
|
|
| 11 |
<title>NPI Pipe Count</title>
|
| 12 |
</head>
|
| 13 |
<body>
|
|
|
|
| 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="#004973" />
|
| 7 |
<meta name="apple-mobile-web-app-capable" content="yes" />
|
| 8 |
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
| 9 |
<meta name="mobile-web-app-capable" content="yes" />
|
| 10 |
+
<link rel="icon" type="image/png" sizes="32x32" href="/images/touch/favicon-32x32.png" />
|
| 11 |
+
<link rel="icon" type="image/png" sizes="16x16" href="/images/touch/favicon-16x16.png" />
|
| 12 |
+
<link rel="shortcut icon" href="/images/touch/favicon.ico" />
|
| 13 |
+
<link rel="apple-touch-icon" href="/images/touch/android-chrome-192x192.png" />
|
| 14 |
<title>NPI Pipe Count</title>
|
| 15 |
</head>
|
| 16 |
<body>
|
frontend/package.json
CHANGED
|
@@ -5,7 +5,8 @@
|
|
| 5 |
"type": "module",
|
| 6 |
"scripts": {
|
| 7 |
"dev": "vite",
|
| 8 |
-
"
|
|
|
|
| 9 |
"lint": "eslint .",
|
| 10 |
"preview": "vite preview"
|
| 11 |
},
|
|
|
|
| 5 |
"type": "module",
|
| 6 |
"scripts": {
|
| 7 |
"dev": "vite",
|
| 8 |
+
"fetch-assets": "node scripts/fetch-brand-assets.mjs",
|
| 9 |
+
"build": "node scripts/fetch-brand-assets.mjs && tsc -b && vite build",
|
| 10 |
"lint": "eslint .",
|
| 11 |
"preview": "vite preview"
|
| 12 |
},
|
frontend/public/images/choose.svg
ADDED
|
|
frontend/public/images/loading.svg
ADDED
|
|
frontend/public/images/result.svg
ADDED
|
|
frontend/scripts/fetch-brand-assets.mjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Download brand images from the legacy NPI Pipe Count HF space.
|
| 3 |
+
* HF Spaces reject PNG/ICO in git — assets are fetched at build time instead.
|
| 4 |
+
*/
|
| 5 |
+
import { mkdir, writeFile, access } from 'node:fs/promises'
|
| 6 |
+
import { constants } from 'node:fs'
|
| 7 |
+
import { dirname, join } from 'node:path'
|
| 8 |
+
import { fileURLToPath } from 'node:url'
|
| 9 |
+
|
| 10 |
+
const BASE = 'https://npisb-pipecountapp.hf.space'
|
| 11 |
+
const PUBLIC = join(fileURLToPath(new URL('.', import.meta.url)), '..', 'public')
|
| 12 |
+
|
| 13 |
+
const FILES = [
|
| 14 |
+
['icon.png', '/images/touch/android-chrome-512x512.png'],
|
| 15 |
+
['images/bg.png', '/images/bg.png'],
|
| 16 |
+
['images/touch/android-chrome-192x192.png', '/images/touch/android-chrome-192x192.png'],
|
| 17 |
+
['images/touch/android-chrome-512x512.png', '/images/touch/android-chrome-512x512.png'],
|
| 18 |
+
['images/touch/favicon-16x16.png', '/images/touch/favicon-16x16.png'],
|
| 19 |
+
['images/touch/favicon-32x32.png', '/images/touch/favicon-32x32.png'],
|
| 20 |
+
['images/touch/favicon.ico', '/images/touch/favicon.ico'],
|
| 21 |
+
['images/touch/mstile-150x150.png', '/images/touch/mstile-150x150.png'],
|
| 22 |
+
]
|
| 23 |
+
|
| 24 |
+
async function exists(path) {
|
| 25 |
+
try {
|
| 26 |
+
await access(path, constants.F_OK)
|
| 27 |
+
return true
|
| 28 |
+
} catch {
|
| 29 |
+
return false
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
async function main() {
|
| 34 |
+
const force = process.env.FORCE_FETCH_ASSETS === '1'
|
| 35 |
+
let fetched = 0
|
| 36 |
+
|
| 37 |
+
for (const [dest, urlPath] of FILES) {
|
| 38 |
+
const out = join(PUBLIC, dest)
|
| 39 |
+
if (!force && (await exists(out))) continue
|
| 40 |
+
|
| 41 |
+
const res = await fetch(`${BASE}${urlPath}`)
|
| 42 |
+
if (!res.ok) {
|
| 43 |
+
throw new Error(`Failed to fetch ${urlPath}: ${res.status}`)
|
| 44 |
+
}
|
| 45 |
+
await mkdir(dirname(out), { recursive: true })
|
| 46 |
+
const buf = Buffer.from(await res.arrayBuffer())
|
| 47 |
+
if (buf.length < 100) {
|
| 48 |
+
throw new Error(`Suspiciously small file for ${urlPath} (${buf.length} bytes)`)
|
| 49 |
+
}
|
| 50 |
+
await writeFile(out, buf)
|
| 51 |
+
fetched++
|
| 52 |
+
console.log(`fetched ${dest} (${buf.length} bytes)`)
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
console.log(fetched ? `Done — ${fetched} asset(s) updated.` : 'Brand assets already present.')
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
main().catch((err) => {
|
| 59 |
+
console.error(err)
|
| 60 |
+
process.exit(1)
|
| 61 |
+
})
|
frontend/src/App.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 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'
|
|
@@ -11,6 +12,7 @@ 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 |
|
|
@@ -242,7 +244,7 @@ export default function App() {
|
|
| 242 |
>
|
| 243 |
<div className="flex items-center gap-2.5">
|
| 244 |
<div className="relative">
|
| 245 |
-
<img src=
|
| 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'
|
|
@@ -337,6 +339,8 @@ export default function App() {
|
|
| 337 |
)}
|
| 338 |
</div>
|
| 339 |
|
|
|
|
|
|
|
| 340 |
<SettingsDrawer
|
| 341 |
lang={lang}
|
| 342 |
open={settingsOpen}
|
|
|
|
| 1 |
import { useCallback, useEffect, useRef, useState } from 'react'
|
| 2 |
import { Settings } from 'lucide-react'
|
| 3 |
+
import { ASSETS } from './lib/assets'
|
| 4 |
import { assignDiameterGroups, countByGroup } from './lib/clustering'
|
| 5 |
import { getActiveBackend, isLowMemoryDevice, loadModel, runDetection } from './lib/inference'
|
| 6 |
import { loadInferenceMode, saveInferenceMode } from './lib/inferenceSettings'
|
|
|
|
| 12 |
import { StepPreview } from './components/StepPreview'
|
| 13 |
import { StepResults } from './components/StepResults'
|
| 14 |
import { SettingsDrawer } from './components/SettingsDrawer'
|
| 15 |
+
import { CreditFooter } from './components/CreditFooter'
|
| 16 |
|
| 17 |
type Step = 'capture' | 'preview' | 'counting' | 'results'
|
| 18 |
|
|
|
|
| 244 |
>
|
| 245 |
<div className="flex items-center gap-2.5">
|
| 246 |
<div className="relative">
|
| 247 |
+
<img src={ASSETS.icon192} alt="" className="h-7 w-7 rounded-lg object-cover" />
|
| 248 |
<span
|
| 249 |
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 ${
|
| 250 |
engine === 'none'
|
|
|
|
| 339 |
)}
|
| 340 |
</div>
|
| 341 |
|
| 342 |
+
{step !== 'results' && <CreditFooter lang={lang} />}
|
| 343 |
+
|
| 344 |
<SettingsDrawer
|
| 345 |
lang={lang}
|
| 346 |
open={settingsOpen}
|
frontend/src/components/CreditFooter.tsx
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { t } from '../lib/i18n'
|
| 2 |
+
import type { Lang } from '../lib/types'
|
| 3 |
+
|
| 4 |
+
interface Props {
|
| 5 |
+
lang: Lang
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
export function CreditFooter({ lang }: Props) {
|
| 9 |
+
return (
|
| 10 |
+
<footer
|
| 11 |
+
className="shrink-0 border-t border-[var(--hairline)] bg-[var(--header-bg)] px-4 py-1.5 text-center"
|
| 12 |
+
style={{ paddingBottom: 'max(0.375rem, env(safe-area-inset-bottom))' }}
|
| 13 |
+
>
|
| 14 |
+
<p className="text-[10px] font-medium tracking-wide text-[var(--text-faint)]">
|
| 15 |
+
{t(lang, 'creditFooter')}
|
| 16 |
+
</p>
|
| 17 |
+
</footer>
|
| 18 |
+
)
|
| 19 |
+
}
|
frontend/src/components/ResultsDock.tsx
CHANGED
|
@@ -172,6 +172,10 @@ export function ResultsDock({
|
|
| 172 |
{t(lang, 'export')}
|
| 173 |
</button>
|
| 174 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
</div>
|
| 176 |
)
|
| 177 |
}
|
|
|
|
| 172 |
{t(lang, 'export')}
|
| 173 |
</button>
|
| 174 |
</div>
|
| 175 |
+
|
| 176 |
+
<p className="mt-2 pb-1 text-center text-[10px] font-medium tracking-wide text-[var(--text-faint)]">
|
| 177 |
+
{t(lang, 'creditFooter')}
|
| 178 |
+
</p>
|
| 179 |
</div>
|
| 180 |
)
|
| 181 |
}
|
frontend/src/components/StepCapture.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import { AlertTriangle, Camera, ImagePlus, RotateCcw } from 'lucide-react'
|
|
|
|
| 2 |
import { t } from '../lib/i18n'
|
| 3 |
import type { Lang } from '../lib/types'
|
| 4 |
|
|
@@ -18,43 +19,43 @@ export function StepCapture({ lang, engine, modelError, onRetryModel, onCamera,
|
|
| 18 |
const ready = engine === 'local' || engine === 'server'
|
| 19 |
|
| 20 |
return (
|
| 21 |
-
<div className="relative flex flex-1 flex-col overflow-hidden
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 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-
|
| 35 |
<div className="relative">
|
| 36 |
-
<
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
style={{ animation: 'breathe 3.5s ease-in-out infinite' }}
|
| 39 |
-
>
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
/>
|
| 50 |
-
</div>
|
| 51 |
</div>
|
| 52 |
|
| 53 |
<div className="text-center">
|
| 54 |
-
<h1 className="text-[26px] font-bold tracking-tight text-
|
| 55 |
{t(lang, 'title')}
|
| 56 |
</h1>
|
| 57 |
-
<p className="mt-1.5 text-sm text-
|
| 58 |
{t(lang, 'captureSubtitle')}
|
| 59 |
</p>
|
| 60 |
</div>
|
|
@@ -65,7 +66,11 @@ export function StepCapture({ lang, engine, modelError, onRetryModel, onCamera,
|
|
| 65 |
{t(lang, 'retry')}
|
| 66 |
</button>
|
| 67 |
) : (
|
| 68 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
<span
|
| 70 |
className={`h-1.5 w-1.5 rounded-full ${
|
| 71 |
ready ? 'bg-[var(--success)]' : 'animate-pulse bg-[var(--warning)]'
|
|
@@ -77,7 +82,7 @@ export function StepCapture({ lang, engine, modelError, onRetryModel, onCamera,
|
|
| 77 |
</div>
|
| 78 |
|
| 79 |
{hasError && (
|
| 80 |
-
<div className="mb-4 w-full max-w-sm rounded-2xl border border-red-
|
| 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">
|
|
@@ -110,7 +115,7 @@ export function StepCapture({ lang, engine, modelError, onRetryModel, onCamera,
|
|
| 110 |
<button
|
| 111 |
type="button"
|
| 112 |
disabled={hasError}
|
| 113 |
-
className="
|
| 114 |
onClick={onGallery}
|
| 115 |
>
|
| 116 |
<ImagePlus size={22} strokeWidth={2} />
|
|
@@ -118,10 +123,6 @@ export function StepCapture({ lang, engine, modelError, onRetryModel, onCamera,
|
|
| 118 |
</button>
|
| 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 |
)
|
| 127 |
}
|
|
|
|
| 1 |
import { AlertTriangle, Camera, ImagePlus, RotateCcw } from 'lucide-react'
|
| 2 |
+
import { ASSETS } from '../lib/assets'
|
| 3 |
import { t } from '../lib/i18n'
|
| 4 |
import type { Lang } from '../lib/types'
|
| 5 |
|
|
|
|
| 19 |
const ready = engine === 'local' || engine === 'server'
|
| 20 |
|
| 21 |
return (
|
| 22 |
+
<div className="relative flex flex-1 flex-col overflow-hidden">
|
| 23 |
+
<img
|
| 24 |
+
src={ASSETS.bg}
|
| 25 |
+
alt=""
|
| 26 |
+
aria-hidden
|
| 27 |
+
className="absolute inset-0 h-full w-full object-cover"
|
| 28 |
+
/>
|
| 29 |
+
<div
|
| 30 |
+
className="absolute inset-0"
|
| 31 |
+
style={{ background: 'linear-gradient(180deg, rgba(0,73,115,0.88) 0%, rgba(0,49,77,0.92) 100%)' }}
|
| 32 |
+
/>
|
| 33 |
|
| 34 |
<div className="relative z-10 flex flex-1 flex-col items-center justify-center px-8">
|
| 35 |
+
<div className="mb-8 flex flex-col items-center gap-5">
|
| 36 |
<div className="relative">
|
| 37 |
+
<img
|
| 38 |
+
src={ASSETS.logo}
|
| 39 |
+
alt=""
|
| 40 |
+
className="h-[72px] w-auto max-w-[220px] drop-shadow-md"
|
| 41 |
style={{ animation: 'breathe 3.5s ease-in-out infinite' }}
|
| 42 |
+
/>
|
| 43 |
+
<span
|
| 44 |
+
className={`absolute -right-2 -top-1 h-5 w-5 rounded-full border-[3px] border-[#00314d] transition-all duration-700 ${
|
| 45 |
+
engine === 'none'
|
| 46 |
+
? 'bg-[var(--danger)]'
|
| 47 |
+
: ready
|
| 48 |
+
? 'bg-[var(--success)]'
|
| 49 |
+
: 'animate-pulse bg-[var(--warning)]'
|
| 50 |
+
}`}
|
| 51 |
+
/>
|
|
|
|
|
|
|
| 52 |
</div>
|
| 53 |
|
| 54 |
<div className="text-center">
|
| 55 |
+
<h1 className="text-[26px] font-bold tracking-tight text-white">
|
| 56 |
{t(lang, 'title')}
|
| 57 |
</h1>
|
| 58 |
+
<p className="mt-1.5 text-sm text-white/75">
|
| 59 |
{t(lang, 'captureSubtitle')}
|
| 60 |
</p>
|
| 61 |
</div>
|
|
|
|
| 66 |
{t(lang, 'retry')}
|
| 67 |
</button>
|
| 68 |
) : (
|
| 69 |
+
<div
|
| 70 |
+
className={`ct-badge border border-white/15 ${
|
| 71 |
+
ready ? 'bg-white/15 text-white' : 'bg-white/10 text-white/90'
|
| 72 |
+
}`}
|
| 73 |
+
>
|
| 74 |
<span
|
| 75 |
className={`h-1.5 w-1.5 rounded-full ${
|
| 76 |
ready ? 'bg-[var(--success)]' : 'animate-pulse bg-[var(--warning)]'
|
|
|
|
| 82 |
</div>
|
| 83 |
|
| 84 |
{hasError && (
|
| 85 |
+
<div className="mb-4 w-full max-w-sm rounded-2xl border border-red-300/40 bg-white/95 p-4 shadow-lg">
|
| 86 |
<div className="flex items-start gap-2.5">
|
| 87 |
<AlertTriangle size={18} className="mt-0.5 shrink-0 text-[var(--danger)]" />
|
| 88 |
<div className="min-w-0">
|
|
|
|
| 115 |
<button
|
| 116 |
type="button"
|
| 117 |
disabled={hasError}
|
| 118 |
+
className="flex min-h-14 w-full items-center justify-center gap-3 rounded-[var(--r-lg)] border border-white/25 bg-white/12 text-base font-semibold text-white backdrop-blur-sm transition-transform active:scale-[0.98] active:bg-white/20 disabled:opacity-50"
|
| 119 |
onClick={onGallery}
|
| 120 |
>
|
| 121 |
<ImagePlus size={22} strokeWidth={2} />
|
|
|
|
| 123 |
</button>
|
| 124 |
</div>
|
| 125 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
</div>
|
| 127 |
)
|
| 128 |
}
|
frontend/src/components/StepCounting.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import { useEffect, useState } from 'react'
|
|
|
|
| 2 |
import { t } from '../lib/i18n'
|
| 3 |
import type { Lang } from '../lib/types'
|
| 4 |
|
|
@@ -35,36 +36,12 @@ export function StepCounting({ lang, status, imageSrc }: Props) {
|
|
| 35 |
/>
|
| 36 |
|
| 37 |
<div className="relative z-10 flex flex-col items-center gap-7 px-8 text-center">
|
| 38 |
-
<
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 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)]">
|
|
|
|
| 1 |
import { useEffect, useState } from 'react'
|
| 2 |
+
import { ASSETS } from '../lib/assets'
|
| 3 |
import { t } from '../lib/i18n'
|
| 4 |
import type { Lang } from '../lib/types'
|
| 5 |
|
|
|
|
| 36 |
/>
|
| 37 |
|
| 38 |
<div className="relative z-10 flex flex-col items-center gap-7 px-8 text-center">
|
| 39 |
+
<img
|
| 40 |
+
src={ASSETS.loading}
|
| 41 |
+
alt=""
|
| 42 |
+
className="h-28 w-auto"
|
| 43 |
+
style={{ animation: 'breathe 2s ease-in-out infinite' }}
|
| 44 |
+
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
<div>
|
| 47 |
<h2 className="text-xl font-bold tracking-tight text-[var(--text)]">
|
frontend/src/lib/assets.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** Brand assets from npisb-pipecountapp.hf.space */
|
| 2 |
+
export const ASSETS = {
|
| 3 |
+
bg: '/images/bg.png',
|
| 4 |
+
logo: '/images/choose.svg',
|
| 5 |
+
loading: '/images/loading.svg',
|
| 6 |
+
icon192: '/images/touch/android-chrome-192x192.png',
|
| 7 |
+
icon512: '/images/touch/android-chrome-512x512.png',
|
| 8 |
+
favicon32: '/images/touch/favicon-32x32.png',
|
| 9 |
+
favicon16: '/images/touch/favicon-16x16.png',
|
| 10 |
+
} as const
|
frontend/src/lib/i18n.ts
CHANGED
|
@@ -57,6 +57,7 @@ const messages = {
|
|
| 57 |
noImage: 'Capture or upload a photo of a pipe bundle. Works fully offline after first load.',
|
| 58 |
getStarted: 'Ready to count',
|
| 59 |
company: 'Nawaplastic Industry Co., Ltd.',
|
|
|
|
| 60 |
settings: 'Settings',
|
| 61 |
apply: 'Apply',
|
| 62 |
},
|
|
@@ -116,6 +117,7 @@ const messages = {
|
|
| 116 |
noImage: 'ถ่ายหรืออัปโหลดรูปมัดท่อ ใช้งานออฟไลน์ได้หลังโหลดครั้งแรก',
|
| 117 |
getStarted: 'พร้อมนับท่อ',
|
| 118 |
company: 'บริษัท นวพลาสติก อุตสาหกรรม จำกัด',
|
|
|
|
| 119 |
settings: 'ตั้งค่า',
|
| 120 |
apply: 'ใช้',
|
| 121 |
},
|
|
|
|
| 57 |
noImage: 'Capture or upload a photo of a pipe bundle. Works fully offline after first load.',
|
| 58 |
getStarted: 'Ready to count',
|
| 59 |
company: 'Nawaplastic Industry Co., Ltd.',
|
| 60 |
+
creditFooter: 'Digital Manufacturing · Nawaplastic',
|
| 61 |
settings: 'Settings',
|
| 62 |
apply: 'Apply',
|
| 63 |
},
|
|
|
|
| 117 |
noImage: 'ถ่ายหรืออัปโหลดรูปมัดท่อ ใช้งานออฟไลน์ได้หลังโหลดครั้งแรก',
|
| 118 |
getStarted: 'พร้อมนับท่อ',
|
| 119 |
company: 'บริษัท นวพลาสติก อุตสาหกรรม จำกัด',
|
| 120 |
+
creditFooter: 'Digital Manufacturing · Nawaplastic',
|
| 121 |
settings: 'ตั้งค่า',
|
| 122 |
apply: 'ใช้',
|
| 123 |
},
|
frontend/vite.config.ts
CHANGED
|
@@ -9,21 +9,33 @@ export default defineConfig({
|
|
| 9 |
tailwindcss(),
|
| 10 |
VitePWA({
|
| 11 |
registerType: 'autoUpdate',
|
| 12 |
-
includeAssets: [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
manifest: {
|
| 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: '/',
|
| 22 |
icons: [
|
| 23 |
{
|
| 24 |
-
src: '/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
sizes: '512x512',
|
| 26 |
-
type: 'image/
|
| 27 |
purpose: 'any maskable',
|
| 28 |
},
|
| 29 |
],
|
|
|
|
| 9 |
tailwindcss(),
|
| 10 |
VitePWA({
|
| 11 |
registerType: 'autoUpdate',
|
| 12 |
+
includeAssets: [
|
| 13 |
+
'models/countmodel.onnx',
|
| 14 |
+
'models/countmodel-640.onnx',
|
| 15 |
+
'models/countmodel-int8.onnx',
|
| 16 |
+
'images/**/*',
|
| 17 |
+
'icon.png',
|
| 18 |
+
],
|
| 19 |
manifest: {
|
| 20 |
name: 'NPI Pipe Count',
|
| 21 |
short_name: 'Pipe Count',
|
| 22 |
description: 'Offline pipe counting with diameter sorting',
|
| 23 |
+
theme_color: '#004973',
|
| 24 |
+
background_color: '#004973',
|
| 25 |
display: 'standalone',
|
| 26 |
orientation: 'portrait',
|
| 27 |
start_url: '/',
|
| 28 |
icons: [
|
| 29 |
{
|
| 30 |
+
src: '/images/touch/android-chrome-192x192.png',
|
| 31 |
+
sizes: '192x192',
|
| 32 |
+
type: 'image/png',
|
| 33 |
+
purpose: 'any',
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
src: '/images/touch/android-chrome-512x512.png',
|
| 37 |
sizes: '512x512',
|
| 38 |
+
type: 'image/png',
|
| 39 |
purpose: 'any maskable',
|
| 40 |
},
|
| 41 |
],
|