Skip to content
Closed
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
83 changes: 60 additions & 23 deletions apps/web/src/components/usage/UsageLimitsPooled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,10 @@ function SegmentTriggers({
type="button"
style={{ gridColumn: index, gridRow: 1, ...paceMark?.gappedTrack }}
aria-label={`${account.displayName ?? (account.email ? accountInitials(account.email) : account.driver)}: ${remaining}% left${resetsIn ? `, ${resetsIn}` : ""}${timeLeft === null ? "" : `, ${timeLeft}% of the window left`}${credits ? `, ${credits} reset ${credits === 1 ? "credit" : "credits"} banked` : ""}`}
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"
className={cn(
"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",
!showAccountName && "@xs/pool:h-8",
)}
/>
}
>
Expand Down Expand Up @@ -395,11 +398,19 @@ function SegmentTriggers({
) : 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"
className={cn(
"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",
!showAccountName && "@xs/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">
<div
className={cn(
"relative hidden h-full min-w-0 items-center gap-1.5 overflow-hidden rounded-md px-2 text-xs @2xl/pool:flex",
!showAccountName && "@xs/pool:flex",
)}
>
{showAccountName ? (
<AccountName
account={account}
Expand Down Expand Up @@ -432,7 +443,9 @@ function SegmentTriggers({
) : null}
</div>
</PopoverTrigger>
<LegendRow payload={payload} color={color} now={now} index={index} />
<div className={cn("contents", !showAccountName && "@xs/pool:hidden")}>
<LegendRow payload={payload} color={color} now={now} index={index} />
</div>
</>
);
}
Expand Down Expand Up @@ -556,31 +569,55 @@ function PoolWindowCard({
readonly description?: string | undefined;
}) {
const nextRefill = pool.resets.find((reset) => reset.restoresPercent > 0);
const inlineBar = pool.columns.length === 1 && label !== null;
return (
<div className="grid items-center gap-x-6 gap-y-3 rounded-lg border border-border/60 p-4 md:grid-cols-[11rem_minmax(0,1fr)]">
<div className="flex flex-col gap-1">
<div className="@container/usage-window w-full max-w-4xl">
<div
className={cn(
"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-2 rounded-lg border border-border/60 px-3 py-2.5",
inlineBar && "@2xl/usage-window:grid-cols-[minmax(0,12rem)_minmax(0,1fr)_auto]",
)}
>
{label !== null ? (
<span className="text-sm font-medium text-foreground">{label ?? pool.label}</span>
) : null}
<span className="flex items-baseline gap-2">
<span className="text-3xl font-semibold text-foreground tabular-nums">
{pool.remainingPercent}%
</span>
<span className="inline-flex items-center gap-2 text-sm text-muted-foreground">
<span>left</span>
{pool.pace ? <PaceIcon pace={pool.pace} /> : null}
<span className="min-w-0 text-sm font-medium wrap-break-word text-foreground">
{label ?? pool.label}
</span>
</span>
{nextRefill && pool.columns.length > 1 ? (
<span className="text-xs font-medium text-foreground tabular-nums">
↻ +{nextRefill.restoresPercent}%
) : null}
<div
className={cn(
"col-start-2 row-start-1 flex flex-wrap items-center justify-end gap-x-3 gap-y-1",
inlineBar && "@2xl/usage-window:col-start-3",
label === null && "col-start-1 justify-start",
)}
>
<span className="flex items-baseline gap-1.5 whitespace-nowrap">
<span className="text-3xl font-semibold text-foreground tabular-nums">
{pool.remainingPercent}%
</span>
<span className="inline-flex items-center gap-1.5 text-sm text-muted-foreground">
<span>left</span>
{pool.pace ? <PaceIcon pace={pool.pace} /> : null}
</span>
</span>
{nextRefill && pool.columns.length > 1 ? (
<span className="text-xs font-medium whitespace-nowrap text-muted-foreground tabular-nums">
↻ +{nextRefill.restoresPercent}%
</span>
) : null}
</div>
<div
className={cn(
"col-span-full min-w-0",
inlineBar &&
"@2xl/usage-window:col-span-1 @2xl/usage-window:col-start-2 @2xl/usage-window:row-start-1",
)}
>
<PoolBar pool={pool} color={color} now={now} />
</div>
{description ? (
<p className="col-span-full text-xs text-muted-foreground">{description}</p>
) : null}
</div>
<PoolBar pool={pool} color={color} now={now} />
{description ? (
<p className="text-xs text-muted-foreground md:col-span-2">{description}</p>
) : null}
</div>
);
}
Expand Down
Loading