diff --git a/apps/web/src/components/layouts/AppLayout/Header/UsageIndicator/index.tsx b/apps/web/src/components/layouts/AppLayout/Header/UsageIndicator/index.tsx index 1e1103825..40d976833 100644 --- a/apps/web/src/components/layouts/AppLayout/Header/UsageIndicator/index.tsx +++ b/apps/web/src/components/layouts/AppLayout/Header/UsageIndicator/index.tsx @@ -24,14 +24,15 @@ function UsageIndicatorCircle({ isLoading: boolean }) { const ratio = useMemo(() => { - if (!data) return 0 - if (data.max === 0) return 0 - const actualRatio = (data.max - data.usage) / data.max + if (!data) return 1 + if (data.max === 0) return 1 + const actualRatio = data.usage / data.max - if (actualRatio <= 0) return 0 if (actualRatio >= 1) return 1 + if (actualRatio <= 0) return 0 + + if (actualRatio < 0.01) return 0.01 // Too small of a value makes the progress so small its not visible - if (actualRatio < 0.01) return 0.01 // Too low of a ratio makes the circle so small it disappears return actualRatio }, [data]) @@ -46,20 +47,18 @@ function UsageIndicatorCircle({ /> ) } - if (ratio <= 0) { - return - } return ( 0.25 + ratio < 0.75 ? 'primary' - : ratio === 0 + : ratio >= 1 ? 'destructive' : 'warningMutedForeground' } + showBackground {...props} /> ) diff --git a/packages/web-ui/src/ds/atoms/CircularProgress/index.tsx b/packages/web-ui/src/ds/atoms/CircularProgress/index.tsx index 4e7995042..1e7f82cff 100644 --- a/packages/web-ui/src/ds/atoms/CircularProgress/index.tsx +++ b/packages/web-ui/src/ds/atoms/CircularProgress/index.tsx @@ -8,7 +8,7 @@ import { colors, TextColor } from '../../tokens' export type CircularProgressProps = { value: number color?: TextColor - backgroundColor?: TextColor + showBackground?: boolean size?: number strokeWidth?: number className?: string @@ -18,7 +18,7 @@ export type CircularProgressProps = { export function CircularProgress({ value: valueProp, color = 'primary', - backgroundColor, + showBackground, size = 14, strokeWidth = 3, className, @@ -44,17 +44,13 @@ export function CircularProgress({ height={size} className={cn('-rotate-90', colors.textColors[color], className)} > - {backgroundColor && ( + {showBackground && (