refactor(ui): give Settings and Admin one card rhythm and one page header

The two consoles used the same primitives and still read as two systems,
because everything without a primitive had drifted: the header-to-body
step existed in three competing techniques at once (`mt-4` on the first
body child, `space-y-4` on the card, `mb-4` on the header), the body
started either at the card edge or 28 px in, and both shells hand-rolled
the page title instead of calling `PageHeader`.

Move the decisions into the primitives so a call site cannot re-open them:

- `SettingsCard` is gap-based like `Card` (`flex flex-col gap-4`). The
  header-to-body step is the container's, not a margin somebody remembers.
  A dense card still overrides the gap on the card itself.
- The body starts at the card edge. `pl-7` is gone — off the spacing scale,
  and it mis-aligned action rows against their own forms wherever two
  neighbouring cards disagreed about it.
- The card header's description slot loses its `space-y-1`. That was the
  licence call sites used to stack explainer paragraphs into a muted
  `text-xs` slot; the slot holds one sentence.
- New `SettingsCardActions`: one action row, trailing edge, last thing in
  the card. `align="start"` spells the one exception, a card whose only
  actions are links out.
- New `StatTile` replaces four hand-rolled label/value boxes in Admin.
- `SectionHeading` moves from `insights/` to `ui/`. It is the heading above
  a group of cards, which is what Settings needs; Settings had been using a
  card header with no card, which reads as a card that failed to paint.

Both shells now render their heading through `PageHeader`, which gained
`headingAs="div"` for the second copy each shell paints (mobile above the
nav strip, desktop inside the grid) so only one is a real `<h1>`. The
page explainer is muted everywhere: the primitive said foreground, the
standards and every hand-rolled copy said muted, so pages disagreed with
each other. Medications, Vorsorge, the labs / custom-metric / illness
detail pages and the clinician view drop their hand-rolled title blocks
too, including the mid-word truncation on the medications subtitle.

Tests pin the parts that can be checked exactly: the card's gap, the
description slot's missing rhythm, the action row's two alignments, the
`<h1>`-free shells, and a sweep asserting `pl-7` stays gone.
This commit is contained in:
Marc-André Bombeck committed 2026-08-07 19:05:15 +02:00
1 parent 00e8d05235
commit 5445bfc1f1
121 files changed
+832 -620

No files matched your search

@@ -18,6 +18,7 @@ import { Card, CardContent } from "@/components/ui/card";
import { QueryErrorCard } from "@/components/ui/query-error-card";
import { EmptyState } from "@/components/ui/empty-state";
import { ResponsiveSheet } from "@/components/ui/responsive-sheet";
import { PageHeader } from "@/components/ui/page-header";
import { Skeleton } from "@/components/ui/skeleton";
import { MetricStatStrip } from "@/components/insights/metric-stat-strip";
import { apiDelete, apiGet } from "@/lib/api/api-fetch";
@@ -171,14 +172,10 @@ export function CustomMetricDetail({
if (metricError || listError) {
return (
<div className="space-y-6">
<header className="space-y-1.5">
<h1 className="text-2xl font-bold tracking-tight">
{metric?.name ?? t("customMetrics.detail.title")}
</h1>
<p className="text-foreground text-sm leading-relaxed">
{description}
</p>
</header>
<PageHeader
title={metric?.name ?? t("customMetrics.detail.title")}
description={description}
/>
<QueryErrorCard
description={t("customMetrics.loadError")}
onRetry={() => {
@@ -192,70 +189,69 @@ export function CustomMetricDetail({
return (
<div className="space-y-6">
<div className="flex items-start justify-between gap-3">
<div className="min-w-0">
<h1 className="text-2xl font-bold tracking-tight">
{metric?.name ?? <Skeleton className="h-7 w-32" />}
</h1>
{metric?.unit ? (
<p className="text-muted-foreground text-xs sm:text-sm">
{metric.unit}
</p>
) : null}
</div>
<div className="flex shrink-0 items-center gap-2">
{/* Controls, left → right: Delete · Edit · Show-all-values · Add. */}
<DeleteButton
onConfirm={() => deleteMetric.mutate()}
title={t("customMetrics.deleteConfirmTitle")}
description={t("customMetrics.deleteConfirmDescription")}
confirmLabel={t("customMetrics.delete")}
triggerTitle={t("customMetrics.delete")}
className="min-h-11 min-w-11 sm:min-h-9 sm:min-w-9"
iconClassName="h-4 w-4"
/>
<Button
variant="ghost"
size="icon"
className="min-h-11 min-w-11 sm:min-h-9 sm:min-w-9"
onClick={() => setEditOpen(true)}
disabled={!metric}
aria-label={t("customMetrics.edit")}
title={t("customMetrics.edit")}
>
<Pencil className="h-4 w-4" />
</Button>
{entries.length > 0 ? (
<PageHeader
title={metric?.name ?? <Skeleton className="h-7 w-32" />}
description={description}
actions={
<>
{/* Controls, left → right: Delete · Edit · Show-all-values · Add. */}
<DeleteButton
onConfirm={() => deleteMetric.mutate()}
title={t("customMetrics.deleteConfirmTitle")}
description={t("customMetrics.deleteConfirmDescription")}
confirmLabel={t("customMetrics.delete")}
triggerTitle={t("customMetrics.delete")}
className="min-h-11 min-w-11 sm:min-h-9 sm:min-w-9"
iconClassName="h-4 w-4"
/>
<Button
asChild
variant="ghost"
size="icon"
data-slot="custom-metric-show-all-values"
className="min-h-11 min-w-11 sm:min-h-9 sm:min-w-9"
onClick={() => setEditOpen(true)}
disabled={!metric}
aria-label={t("customMetrics.edit")}
title={t("customMetrics.edit")}
>
<Link
href={`/custom-metrics/${customMetricId}/values`}
aria-label={t("customMetrics.showAllValues")}
title={t("customMetrics.showAllValues")}
>
<ListOrdered className="h-4 w-4" aria-hidden="true" />
</Link>
<Pencil className="h-4 w-4" />
</Button>
) : null}
<Button
onClick={() => setAddOpen(true)}
className="min-h-11 min-w-11 shrink-0 sm:min-h-9 sm:min-w-0"
aria-label={t("customMetrics.addValue")}
>
<Plus className="h-4 w-4" />
<span className="hidden sm:inline">
{t("customMetrics.addValue")}
</span>
</Button>
</div>
</div>
{entries.length > 0 ? (
<Button
asChild
variant="ghost"
size="icon"
data-slot="custom-metric-show-all-values"
className="min-h-11 min-w-11 sm:min-h-9 sm:min-w-9"
>
<Link
href={`/custom-metrics/${customMetricId}/values`}
aria-label={t("customMetrics.showAllValues")}
title={t("customMetrics.showAllValues")}
>
<ListOrdered className="h-4 w-4" aria-hidden="true" />
</Link>
</Button>
) : null}
<Button
onClick={() => setAddOpen(true)}
className="min-h-11 min-w-11 shrink-0 sm:min-h-9 sm:min-w-0"
aria-label={t("customMetrics.addValue")}
>
<Plus className="h-4 w-4" />
<span className="hidden sm:inline">
{t("customMetrics.addValue")}
</span>
</Button>
</>
}
/>
<p className="text-foreground text-sm leading-relaxed">{description}</p>
{/* The unit is meta about the metric, not its explainer, so it reads
below the header rather than competing for the one description line
every page header carries. */}
{metric?.unit ? (
<p className="text-muted-foreground text-sm">{metric.unit}</p>
) : null}
{isLoading ? (
<Card>