"use client" import * as React from "react" import * as ProgressPrimitive from "@radix-ui/react-progress" import { cn } from "../../design-lib/utils" const Progress = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { max?: number min?: number value: number enableProgressColor?: boolean customColors?: { 25?: string 50?: string 75?: string 100?: string default?: string } } >( ( { className, value, max = 100, min = 0, enableProgressColor, customColors, ...props }, ref ) => { const colors = { 25: "var(--error)", 50: "var(--warning)", 75: "var(--violet)", 100: "var(--success)", default: "var(--primary)", ...customColors, } let percentage if (value > max) { percentage = max } else if (value < min) { percentage = min } else { percentage = value } // Error handling for invalid min, max values if (min >= max) { return null } let color if (percentage <= 25) { color = colors[25] } else if (percentage <= 50) { color = colors[50] } else if (percentage <= 75) { color = colors[75] } else if (percentage <= 100) { color = colors[100] } else { color = colors["default"] } return ( ) } ) Progress.displayName = ProgressPrimitive.Root.displayName export { Progress }