Skip to content

feat(UI): have red ring when full quotas #983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions frontend/components/QuotaCard.tsx
Original file line number Diff line number Diff line change
@@ -21,22 +21,28 @@ export function QuotaCard(
}

function QuotaUsage(props: { limit: number; usage: number }) {
let color = "bg-jsr-yellow-400";
const percent = props.usage / props.limit;

let bgColor = "bg-jsr-yellow-400";
const ringColor = percent >= 1 ? "ring-red-700" : "ring-jsr-yellow-700";

if (percent >= 1) {
color = "bg-red-500";
bgColor = "bg-red-500";
} else if (percent > 0.9) {
color = "bg-orange-400";
bgColor = "bg-orange-400";
} else if (percent > 0.8) {
color = "bg-jsr-yellow-500";
bgColor = "bg-jsr-yellow-500";
}

return (
<div class="mt-4 flex items-center gap-2">
<div class="overflow-hidden h-3 w-full rounded bg-jsr-yellow-50 ring-1 ring-jsr-yellow-500">
<div
class={`overflow-hidden h-3 w-full rounded bg-jsr-yellow-50 ring-1 ${ringColor}`}
>
<div
style={{ width: `${percent * 100}%` }}
class={`h-full ${color}`}
// We deduplicate ring classes here to avoid whitespace between "bar" and "ring"
class={`h-full ${bgColor} ring-1 ${ringColor}`}
>
</div>
</div>