Spaces:
Runtime error
Runtime error
Khunndev
Sisyphus
Make the counting-to-results moment theatrical with a mono count-up and precision timer.
eef382a Download frontend/src/components/StepCounting.tsx from npisb/pipecountapp-dev: direct link, hf CLI and curl.
- Browser
- Download file 3.41 kB
-
https://huggingface.co/spaces/npisb/pipecountapp-dev/resolve/main/frontend/src/components/StepCounting.tsx
- Command line
-
hf download hf://spaces/npisb/pipecountapp-dev/frontend/src/components/StepCounting.tsx
-
curl -L -o StepCounting.tsx https://huggingface.co/spaces/npisb/pipecountapp-dev/resolve/main/frontend/src/components/StepCounting.tsx
3.41 kB
| import { useEffect, useState } from 'react' | |
| import { ASSETS } from '../lib/assets' | |
| import { t } from '../lib/i18n' | |
| import type { Lang } from '../lib/types' | |
| interface Props { | |
| lang: Lang | |
| status: string | |
| imageSrc?: string | |
| } | |
| export function StepCounting({ lang, status, imageSrc }: Props) { | |
| const [dots, setDots] = useState(0) | |
| const [deci, setDeci] = useState(0) | |
| useEffect(() => { | |
| const id = setInterval(() => setDots((d) => (d + 1) % 4), 500) | |
| return () => clearInterval(id) | |
| }, []) | |
| useEffect(() => { | |
| const id = setInterval(() => setDeci((d) => d + 1), 100) | |
| return () => clearInterval(id) | |
| }, []) | |
| return ( | |
| <div className="relative flex flex-1 flex-col items-center justify-center overflow-hidden bg-[var(--bg)] grain"> | |
| {imageSrc && ( | |
| <img | |
| src={imageSrc} | |
| alt="" | |
| aria-hidden | |
| className="absolute inset-0 h-full w-full scale-110 object-cover opacity-20 blur-2xl" | |
| /> | |
| )} | |
| <div | |
| className="pointer-events-none absolute inset-0" | |
| style={{ | |
| background: 'radial-gradient(ellipse 70% 60% at 50% 50%, transparent 20%, var(--bg) 100%)', | |
| }} | |
| /> | |
| <div className="relative z-10 flex flex-col items-center gap-8 px-8 text-center"> | |
| <img | |
| src={ASSETS.loading} | |
| alt="" | |
| className="h-28 w-auto" | |
| style={{ animation: 'breathe 2s ease-in-out infinite' }} | |
| /> | |
| <div className="flex flex-col items-center gap-2"> | |
| <h2 | |
| className="rise-enter text-[var(--text)]" | |
| style={{ font: 'var(--type-h2)', letterSpacing: 'var(--tracking-snug)', animationDelay: '0.08s' }} | |
| > | |
| {t(lang, 'countingTitle')}{''.padEnd(dots, '.')} | |
| </h2> | |
| <p | |
| className="rise-enter min-h-6 text-[var(--text-dim)]" | |
| style={{ font: 'var(--type-body)', animationDelay: '0.16s' }} | |
| > | |
| {status || t(lang, 'pleaseWait')} | |
| </p> | |
| </div> | |
| <div | |
| className="rise-enter h-1.5 w-52 overflow-hidden rounded-full border border-[var(--hairline)] bg-[var(--surface-sunken)]" | |
| style={{ boxShadow: 'var(--shadow-inset)', animationDelay: '0.24s' }} | |
| > | |
| <div | |
| className="h-full rounded-full" | |
| style={{ | |
| width: '35%', | |
| background: | |
| 'linear-gradient(90deg, var(--brand-muted), var(--brand) 60%, var(--brand-hover))', | |
| boxShadow: '0 0 12px rgba(0,49,77,0.35)', | |
| animation: 'track-slide 1.8s var(--ease-ios) infinite', | |
| }} | |
| /> | |
| </div> | |
| <div | |
| className="rise-enter flex items-baseline gap-1 rounded-[var(--r-md)] border border-[var(--hairline)] bg-[var(--surface-sunken)] px-4 py-2" | |
| style={{ boxShadow: 'var(--shadow-inset)', animationDelay: '0.32s' }} | |
| > | |
| <span | |
| aria-live="polite" | |
| className="tabular-nums text-[var(--brand)]" | |
| style={{ font: '700 var(--text-2xl)/1 var(--font-mono)', letterSpacing: 'var(--tracking-tight)' }} | |
| > | |
| {(deci / 10).toFixed(1)} | |
| </span> | |
| <span | |
| className="text-[var(--text-faint)]" | |
| style={{ font: '600 var(--text-xs)/1 var(--font-mono)' }} | |
| > | |
| s | |
| </span> | |
| </div> | |
| </div> | |
| </div> | |
| ) | |
| } | |