File size: 1,051 Bytes
0f0d9a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { cn } from '@/lib/utils';

type Props = {
  total: number;
  current: number;
  doneCount: number;
  liveProgress?: number;
};

export function ProgressPips({ total, current, doneCount, liveProgress = 0 }: Props) {
  return (
    <div className="flex gap-1 px-4">

      {Array.from({ length: total }, (_, i) => {

        const idx = i + 1;

        const isDone = idx <= doneCount;

        const isCurrent = idx === current && !isDone;

        return (

          <div

            key={idx}

            className={cn(

              'h-[3px] flex-1 overflow-hidden rounded-full',

              isDone ? 'bg-sage' : 'bg-white/20',

            )}

          >

            {isCurrent ? (

              <div

                className="h-full bg-sage transition-[width] duration-100 ease-linear"

                style={{

                  width: `${Math.max(8, Math.min(100, liveProgress * 100))}%`,

                }}

              />

            ) : null}

          </div>

        );

      })}

    </div>
  );
}