Skip to content
Open
Show file tree
Hide file tree
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
201 changes: 61 additions & 140 deletions apps/web/src/components/usage/UsageLimitsPooled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,150 +392,74 @@ function SegmentTriggers({
.filter(Boolean)
.join(", ");
return (
<>
<PopoverTrigger
handle={popover}
payload={payload}
openOnHover
render={
<button
ref={segmentRef}
type="button"
style={{ gridColumn: index, gridRow: 1, ...paceMark?.gappedTrack }}
aria-label={segmentLabel}
className="relative h-5 min-w-0 cursor-pointer rounded-md bg-muted text-start outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background data-[popup-open]:ring-1 data-[popup-open]:ring-inset data-[popup-open]:ring-border @2xl/pool:h-8"
<PopoverTrigger
handle={popover}
payload={payload}
openOnHover
render={
<button
ref={segmentRef}
type="button"
style={{ gridColumn: index, gridRow: 1, ...paceMark?.gappedTrack }}
aria-label={segmentLabel}
className="relative h-8 min-w-0 cursor-pointer rounded-md bg-muted text-start outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background data-[popup-open]:ring-1 data-[popup-open]:ring-inset data-[popup-open]:ring-border"
/>
}
>
<div aria-hidden className="absolute inset-0 overflow-hidden rounded-md">
{/* Clipped inside the rounded clip so the bar's own corners keep their antialiasing. */}
<div className="absolute inset-0" style={paceMark?.gap}>
<div
aria-hidden
className="absolute inset-y-0 left-0 rounded-md opacity-35"
style={{ width: `${remaining}%`, backgroundColor: color }}
/>
}
>
<div aria-hidden className="absolute inset-0 overflow-hidden rounded-md">
{/* Clipped inside the rounded clip so the bar's own corners keep their antialiasing. */}
<div className="absolute inset-0" style={paceMark?.gap}>
{remaining < 100 && reset && refillPercent > 0 ? (
<div
aria-hidden
className="absolute inset-y-0 left-0 rounded-md opacity-35"
style={{ width: `${remaining}%`, backgroundColor: color }}
/>
{remaining < 100 && reset && refillPercent > 0 ? (
<div
aria-hidden
className="absolute inset-y-0 right-0 opacity-20"
style={{
width: `${Math.min(100 - remaining, refillPercent)}%`,
backgroundImage: `repeating-linear-gradient(135deg, ${color} 0 1px, transparent 1px 5px)`,
}}
/>
) : null}
</div>
</div>
{paceMark ? (
<span
aria-hidden
className="absolute inset-y-0.5 w-0.5 -translate-x-1/2 rounded-full bg-foreground"
style={paceMark.tick}
/>
) : null}
<span
aria-hidden
className="absolute inset-0 flex items-center justify-center overflow-hidden rounded-md text-3xs leading-none font-semibold text-foreground/80 tabular-nums @2xl/pool:hidden"
>
{index}
</span>
<div className="relative hidden h-full min-w-0 items-center gap-1.5 overflow-hidden rounded-md px-2 text-xs @2xl/pool:flex">
{showAccountName ? (
<AccountName
account={account}
className="min-w-0 truncate font-medium text-foreground"
className="absolute inset-y-0 right-0 opacity-20"
style={{
width: `${Math.min(100 - remaining, refillPercent)}%`,
backgroundImage: `repeating-linear-gradient(135deg, ${color} 0 1px, transparent 1px 5px)`,
}}
/>
) : null}
{/* A single-account bar repeats the headline percentage. */}
{showAccountName ? (
<span className="shrink-0 font-semibold text-foreground tabular-nums">
{remaining}%
</span>
) : null}
{resetsIn || credits ? (
<span className="ms-auto flex min-w-0 items-center gap-1.5 overflow-hidden rounded-sm bg-background/85 px-1.5 py-0.5 text-2xs whitespace-nowrap text-foreground tabular-nums">
{refillIn ?? ""}
{credits ? (
<>
{resetsIn ? (
<span aria-hidden className="text-muted-foreground">
·
</span>
) : null}
<span aria-hidden className="inline-flex items-center gap-0.5 font-semibold">
<TicketIcon className="size-3" aria-hidden />
{credits}
</span>
</>
) : null}
</span>
) : null}
</div>
</PopoverTrigger>
<LegendRow payload={payload} color={color} now={now} index={index} />
</>
);
}

function LegendRow({
payload,
color,
now,
index,
}: {
readonly payload: SegmentPayload;
readonly color: string;
readonly now: number;
readonly index: number;
}) {
const popover = use(SegmentPopoverContext) ?? undefined;
const { account, window } = payload;
const remaining = remainingPercent(window);
const m = useMessages();
const resetsIn = formatResetsIn(window, now, m, "refill");
const credits = account.limits.resetCredits?.availableCount ?? 0;
const gt = useGT();
return (
<PopoverTrigger
handle={popover}
payload={payload}
style={{ gridColumn: "1 / -1", gridRow: index + 1 }}
render={<Button variant="ghost" size="compact" />}
className="min-w-0 @2xl/pool:hidden"
>
<span className="relative inline-flex size-4 shrink-0 items-center justify-center rounded-sm text-3xs leading-none font-semibold text-foreground/80 tabular-nums">
</div>
{paceMark ? (
<span
aria-hidden
className="absolute inset-0 rounded-sm opacity-35"
style={{ backgroundColor: color }}
className="absolute inset-y-0.5 w-0.5 -translate-x-1/2 rounded-full bg-foreground"
style={paceMark.tick}
/>
<span className="sr-only">{`${gt("Segment")} `}</span>
<span className="relative">{index}</span>
</span>
<AccountName account={account} className="min-w-0 truncate font-medium text-foreground" />
<span className="shrink-0 font-semibold text-foreground tabular-nums">{remaining}%</span>
<span className="ms-auto flex shrink-0 items-center gap-1.5 text-2xs text-muted-foreground tabular-nums">
{resetsIn ?? ""}
{credits ? (
<>
{resetsIn ? <span aria-hidden>·</span> : null}
<span
aria-hidden
className="inline-flex items-center gap-0.5 font-semibold text-foreground"
>
<TicketIcon className="size-3" aria-hidden />
{credits}
</span>
<span className="sr-only">
{gt(
"{count, plural, one {{count} reset credit banked} other {{count} reset credits banked}}",
{ count: credits },
)}
</span>
</>
) : null}
<div className="relative flex h-full min-w-0 items-center gap-1.5 overflow-hidden rounded-md px-2 text-xs">
{showAccountName ? (
<AccountName account={account} className="min-w-0 truncate font-medium text-foreground" />
) : null}
</span>
{/* A single-account bar repeats the headline percentage. */}
{showAccountName ? (
<span className="shrink-0 font-semibold text-foreground tabular-nums">{remaining}%</span>
) : null}
{resetsIn || credits ? (
<span className="ms-auto flex min-w-0 items-center gap-1.5 overflow-hidden rounded-sm bg-background/85 px-1.5 py-0.5 text-2xs whitespace-nowrap text-foreground tabular-nums">
{refillIn ?? ""}
{credits ? (
<>
{resetsIn ? (
<span aria-hidden className="text-muted-foreground">
·
</span>
) : null}
<span aria-hidden className="inline-flex items-center gap-0.5 font-semibold">
<TicketIcon className="size-3" aria-hidden />
{credits}
</span>
</>
) : null}
</span>
) : null}
</div>
Comment thread
maria-rcks marked this conversation as resolved.
Resolved
</PopoverTrigger>
);
}
Expand All @@ -552,7 +476,7 @@ function PoolBar({
const restores = new Map(pool.resets.map((reset) => [reset.member.account.key, reset]));
const gt = useGT();
return (
<div className="@container/pool min-w-0">
<div className="min-w-0">
<div
className="grid gap-x-1 gap-y-1"
style={{ gridTemplateColumns: `repeat(${pool.columns.length}, minmax(0, 1fr))` }}
Expand All @@ -574,12 +498,9 @@ function PoolBar({
<div
key={member.account.key}
style={{ gridColumn: position + 1, gridRow: 1 }}
className="flex h-5 min-w-0 items-center justify-center gap-1.5 overflow-hidden rounded-md border border-dashed border-border text-3xs whitespace-nowrap text-muted-foreground @2xl/pool:h-8 @2xl/pool:justify-start @2xl/pool:px-2 @2xl/pool:text-xs"
className="flex h-8 min-w-0 items-center justify-start gap-1.5 overflow-hidden rounded-md border border-dashed border-border px-2 text-xs whitespace-nowrap text-muted-foreground"
>
<AccountName
account={member.account}
className="hidden min-w-0 truncate @2xl/pool:inline-flex"
/>
<AccountName account={member.account} className="inline-flex min-w-0 truncate" />
{gt("$0 cap")}
</div>
) : null,
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -11890,7 +11890,6 @@
"0bd938825ffcf992": "+{percent} % des Kontingents",
"09c0e00d7fb55402": "Reset-Guthaben wird verwendet…",
"4df3ff1be768a7ab": "{name}: {remaining} % übrig",
"7aaaff1c6484f25c": "Segment",
"8bcab2ef61de6518": "0-$-Limit",
"a16b48709357a5a7": "Nutzung verwalten",
"a00e74aaa421c524": "übrig",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11898,7 +11898,6 @@
"0bd938825ffcf992": "+{percent}% of pool",
"09c0e00d7fb55402": "Using reset credit…",
"4df3ff1be768a7ab": "{name}: {remaining}% left",
"7aaaff1c6484f25c": "Segment",
"8bcab2ef61de6518": "$0 cap",
"a16b48709357a5a7": "Manage usage",
"a00e74aaa421c524": "left",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -11883,7 +11883,6 @@
"0bd938825ffcf992": "+{percent}% del total",
"09c0e00d7fb55402": "Usando el crédito de restablecimiento…",
"4df3ff1be768a7ab": "{name}: queda un {remaining}%",
"7aaaff1c6484f25c": "Segmento",
"8bcab2ef61de6518": "Límite de 0 $",
"a16b48709357a5a7": "Gestionar uso",
"a00e74aaa421c524": "restante",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -11888,7 +11888,6 @@
"0bd938825ffcf992": "+{percent} % du quota",
"09c0e00d7fb55402": "Utilisation du crédit de réinitialisation…",
"4df3ff1be768a7ab": "{name} : {remaining} % restant",
"7aaaff1c6484f25c": "Segment",
"8bcab2ef61de6518": "Plafond de 0 $",
"a16b48709357a5a7": "Gérer l’utilisation",
"a00e74aaa421c524": "restant",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -11838,7 +11838,6 @@
"0bd938825ffcf992": "プールの +{percent}%",
"09c0e00d7fb55402": "リセットクレジットを使用しています…",
"4df3ff1be768a7ab": "{name}: 残り {remaining}%",
"7aaaff1c6484f25c": "セグメント",
"8bcab2ef61de6518": "上限 $0",
"a16b48709357a5a7": "使用量を管理",
"a00e74aaa421c524": "残り",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -11835,7 +11835,6 @@
"0bd938825ffcf992": "풀의 +{percent}%",
"09c0e00d7fb55402": "초기화 크레딧 사용 중…",
"4df3ff1be768a7ab": "{name}: {remaining}% 남음",
"7aaaff1c6484f25c": "구간",
"8bcab2ef61de6518": "$0 한도",
"a16b48709357a5a7": "사용량 관리",
"a00e74aaa421c524": "남음",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -11887,7 +11887,6 @@
"0bd938825ffcf992": "+{percent}% do total",
"09c0e00d7fb55402": "Usando crédito de redefinição…",
"4df3ff1be768a7ab": "{name}: {remaining}% restante",
"7aaaff1c6484f25c": "Segmento",
"8bcab2ef61de6518": "Limite de $0",
"a16b48709357a5a7": "Gerenciar uso",
"a00e74aaa421c524": "restante",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -11888,7 +11888,6 @@
"0bd938825ffcf992": "+{percent}% пула",
"09c0e00d7fb55402": "Использование кредита на сброс…",
"4df3ff1be768a7ab": "{name}: осталось {remaining}%",
"7aaaff1c6484f25c": "Сегмент",
"8bcab2ef61de6518": "Лимит $0",
"a16b48709357a5a7": "Управление использованием",
"a00e74aaa421c524": "осталось",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -11896,7 +11896,6 @@
"0bd938825ffcf992": "+{percent} % av poolen",
"09c0e00d7fb55402": "Använder återställningskredit…",
"4df3ff1be768a7ab": "{name}: {remaining} % kvar",
"7aaaff1c6484f25c": "Segment",
"8bcab2ef61de6518": "Tak på 0 $",
"a16b48709357a5a7": "Hantera användning",
"a00e74aaa421c524": "kvar",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -11913,7 +11913,6 @@
"0bd938825ffcf992": "+{percent}%(按共享池总额度计算)",
"09c0e00d7fb55402": "正在使用重置额度…",
"4df3ff1be768a7ab": "{name}:剩余 {remaining}%",
"7aaaff1c6484f25c": "分段",
"8bcab2ef61de6518": "上限 $0",
"a16b48709357a5a7": "管理用量",
"a00e74aaa421c524": "剩余",
Expand Down
Loading