File size: 3,409 Bytes
ddec551
e205988
ddec551
 
 
 
 
 
 
 
 
 
 
906b5bb
ddec551
 
 
 
 
 
906b5bb
 
 
 
 
ddec551
eef382a
ddec551
 
 
 
 
d30af0c
ddec551
 
 
445c3cc
 
 
bd603dd
445c3cc
 
 
eef382a
e205988
 
 
 
 
 
ddec551
eef382a
 
 
 
 
ddec551
 
eef382a
 
 
 
445c3cc
ddec551
 
 
eef382a
 
 
 
445c3cc
eef382a
 
 
 
 
 
 
 
445c3cc
ddec551
906b5bb
 
eef382a
 
906b5bb
eef382a
 
 
 
 
 
 
 
 
 
 
 
 
906b5bb
ddec551
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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>
  )
}