mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 08:12:52 +00:00
Bucket A of the v1.4.3 polish pass.
Tile-strip width drifted past the chart-strip width by 16px on >=md
because the strip used `-mx-2 px-2` to bleed two pixels past the
parent for a snap-scroll feel. The bleed is real on mobile — the
horizontal-scroll affordance only reads as a scroll if the first/last
tiles touch the viewport edge — but on tablet/desktop where the row
fits without scrolling it just made the tile group visibly wider than
the charts below. Now `md:mx-0 md:px-0` drops the bleed once charts
fit inline, so the two strips share the same content box.
Tile heights varied because the blood-pressure tile rendered as two
stacked TrendCards (sys + dia) inside one tile slot while every
other tile was a single TrendCard. The cleaner fix is one TrendCard
that displays the paired value as `117/79` — TrendCard now accepts an
optional `secondary: { latest, avg7, avg30 }` and the dashboard pushes
ONE BP entry instead of a Fragment of two. Tile count drops from 6
to 5, the strip stops wrapping awkwardly, and the BP card carries
the systolic sparkline + traffic-light tooltip while the diastolic
value rides along under the same heading. Each tile wrapper got
`flex` and the card itself `flex h-full flex-col`, so flex-stretch
inside the strip can do its job and the avg7/avg30 row pins to the
bottom.
Settings nav split: the section formerly titled "Übersicht" was
renamed to "Dashboard" (the term every user already knows from the
main nav), and the embedded Persönliche Zielwerte panel moved out
into its own top-level settings section under `/settings/thresholds`.
Two reasons: the panel is heavy (one card per metric) and was
visually buried behind the layout customizer, and "Übersicht" leaked
internal vocabulary — neither the route slug nor the surrounding nav
entries used it. Tests guarding slug order + section count updated
in lockstep.
Touched:
- messages/de.json, messages/en.json
- src/app/page.tsx (dashboard tile strip)
- src/app/settings/[section]/page.tsx (route wiring)
- src/components/charts/trend-card.tsx (secondary-metric prop)
- src/components/settings/section-slugs.ts
- src/components/settings/settings-shell.tsx (new entry + icon)
- src/components/settings/section-placeholder.tsx
- src/components/settings/dashboard-section.tsx (drop ThresholdsSection)
- src/components/settings/thresholds-settings-section.tsx (new)
- src/components/settings/__tests__/{sections,settings-shell}.test.tsx
Tests + typecheck green (669/669).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
79 lines
3.0 KiB
TypeScript
79 lines
3.0 KiB
TypeScript
import { notFound } from "next/navigation";
|
|
import type { JSX } from "react";
|
|
|
|
import { AccountSection } from "@/components/settings/account-section";
|
|
import { AboutSection } from "@/components/settings/about-section";
|
|
import { AdvancedSection } from "@/components/settings/advanced-section";
|
|
import { AiSection } from "@/components/settings/ai-section";
|
|
import { ApiSection } from "@/components/settings/api-section";
|
|
import { DashboardSection } from "@/components/settings/dashboard-section";
|
|
import { IntegrationsSection } from "@/components/settings/integrations-section";
|
|
import { NotificationsSection } from "@/components/settings/notifications-section";
|
|
import { SectionPlaceholder } from "@/components/settings/section-placeholder";
|
|
import { ThresholdsSettingsSection } from "@/components/settings/thresholds-settings-section";
|
|
import {
|
|
SETTINGS_SECTION_SLUGS,
|
|
isSettingsSectionSlug,
|
|
type SettingsSectionSlug,
|
|
} from "@/components/settings/section-slugs";
|
|
import { SettingsShell } from "@/components/settings/settings-shell";
|
|
|
|
/**
|
|
* Dynamic settings section route. Each of the eight `SETTINGS_SECTION_SLUGS`
|
|
* is pre-rendered at build via `generateStaticParams()` so the URLs are
|
|
* statically known to Next.js, while the `dynamicParams = false` flag below
|
|
* tells the router to 404 (instead of attempting on-demand rendering) for any
|
|
* slug not in the list — which is exactly what `notFound()` would do at
|
|
* request time, just earlier and without rendering.
|
|
*/
|
|
|
|
export const dynamicParams = false;
|
|
|
|
export function generateStaticParams() {
|
|
return SETTINGS_SECTION_SLUGS.map((section) => ({ section }));
|
|
}
|
|
|
|
const SECTION_COMPONENTS: Record<
|
|
SettingsSectionSlug,
|
|
() => JSX.Element | null
|
|
> = {
|
|
account: AccountSection,
|
|
about: AboutSection,
|
|
ai: AiSection,
|
|
integrations: IntegrationsSection,
|
|
notifications: NotificationsSection,
|
|
dashboard: DashboardSection,
|
|
thresholds: ThresholdsSettingsSection,
|
|
api: ApiSection,
|
|
advanced: AdvancedSection,
|
|
};
|
|
|
|
interface PageProps {
|
|
// Next.js 16 made route `params` an async Promise. We `await` it before use.
|
|
params: Promise<{ section: string }>;
|
|
}
|
|
|
|
export default async function SettingsSectionPage({ params }: PageProps) {
|
|
const { section } = await params;
|
|
|
|
// Defence-in-depth — `dynamicParams = false` already 404s unknown slugs at
|
|
// routing time, but we re-check here so a hand-rolled override of the route
|
|
// config can never silently fall through to a typo'd slug.
|
|
if (!isSettingsSectionSlug(section)) {
|
|
notFound();
|
|
}
|
|
|
|
const SectionComponent = SECTION_COMPONENTS[section];
|
|
// Defensive fallback: in theory unreachable since `isSettingsSectionSlug`
|
|
// guards the slug, but a future slug added to `SETTINGS_SECTION_SLUGS`
|
|
// without a wired component would otherwise crash silently — placeholder
|
|
// surfaces the gap visually instead.
|
|
const body = SectionComponent ? (
|
|
<SectionComponent />
|
|
) : (
|
|
<SectionPlaceholder slug={section} />
|
|
);
|
|
|
|
return <SettingsShell active={section}>{body}</SettingsShell>;
|
|
}
|