File size: 1,100 Bytes
09fa60b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import * as React from "react";
import { cn } from "@/lib/utils";

export interface ProgressProps
  extends React.HTMLAttributes<HTMLDivElement> {
  value?: number;
}

const Progress = React.forwardRef<HTMLDivElement, ProgressProps>(
  ({ className, value, ...props }, ref) => {
    const isIndeterminate = value === undefined;
    
    return (
      <div

        ref={ref}

        className={cn(

          "relative h-4 w-full overflow-hidden rounded-full bg-secondary",

          className

        )}

        {...props}

      >

        <div

          className={cn(

            "h-full flex-1 transition-all",

            isIndeterminate

              ? "w-full bg-gradient-to-r from-primary via-purple-500 to-primary animate-gradient bg-[length:200%_100%]"

              : "w-full bg-primary"

          )}

          style={

            !isIndeterminate

              ? { transform: `translateX(-${100 - (value || 0)}%)` }

              : undefined

          }

        />

      </div>
    );
  }
);
Progress.displayName = "Progress";

export { Progress };