Fix: constrain usage bar to 0-100 (#2650)

This commit is contained in:
shamoon
2024-01-16 16:07:20 -08:00
committed by GitHub
parent d61d0eb88f
commit 1f905bc241

View File

@@ -1,10 +1,11 @@
export default function UsageBar({ percent, additionalClassNames = "" }) { export default function UsageBar({ percent, additionalClassNames = "" }) {
const normalized = Math.min(100, Math.max(0, percent));
return ( return (
<div className={`mt-0.5 w-full bg-theme-800/30 rounded-full h-1 dark:bg-theme-200/20 ${additionalClassNames}`}> <div className={`mt-0.5 w-full bg-theme-800/30 rounded-full h-1 dark:bg-theme-200/20 ${additionalClassNames}`}>
<div <div
className="bg-theme-800/70 h-1 rounded-full dark:bg-theme-200/50 transition-all duration-1000" className="bg-theme-800/70 h-1 rounded-full dark:bg-theme-200/50 transition-all duration-1000"
style={{ style={{
width: `${percent}%`, width: `${normalized}%`,
}} }}
/> />
</div> </div>