mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 04:27:56 +00:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import * as React from "react"
|
|
import * as ProgressPrimitive from "@radix-ui/react-progress"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
|
|
interface ProgressProps extends
|
|
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> {
|
|
variant?: "default" | "success" | "warning" | "error"
|
|
}
|
|
|
|
const Progress = React.forwardRef<
|
|
React.ElementRef<typeof ProgressPrimitive.Root>,
|
|
ProgressProps
|
|
>(({ className, value, variant = "default", ...props }, ref) => (
|
|
<ProgressPrimitive.Root
|
|
ref={ref}
|
|
className={cn(
|
|
"relative h-2 w-full overflow-hidden rounded-full bg-secondary/40",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
<ProgressPrimitive.Indicator
|
|
className={cn(
|
|
"h-full w-full flex-1 transition-all duration-300 ease-in-out",
|
|
variant === "default" && "bg-primary",
|
|
variant === "success" && "bg-green-500",
|
|
variant === "warning" && "bg-yellow-500",
|
|
variant === "error" && "bg-destructive",
|
|
)}
|
|
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
|
/>
|
|
</ProgressPrimitive.Root>
|
|
))
|
|
Progress.displayName = ProgressPrimitive.Root.displayName
|
|
|
|
export { Progress }
|