refactor(ui): one Segmented control instead of four

The timeline's Segmented, the document sources' SegmentedChoice, the
medication detail's SegmentedToggle and the icon-only ViewToggle were
four implementations of the same control in two looks, two at 36 px on
a phone. ui/segmented.tsx replaces all four, plus the hand-rolled range
rows above the lab and custom metric charts, the mood dimension window
and the inventory quantity mode: a muted track with the chosen segment
raised, radio semantics with roving focus by default, pressed-button
semantics for view switches and form sheets, icon-only segments, and
44 px per segment on a coarse pointer. A test holds the definition to
that one module.
This commit is contained in:
Marc-André Bombeck committed 2026-10-20 13:15:29 +02:00
1 parent c849619bee
commit ab3f21c58c
26 files changed
+428 -139

No files matched your search

@@ -3,13 +3,13 @@
import { LayoutGrid, List as ListIcon } from "lucide-react";
import { useTranslations } from "@/lib/i18n/context";
import { ViewToggle } from "@/components/ui/view-toggle";
import { Segmented } from "@/components/ui/segmented";
import type { ModuleListView } from "@/lib/module-list-prefs";
/**
* v1.18.6 — icon-only card/list view toggle shared by the
* Vorsorge / Illness / Labs settings pages. Thin wrapper over the shared
* `ViewToggle` primitive (mirrors the medication module's
* `Segmented` primitive, icon-only (mirrors the medication module's
* `MedicationViewToggle`, which is the same wrapper switching between a
* card grid and a compact list rather than cards-vs-table).
*/
@@ -22,12 +22,14 @@ export function ModuleViewToggle({ view, onChange }: ModuleViewToggleProps) {
const { t } = useTranslations();
return (
<ViewToggle
view={view}
<Segmented
mode="toggle"
iconOnly
value={view}
onChange={onChange}
groupLabel={t("moduleList.viewToggleLabel")}
dataSlotPrefix="module-view"
segments={[
label={t("moduleList.viewToggleLabel")}
optionSlot={(value) => `module-view-${value}`}
options={[
{
value: "cards",
label: t("moduleList.viewCards"),