mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
Align layout settings cards and the insights arrange editor
The insights arrange list becomes a Settings card with its own header and a Save that waits for a change; the self-link back to the page it sits on and the focus grab on load are gone. The medications view card takes the header shape the labs and documents cards use, the order card shares their title and loads with row placeholders, and the documents view card uses their icon.
This commit is contained in:
1 parent
991764b0c8
commit
2dda933d77
6 files changed
+188
-89
No files matched your search
@@ -97,7 +97,8 @@ describe("<MedicationsSection> — SSR smoke", () => {
|
||||
|
||||
it("renders the German copy end-to-end", () => {
|
||||
const html = render("de");
|
||||
expect(html).toContain("Reihenfolge anpassen");
|
||||
// The order card shares its title with the Labs order card.
|
||||
expect(html).toContain(">Reihenfolge<");
|
||||
expect(html).toContain(
|
||||
"Wähle, ob deine Medikamente als Karten oder als Tabelle angezeigt werden.",
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* shape): the card/list view and the month arrangement. Both persist per user
|
||||
* through `/api/documents/inbound/layout`.
|
||||
*/
|
||||
import { Eye, Rows3, WrapText } from "lucide-react";
|
||||
import { LayoutGrid, Rows3, WrapText } from "lucide-react";
|
||||
|
||||
import { SettingsCardHeader } from "@/components/settings/_card-header";
|
||||
import { SettingsCard } from "@/components/settings/settings-card";
|
||||
@@ -26,7 +26,7 @@ export function DocumentsSection() {
|
||||
<div className="space-y-6" data-slot="documents-layout-settings">
|
||||
<SettingsCard id="documents-view" className="scroll-mt-28">
|
||||
<SettingsCardHeader
|
||||
icon={Eye}
|
||||
icon={LayoutGrid}
|
||||
title={t("moduleList.viewHeading")}
|
||||
description={t("documents.layout.viewDescription")}
|
||||
status={<ModuleViewToggle view={layout.view} onChange={setView} />}
|
||||
|
||||
@@ -9,8 +9,8 @@ import { useAuth } from "@/hooks/use-auth";
|
||||
import { useAiCapability } from "@/hooks/use-ai-capability";
|
||||
import { useInsightsLayoutQuery } from "@/hooks/use-insights-layout";
|
||||
import { InsightsEditMode } from "@/components/insights/insights-edit-mode";
|
||||
import { SectionHeading } from "@/components/ui/section-heading";
|
||||
import { SettingsCard } from "@/components/settings/settings-card";
|
||||
import { SettingsCardHeader } from "@/components/settings/_card-header";
|
||||
import {
|
||||
INSIGHTS_SECTION_IDS,
|
||||
type InsightsSectionId,
|
||||
@@ -59,29 +59,28 @@ export function InsightsOverviewArrangeSection({ id }: { id?: string }) {
|
||||
id={id}
|
||||
data-slot="insights-overview-arrange-section"
|
||||
aria-labelledby="insights-overview-arrange-title"
|
||||
className="space-y-3"
|
||||
className="scroll-mt-28"
|
||||
>
|
||||
<SectionHeading
|
||||
icon={LayoutGrid}
|
||||
id="insights-overview-arrange-title"
|
||||
title={t("insights.settings.overviewTitle")}
|
||||
subtitle={t("insights.settings.overviewDescription")}
|
||||
/>
|
||||
|
||||
{/* Gate the editor mount until the layout GET settles. The editor seeds
|
||||
its draft once from `layout` on mount, which is the canonical default
|
||||
while in flight; mounting it early would let a "Fertig" save flush
|
||||
defaults over the user's real saved layout (the same QA-L1 gate the
|
||||
mother page applies to its "Anpassen" toggle). */}
|
||||
while in flight; mounting it early would let a Save flush defaults
|
||||
over the user's real saved layout (the same QA-L1 gate the mother
|
||||
page applies to its "Anpassen" toggle). The loading card paints the
|
||||
same header the loaded card carries (design standards §13), so the
|
||||
page does not reflow under the cursor when the list arrives. */}
|
||||
{isLoading ? (
|
||||
<SettingsCard
|
||||
className="text-muted-foreground flex items-center gap-2 text-sm"
|
||||
data-slot="insights-overview-arrange-loading"
|
||||
>
|
||||
<Loader2 className="h-4 w-4 animate-spin motion-reduce:animate-none" />
|
||||
<SettingsCard data-slot="insights-overview-arrange-loading">
|
||||
<SettingsCardHeader
|
||||
icon={LayoutGrid}
|
||||
title={t("insights.settings.overviewTitle")}
|
||||
titleId="insights-overview-arrange-title"
|
||||
description={t("insights.settings.overviewDescription")}
|
||||
/>
|
||||
<Loader2 className="text-muted-foreground h-4 w-4 animate-spin motion-reduce:animate-none" />
|
||||
</SettingsCard>
|
||||
) : (
|
||||
<InsightsEditMode
|
||||
variant="settings"
|
||||
layout={layout}
|
||||
gatedOffSectionIds={gatedOffSectionIds}
|
||||
onClose={() => {}}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { LayoutGrid, Loader2, Pill } from "lucide-react";
|
||||
import { LayoutGrid, ListOrdered } from "lucide-react";
|
||||
|
||||
import {
|
||||
MedicationOrderEditor,
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from "@/components/medications/medication-order-editor";
|
||||
import { MedicationViewToggle } from "@/components/medications/medication-view-toggle";
|
||||
import { SettingsCard } from "@/components/settings/settings-card";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { SettingsCardHeader } from "@/components/settings/_card-header";
|
||||
import { InjectionSitesCard } from "@/components/settings/injection-sites-card";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
@@ -81,33 +82,39 @@ export function MedicationsSection() {
|
||||
{/* View preference — cards vs table. The shared header toggle
|
||||
writes optimistically, so there is no Save button here. */}
|
||||
<SettingsCard id="medications-view" className="scroll-mt-28">
|
||||
{/* Same shape as the Labs and Documents view cards: the hint is the
|
||||
header description, the toggle sits in the status slot. */}
|
||||
<SettingsCardHeader
|
||||
icon={LayoutGrid}
|
||||
title={t("medications.viewToggleLabel")}
|
||||
/>
|
||||
<div className="border-border bg-background/30 flex min-h-12 items-center justify-between gap-3 rounded-md border px-3 py-2">
|
||||
<p className="text-muted-foreground min-w-0 text-xs">
|
||||
{t("medications.viewToggleHint")}
|
||||
</p>
|
||||
{isLayoutLoading ? (
|
||||
<Loader2 className="text-muted-foreground h-4 w-4 animate-spin motion-reduce:animate-none" />
|
||||
) : (
|
||||
description={t("medications.viewToggleHint")}
|
||||
status={
|
||||
// Painted from the first frame, like the Labs and Documents
|
||||
// toggles: a spinner the width of one icon swapped for a
|
||||
// two-button toggle moved the cards below it.
|
||||
<MedicationViewToggle view={layout.view} onChange={setView} />
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</SettingsCard>
|
||||
|
||||
{/* Manual order — applies to both list views. */}
|
||||
<SettingsCard id="medications-order" className="scroll-mt-28">
|
||||
<SettingsCardHeader
|
||||
icon={Pill}
|
||||
title={t("medications.reorderTitle")}
|
||||
icon={ListOrdered}
|
||||
title={t("moduleList.reorder.heading")}
|
||||
description={t("medications.reorderDescription")}
|
||||
/>
|
||||
{isLoading || isLayoutLoading ? (
|
||||
<div className="text-muted-foreground flex items-center gap-2 text-sm">
|
||||
<Loader2 className="h-4 w-4 animate-spin motion-reduce:animate-none" />
|
||||
{t("common.loading")}
|
||||
// Row-shaped placeholders instead of a one-line spinner, so the
|
||||
// card below moves less when the list arrives.
|
||||
<div
|
||||
className="space-y-2"
|
||||
role="status"
|
||||
aria-label={t("common.loading")}
|
||||
>
|
||||
{Array.from({ length: 3 }, (_, i) => (
|
||||
<Skeleton key={i} className="h-14 w-full rounded-md" />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<MedicationOrderEditor medications={ordered} />
|
||||
|
||||
Reference in new issue
Block a user