Skip to content

Commit 6fe2afb

Browse files
authoredMar 11, 2025··
feat(UI): have red ring when full quotas (#983)
**Before**: <img width="449" alt="Capture d’écran 2025-02-22 à 20 59 54" src="https://github.com/user-attachments/assets/06eec7f9-187a-411e-901a-787a4d5d4b60" /> **After**: <img width="449" alt="Capture d’écran 2025-02-22 à 21 08 25" src="https://github.com/user-attachments/assets/746e16f2-132e-4f93-8ee8-3ce0b8227020" />
1 parent 9918be4 commit 6fe2afb

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed
 

‎frontend/components/QuotaCard.tsx

+12-6
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,28 @@ export function QuotaCard(
2121
}
2222

2323
function QuotaUsage(props: { limit: number; usage: number }) {
24-
let color = "bg-jsr-yellow-400";
2524
const percent = props.usage / props.limit;
25+
26+
let bgColor = "bg-jsr-yellow-400";
27+
const ringColor = percent >= 1 ? "ring-red-700" : "ring-jsr-yellow-700";
28+
2629
if (percent >= 1) {
27-
color = "bg-red-500";
30+
bgColor = "bg-red-500";
2831
} else if (percent > 0.9) {
29-
color = "bg-orange-400";
32+
bgColor = "bg-orange-400";
3033
} else if (percent > 0.8) {
31-
color = "bg-jsr-yellow-500";
34+
bgColor = "bg-jsr-yellow-500";
3235
}
3336

3437
return (
3538
<div class="mt-4 flex items-center gap-2">
36-
<div class="overflow-hidden h-3 w-full rounded bg-jsr-yellow-50 ring-1 ring-jsr-yellow-500">
39+
<div
40+
class={`overflow-hidden h-3 w-full rounded bg-jsr-yellow-50 ring-1 ${ringColor}`}
41+
>
3742
<div
3843
style={{ width: `${percent * 100}%` }}
39-
class={`h-full ${color}`}
44+
// We deduplicate ring classes here to avoid whitespace between "bar" and "ring"
45+
class={`h-full ${bgColor} ring-1 ${ringColor}`}
4046
>
4147
</div>
4248
</div>

0 commit comments

Comments
 (0)
Please sign in to comment.