|
1 |
| -"use client" |
| 1 | +"use client"; |
2 | 2 |
|
3 |
| -import * as React from "react" |
4 |
| -import * as ProgressPrimitive from "@radix-ui/react-progress" |
| 3 | +import * as React from "react"; |
| 4 | +import * as ProgressPrimitive from "@radix-ui/react-progress"; |
5 | 5 |
|
6 |
| -import { cn } from "@/lib/utils" |
| 6 | +import { cn } from "@/lib/utils"; |
| 7 | + |
| 8 | +interface ProgressProps |
| 9 | + extends React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> { |
| 10 | + indeterminate?: boolean; |
| 11 | +} |
7 | 12 |
|
8 | 13 | const Progress = React.forwardRef<
|
9 | 14 | React.ElementRef<typeof ProgressPrimitive.Root>,
|
10 |
| - React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> |
11 |
| ->(({ className, value, ...props }, ref) => ( |
| 15 | + ProgressProps |
| 16 | +>(({ className, value, indeterminate = false, ...props }, ref) => ( |
12 | 17 | <ProgressPrimitive.Root
|
13 | 18 | ref={ref}
|
14 | 19 | className={cn(
|
15 |
| - "relative h-2 w-full overflow-hidden rounded-full bg-primary/20", |
| 20 | + "relative h-4 w-full overflow-hidden rounded-full bg-secondary", |
16 | 21 | className
|
17 | 22 | )}
|
18 | 23 | {...props}
|
19 | 24 | >
|
20 | 25 | <ProgressPrimitive.Indicator
|
21 |
| - className="h-full w-full flex-1 bg-primary transition-all" |
| 26 | + className={cn( |
| 27 | + "h-full w-full flex-1 bg-primary transition-all", |
| 28 | + indeterminate && "animate-progress origin-left" |
| 29 | + )} |
22 | 30 | style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
23 | 31 | />
|
24 | 32 | </ProgressPrimitive.Root>
|
25 |
| -)) |
26 |
| -Progress.displayName = ProgressPrimitive.Root.displayName |
| 33 | +)); |
| 34 | +Progress.displayName = ProgressPrimitive.Root.displayName; |
27 | 35 |
|
28 |
| -export { Progress } |
| 36 | +export { Progress }; |
0 commit comments