TypeScript
fix(web): prevent overlapping usage breakdown columns (#14318)
Paul van der lei805ff51e58b7
diff --git a/apps/web/src/components/usage/UsagePage.tsx b/apps/web/src/components/usage/UsagePage.tsxindex e7db92cc370..e0ab70d4511 100644--- a/apps/web/src/components/usage/UsagePage.tsx+++ b/apps/web/src/components/usage/UsagePage.tsx@@ -691,7 +691,6 @@ function UsageOverview({.slice(cursorInsertAt).map((provider) => ({ kind: "usage" as const, provider })),];- const timeValueColumnWidth = `${60 / (activeProviders.length + 2)}%`;return (<div aria-busy={loadingPartial} className="flex flex-col gap-6">@@ -999,80 +998,82 @@ function UsageOverview({</tbody></table>) : (- <table className="w-full table-fixed text-sm">- <colgroup>- <col className="w-2/5" />- {activeProviders.map((provider) => (- <col key={provider} style={{ width: timeValueColumnWidth }} />- ))}- <col style={{ width: timeValueColumnWidth }} />- <col style={{ width: timeValueColumnWidth }} />- </colgroup>- <thead>- <tr className="border-b border-border text-left text-xs text-muted-foreground">- <th className="py-2 font-normal">{shownHourly ? "Hour" : "Day"}</th>- {activeProviders.map((provider) => (- <th key={provider} className="py-2 text-right font-normal">- {PROVIDER_PRESENTATION[provider].label}- </th>- ))}- <th className="py-2 text-right font-normal">Total</th>- <th className="py-2 text-right font-normal">Tokens</th>- </tr>- </thead>- <tbody>- {breakdownPeriods.length === 0 ? (- <tr>- <td- colSpan={activeProviders.length + 3}- className="py-6 text-center text-muted-foreground"- >- No activity in this window.- </td>+ <div+ className="overflow-x-auto outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"+ role="region"+ aria-label="Usage breakdown by time"+ tabIndex={0}+ >+ <table className="w-full text-sm whitespace-nowrap">+ <colgroup>+ <col className="w-2/5" />+ </colgroup>+ <thead>+ <tr className="border-b border-border text-left text-xs text-muted-foreground">+ <th className="py-2 font-normal">{shownHourly ? "Hour" : "Day"}</th>+ {activeProviders.map((provider) => (+ <th key={provider} className="py-2 pl-4 text-right font-normal">+ {PROVIDER_PRESENTATION[provider].label}+ </th>+ ))}+ <th className="py-2 pl-4 text-right font-normal">Total</th>+ <th className="py-2 pl-4 text-right font-normal">Tokens</th></tr>- ) : (- breakdownPeriods.map((period) => (- <tr- key={"hourStart" in period ? period.hourStart : period.day}- className="border-b border-border/50 transition-colors hover:bg-muted/50"- >- <td className="py-2 text-foreground">- {"hourStart" in period- ? formatHourShort(period.hourStart, shownWindow.timeZone, hour12)- : formatDayShort(period.day)}+ </thead>+ <tbody>+ {breakdownPeriods.length === 0 ? (+ <tr>+ <td+ colSpan={activeProviders.length + 3}+ className="py-6 text-center text-muted-foreground"+ >+ No activity in this window.</td>- {activeProviders.map((provider) => (+ </tr>+ ) : (+ breakdownPeriods.map((period) => (+ <tr+ key={"hourStart" in period ? period.hourStart : period.day}+ className="border-b border-border/50 transition-colors hover:bg-muted/50"+ >+ <td className="py-2 text-foreground">+ {"hourStart" in period+ ? formatHourShort(period.hourStart, shownWindow.timeZone, hour12)+ : formatDayShort(period.day)}+ </td>+ {activeProviders.map((provider) => (+ <td+ key={provider}+ className={cn(+ "py-2 pl-4 text-right text-muted-foreground tabular-nums",+ figureClass(loadingProviders.has(provider)),+ )}+ >+ {formatUsd(period.byProvider.get(provider)?.costUsd ?? 0)}+ </td>+ ))}<td- key={provider}className={cn(- "py-2 text-right text-muted-foreground tabular-nums",- figureClass(loadingProviders.has(provider)),+ "py-2 pl-4 text-right text-foreground tabular-nums",+ figureClass(loadingPartial),)}>- {formatUsd(period.byProvider.get(provider)?.costUsd ?? 0)}+ {formatUsd(period.costUsd)}</td>- ))}- <td- className={cn(- "py-2 text-right text-foreground tabular-nums",- figureClass(loadingPartial),- )}- >- {formatUsd(period.costUsd)}- </td>- <td- className={cn(- "py-2 text-right text-muted-foreground tabular-nums",- figureClass(loadingPartial),- )}- >- {formatTokens(period.totalTokens)}- </td>- </tr>- ))- )}- </tbody>- </table>+ <td+ className={cn(+ "py-2 pl-4 text-right text-muted-foreground tabular-nums",+ figureClass(loadingPartial),+ )}+ >+ {formatTokens(period.totalTokens)}+ </td>+ </tr>+ ))+ )}+ </tbody>+ </table>+ </div>)}</section></div>