@@ -8,32 +8,16 @@ type UsageBarProps = {
88 current : number ;
99 billingLimit ?: number ;
1010 tierLimit ?: number ;
11- projectedUsage ?: number ;
1211 isPaying : boolean ;
1312} ;
1413
1514const startFactor = 4 ;
1615
17- export function UsageBar ( {
18- current,
19- billingLimit,
20- tierLimit,
21- projectedUsage,
22- isPaying,
23- } : UsageBarProps ) {
24- const getLargestNumber = Math . max (
25- current ,
26- tierLimit ?? - Infinity ,
27- projectedUsage ?? - Infinity ,
28- billingLimit ?? - Infinity ,
29- 5
30- ) ;
16+ export function UsageBar ( { current, billingLimit, tierLimit, isPaying } : UsageBarProps ) {
17+ const getLargestNumber = Math . max ( current , tierLimit ?? - Infinity , billingLimit ?? - Infinity , 5 ) ;
3118 //creates a maximum range for the progress bar, add 10% to the largest number so the bar doesn't reach the end
3219 const maxRange = Math . round ( getLargestNumber * 1.1 ) ;
3320 const tierRunLimitPercentage = tierLimit ? Math . round ( ( tierLimit / maxRange ) * 100 ) : 0 ;
34- const projectedRunsPercentage = projectedUsage
35- ? Math . round ( ( projectedUsage / maxRange ) * 100 )
36- : 0 ;
3721 const billingLimitPercentage =
3822 billingLimit !== undefined ? Math . round ( ( billingLimit / maxRange ) * 100 ) : 0 ;
3923 const usagePercentage = Math . round ( ( current / maxRange ) * 100 ) ;
@@ -42,7 +26,7 @@ export function UsageBar({
4226 const usageCappedToLimitPercentage = Math . min ( usagePercentage , tierRunLimitPercentage ) ;
4327
4428 return (
45- < div className = "h-fit w-full py-12 " >
29+ < div className = "h-fit w-full py-6 " >
4630 < div className = "relative h-3 w-full rounded-sm bg-background-bright" >
4731 { billingLimit !== undefined && (
4832 < motion . div
@@ -93,23 +77,6 @@ export function UsageBar({
9377 />
9478 </ motion . div >
9579 ) }
96- { projectedUsage !== undefined && projectedUsage !== 0 && (
97- < motion . div
98- initial = { { width : projectedRunsPercentage / startFactor + "%" } }
99- animate = { { width : projectedRunsPercentage + "%" } }
100- transition = { { duration : 1.5 , type : "spring" } }
101- style = { { width : `${ projectedRunsPercentage } %` } }
102- className = "absolute h-3 rounded-l-sm"
103- >
104- < Legend
105- text = "Projected:"
106- value = { formatCurrency ( projectedUsage , false ) }
107- position = "topRow2"
108- percentage = { projectedRunsPercentage }
109- />
110- </ motion . div >
111- ) }
112-
11380 < motion . div
11481 initial = { { width : usageCappedToLimitPercentage / startFactor + "%" } }
11582 animate = { { width : usageCappedToLimitPercentage + "%" } }
0 commit comments