From d07abe214398d04c117bd3bf87208e6dbc7dae34 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:58:31 -0500 Subject: [PATCH] add circular progress bar component --- .../components/ui/circular-progress-bar.tsx | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 web/src/components/ui/circular-progress-bar.tsx diff --git a/web/src/components/ui/circular-progress-bar.tsx b/web/src/components/ui/circular-progress-bar.tsx new file mode 100644 index 000000000..c1714829e --- /dev/null +++ b/web/src/components/ui/circular-progress-bar.tsx @@ -0,0 +1,108 @@ +import { cn } from "@/lib/utils"; + +interface Props { + max: number; + value: number; + min: number; + gaugePrimaryColor: string; + gaugeSecondaryColor: string; + className?: string; +} + +export default function AnimatedCircularProgressBar({ + max = 100, + min = 0, + value = 0, + gaugePrimaryColor, + gaugeSecondaryColor, + className, +}: Props) { + const circumference = 2 * Math.PI * 45; + const percentPx = circumference / 100; + const currentPercent = Math.floor(((value - min) / (max - min)) * 100); + + return ( +
+ + {currentPercent <= 90 && currentPercent >= 0 && ( + + )} + + + + {currentPercent}% + +
+ ); +}