From b832b5734e100b5c1e0acf23ae9ce29d9ee28209 Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Sat, 5 Sep 2026 08:06:16 +0200 Subject: [PATCH] Center each habit layout on its completion action --- src/App.test.tsx | 10 ++++++ src/components/HabitHistory.tsx | 4 ++- src/components/design-system/HabitChart.tsx | 26 ++++++++++++++++ src/components/design-system/primitives.tsx | 7 +++-- src/pages/Home.tsx | 18 ++++++----- styles/design-system.css | 34 +++++++++++++++++++++ 6 files changed, 87 insertions(+), 12 deletions(-) diff --git a/src/App.test.tsx b/src/App.test.tsx index ae151b2..56d8cc1 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -276,6 +276,16 @@ describe("homepage", () => { await f.json("/habits", "POST", { name: "Sunday walk", method: "manual", schedule: { type: "weekdays", days: [0] } }, 201); await render("/"); expect(container.querySelector(".ds-welcome-progress")?.textContent).toContain("0 / 3"); + const countGoal = container.querySelector(".ds-goal--count")!; + expect(countGoal.querySelector('.ds-goal-count input[aria-label="Total Water"]')).not.toBeNull(); + expect(countGoal.querySelector(".ds-goal-unit")?.textContent).toBe("glasses"); + expect(countGoal.textContent).not.toContain("Count target"); + const checkIn = container.querySelector('.ds-goal--manual input[type="checkbox"]')!; + expect(container.querySelector('.ds-goal--manual h3 label')?.getAttribute("for")).toBe(checkIn.id); + expect(checkIn.getAttribute("aria-label")).toBe("Reading done"); + expect(container.querySelector('.ds-goal--tasks details')).toBeNull(); + expect(container.querySelectorAll('.ds-goal--tasks .ds-routine-items > li')).toHaveLength(1); + await act(async () => buttonNamed("Increase Water").click()); expect(container.querySelector(".ds-welcome-progress")?.textContent).toContain("1 / 3"); expect(container.querySelector(`#history-${water.id} .ds-date-inspector`)).toBeNull(); diff --git a/src/components/HabitHistory.tsx b/src/components/HabitHistory.tsx index 769b833..97acc0d 100644 --- a/src/components/HabitHistory.tsx +++ b/src/components/HabitHistory.tsx @@ -141,7 +141,7 @@ export function HabitHistory({ /> {editingDay && setEditingDay(false)} busy={savingDay}>
-
{id => { if (event.target.value) setSelectedDate(event.target.value); }} />}

Update the progress recorded for this day.

+
{id => { if (event.target.value) setSelectedDate(event.target.value); }} />}
{ setAttempt(value => value + 1); onHistorySaved?.(); }} />
} @@ -151,6 +151,8 @@ export function HabitHistory({ return ( +
+
+ {trackingMethod === "manual" && children} + + {trackingMethod === "manual" ? : name} + +
+ {headingActions} +
+ {(!due || schedule !== "Every day") &&

{due ? schedule : `Not scheduled today · ${schedule}`}

} + {editor} + {trackingMethod === "count" &&
{children}{unit}
} + {trackingMethod === "tasks" &&
+ {due && target > 0 &&

{value} / {target} completed

} + {tasks} +
} + {calendar} + + ); + return (
diff --git a/src/components/design-system/primitives.tsx b/src/components/design-system/primitives.tsx index f026eaf..d39b124 100644 --- a/src/components/design-system/primitives.tsx +++ b/src/components/design-system/primitives.tsx @@ -56,19 +56,20 @@ export function SectionHeading({ export function Checkbox({ label, description, + hideLabel = false, className = "", ...props -}: Omit, "type"> & { label: string; description?: string }) { +}: Omit, "type"> & { label: string; description?: string; hideLabel?: boolean }) { const descriptionId = useId(); return (