/** * The window's four headline numbers, each with the way into the rows behind it. * * Neutral chrome throughout: no coloured accents, no per-tile tone. Emphasis is * typographic, so the eye ranks the figures rather than the panels, and a tile * never implies a state it is not reporting. * * The Activity links carry the bounds the **overview response** returned, not * bounds computed here — a client-computed window would send the reader to a * slightly different span than the one they were just reading. */ import * as stylex from "@stylexjs/stylex"; import { Link } from "@tanstack/react-router"; import { formatMicros } from "@/lib/format"; import type { OverviewTotals } from "@/lib/types"; import { styles as shared } from "@/ui/styles"; import { colors } from "@/ui/tokens.stylex"; const numberFormat = new Intl.NumberFormat(); const styles = stylex.create({ /** Two columns on a phone, the whole set of four in one row from `md`. */ grid: { display: "grid", gap: "0.75rem", gridTemplateColumns: { default: "repeat(2, minmax(0, 1fr))", "@media (min-width: 768px)": "repeat(4, minmax(0, 1fr))", }, }, tile: { display: "flex", flexDirection: "column", gap: "0.125rem", borderRadius: "0.25rem", borderWidth: 1, borderStyle: "solid", borderColor: colors.border, backgroundColor: colors.surfaceRaised, paddingInline: "1rem", paddingBlock: "0.75rem", }, label: { fontSize: "0.875rem", lineHeight: "1.25rem", color: colors.textMuted, }, valueRow: { display: "flex", alignItems: "baseline", gap: "0.5rem", flexWrap: "wrap", }, value: { fontSize: "1.875rem", lineHeight: "2.25rem", fontWeight: 600, }, detail: { fontSize: "0.875rem", lineHeight: "1.25rem", color: colors.textSecondary, }, footer: { marginTop: "0.25rem", fontSize: "0.75rem", lineHeight: "1rem", }, link: { color: colors.primaryOnSurface, textDecorationLine: "none", }, }); function percentOf(part: number, total: number): string | null { if (total === 0) return null; return `${((part / total) * 100).toFixed(1)}%`; } function Tile({ label, value, detail, footer, }: { label: string; value: string; detail?: string | null; footer?: React.ReactNode; }) { return (
{label}
{value} {detail != null && {detail}}
{footer !== undefined &&
{footer}
}
); } /** The window's totals with the bounds they were measured over. */ export interface StatTilesData extends OverviewTotals { since: number; until: number; } export default function StatTiles({ stats }: { stats: StatTilesData }) { const window = { mode: "history" as const, since: stats.since, until: stats.until, domain: undefined, client: undefined, }; return (
Open in Activity } /> Open blocked queries } /> Manage clients } />
); }