Skip to content

Commit a3a6adc

Browse files
committed
refactor(web): share usage card shell
1 parent 7cab3d3 commit a3a6adc

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

‎apps/web/src/components/usage/UsageLimitsPooled.tsx‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,27 @@ function PoolBar({
522522
);
523523
}
524524

525+
function UsageCard({
526+
variant,
527+
children,
528+
}: {
529+
readonly variant: "window" | "credits";
530+
readonly children: ReactNode;
531+
}) {
532+
return (
533+
<div
534+
className={cn(
535+
"rounded-lg border border-border/60 p-4",
536+
variant === "window"
537+
? "grid items-center gap-x-6 gap-y-3 md:grid-cols-[11rem_minmax(0,1fr)]"
538+
: "flex flex-wrap items-center justify-between gap-x-6 gap-y-2",
539+
)}
540+
>
541+
{children}
542+
</div>
543+
);
544+
}
545+
525546
function PoolWindowCard({
526547
pool,
527548
color,
@@ -537,7 +558,7 @@ function PoolWindowCard({
537558
}) {
538559
const nextRefill = pool.resets.find((reset) => reset.restoresPercent > 0);
539560
return (
540-
<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)]">
561+
<UsageCard variant="window">
541562
<div className="flex flex-col gap-1">
542563
<span className="text-sm font-medium text-foreground">{label ?? pool.label}</span>
543564
<span className="flex items-baseline gap-2">
@@ -559,7 +580,7 @@ function PoolWindowCard({
559580
{description ? (
560581
<p className="text-xs text-muted-foreground md:col-span-2">{description}</p>
561582
) : null}
562-
</div>
583+
</UsageCard>
563584
);
564585
}
565586

@@ -595,10 +616,7 @@ function PoolSection({ pool, now }: { readonly pool: LimitPool; readonly now: nu
595616
{pool.driver === "codex"
596617
? pool.accounts.map((account) =>
597618
account.limits.credits ? (
598-
<div
599-
key={account.key}
600-
className="flex flex-wrap items-center justify-between gap-x-6 gap-y-2 rounded-lg border border-border/60 p-4"
601-
>
619+
<UsageCard key={account.key} variant="credits">
602620
<div className="min-w-0 space-y-1">
603621
<h3 className="flex items-center gap-2 text-sm font-medium text-foreground">
604622
ChatGPT credits
@@ -613,7 +631,7 @@ function PoolSection({ pool, now }: { readonly pool: LimitPool; readonly now: nu
613631
<span className="text-lg font-medium text-foreground tabular-nums">
614632
{creditBalanceLabel(account.limits.credits)}
615633
</span>
616-
</div>
634+
</UsageCard>
617635
) : null,
618636
)
619637
: null}

0 commit comments

Comments
 (0)