From 6c9004b055a94c87eb32a27da85ef6ec11b4b79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Tue, 16 Jun 2026 01:44:44 +0200 Subject: [PATCH] refactor(settings): route section headers through the shared primitive mood, medications, Vorsorge, the health-record export panel and the export section hand-rolled their card headers; route them through the shared settings card-header primitive so every settings card header is structurally identical. --- .../vorsorge-section.tsx | 40 +++++++++---------- src/components/settings/export-section.tsx | 26 ++++++------ .../settings/health-record-export-panel.tsx | 23 ++++------- .../settings/medications-section.tsx | 25 +++++------- src/components/settings/mood-section.tsx | 28 +++++-------- 5 files changed, 60 insertions(+), 82 deletions(-) diff --git a/src/components/measurement-reminders/vorsorge-section.tsx b/src/components/measurement-reminders/vorsorge-section.tsx index 98b927df9..945ef0fb0 100644 --- a/src/components/measurement-reminders/vorsorge-section.tsx +++ b/src/components/measurement-reminders/vorsorge-section.tsx @@ -13,9 +13,10 @@ * relative to "now" but never recomputes the cadence. */ import { useState } from "react"; -import { CheckCircle2, Plus } from "lucide-react"; +import { CalendarClock, CheckCircle2, Plus } from "lucide-react"; import { useTranslations } from "@/lib/i18n/context"; +import { SettingsCardHeader } from "@/components/settings/_card-header"; import { DeleteButton } from "@/components/data-list"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; @@ -120,28 +121,23 @@ export function VorsorgeSection({ enabled = true }: { enabled?: boolean }) { aria-labelledby="vorsorge-section-title" className="space-y-4" > -
-
-

setShowForm((v) => !v)} > - {t("measurementReminders.sectionTitle")} -

-

- {t("measurementReminders.sectionDescription")} -

-
- -
+ + {t("measurementReminders.addButton")} + + } + /> {showForm && ( diff --git a/src/components/settings/export-section.tsx b/src/components/settings/export-section.tsx index ea99c154e..07b0463b0 100644 --- a/src/components/settings/export-section.tsx +++ b/src/components/settings/export-section.tsx @@ -32,12 +32,14 @@ import { Loader2, Pill, Waves, + type LucideIcon, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { DateInput } from "@/components/ui/date-input"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; +import { SettingsCardHeader } from "@/components/settings/_card-header"; import { ImportPanel } from "@/components/settings/import-panel"; import { queryKeys } from "@/lib/query-keys"; import { useTranslations } from "@/lib/i18n/context"; @@ -120,7 +122,7 @@ export function ExportSection() { interface ExportCardShellProps { testId: string; - icon: React.ComponentType<{ className?: string }>; + icon: LucideIcon; title: string; description: string; format: ExportFormat; @@ -146,16 +148,16 @@ function ExportCardShell({ data-testid={testId} className={`bg-card border-border flex h-full flex-col rounded-xl border p-4 sm:p-6${outerClassName ? ` ${outerClassName}` : ""}`} > -
-
- -

{title}

-
- - {format} - -
-

{description}

+ + {format} + + } + /> {children &&
{children}
}
{footer}
@@ -220,7 +222,7 @@ function buildQueryString(base: Record): string { interface CsvCardProps { testId: string; actionTestId: string; - icon: React.ComponentType<{ className?: string }>; + icon: LucideIcon; titleKey: string; descriptionKey: string; endpoint: string; diff --git a/src/components/settings/health-record-export-panel.tsx b/src/components/settings/health-record-export-panel.tsx index 61e96d18f..ec21299e3 100644 --- a/src/components/settings/health-record-export-panel.tsx +++ b/src/components/settings/health-record-export-panel.tsx @@ -24,6 +24,7 @@ import { useId, useState } from "react"; import { ChevronDown, Download, FileText, Loader2 } from "lucide-react"; +import { SettingsCardHeader } from "@/components/settings/_card-header"; import { Button } from "@/components/ui/button"; import { Label } from "@/components/ui/label"; import { Input } from "@/components/ui/input"; @@ -202,21 +203,13 @@ export function HealthRecordExportPanel() { "relative isolate overflow-hidden rounded-xl p-4 sm:p-5", )} > -
-
-

- {t("settings.healthRecord.description")} -

+
{/* Format + range share a row on desktop so the panel opens diff --git a/src/components/settings/medications-section.tsx b/src/components/settings/medications-section.tsx index 966c00174..61dce559d 100644 --- a/src/components/settings/medications-section.tsx +++ b/src/components/settings/medications-section.tsx @@ -8,6 +8,7 @@ import { type ReorderMedication, } from "@/components/medications/medication-order-editor"; import { MedicationViewToggle } from "@/components/medications/medication-view-toggle"; +import { SettingsCardHeader } from "@/components/settings/_card-header"; import { InjectionSitesCard } from "@/components/settings/injection-sites-card"; import { useAuth } from "@/hooks/use-auth"; import { apiGet } from "@/lib/api/api-fetch"; @@ -90,12 +91,10 @@ export function MedicationsSection() { id="medications-view" className="bg-card border-border scroll-mt-28 space-y-4 rounded-xl border p-4 sm:p-6" > -
- -

- {t("medications.viewToggleLabel")} -

-
+

{t("medications.viewToggleHint")} @@ -113,15 +112,11 @@ export function MedicationsSection() { id="medications-order" className="bg-card border-border scroll-mt-28 space-y-4 rounded-xl border p-4 sm:p-6" > -

- -

- {t("medications.reorderTitle")} -

-
-

- {t("medications.reorderDescription")} -

+ {isLoading || isLayoutLoading ? (
diff --git a/src/components/settings/mood-section.tsx b/src/components/settings/mood-section.tsx index d8a82248e..f4a251e96 100644 --- a/src/components/settings/mood-section.tsx +++ b/src/components/settings/mood-section.tsx @@ -2,6 +2,7 @@ import { Archive, Folders, Loader2, Tags } from "lucide-react"; +import { SettingsCardHeader } from "@/components/settings/_card-header"; import { ArchivedTagsCard } from "@/components/mood/manage/archived-tags-card"; import { TagGroupsCard } from "@/components/mood/manage/tag-groups-card"; import { TagManagerCard } from "@/components/mood/manage/tag-manager-card"; @@ -58,12 +59,10 @@ export function MoodSection() { id="mood-groups" className="bg-card border-border scroll-mt-28 space-y-4 rounded-xl border p-4 sm:p-6" > -
- -

- {t("mood.manage.groupsTitle")} -

-
+ {isLoading || !catalog ? loading : }
@@ -72,12 +71,7 @@ export function MoodSection() { id="mood-tags" className="bg-card border-border scroll-mt-28 space-y-4 rounded-xl border p-4 sm:p-6" > -
- -

- {t("mood.manage.tagsTitle")} -

-
+ {isLoading || !catalog ? loading : }
@@ -86,12 +80,10 @@ export function MoodSection() { id="mood-archived" className="bg-card border-border scroll-mt-28 space-y-4 rounded-xl border p-4 sm:p-6" > -
- -

- {t("mood.manage.archivedTitle")} -

-
+ {isLoading || !catalog ? ( loading ) : (