feat(cycle): redesign the log-day sheet — phase header, field info, wider dialog

Anchor the capture surface to the ring and lower its cognitive load:

- A hue-tinted phase-context strip (day-of-cycle + phase) at the top of the
  sheet, on the wellness-tile surface, honesty-gated the same way the phase-
  education card is — no phase claim until prediction is on, not raw-chart,
  and at least three cycles observed; otherwise a neutral day header.
- Inline field explainers (FieldInfo) on the clinical fields: BBT, cervical
  mucus, ovulation test, spotting, pregnancy/progesterone test, intercourse,
  protection — factual, descriptive-only, reachable by keyboard and screen
  reader.
- BBT is now the shadcn Input rather than a bare element, with a morning-
  timing hint, so it matches every other control.
- The symptothermal section (Temperature & ovulation) auto-expands for
  fertility goals and for an edited day that already holds a fertility sign,
  so a pre-filled value is never hidden behind a collapsed section.
- Desktop dialog widened to lg so the form breathes.

The payload builders and the form-hydration reconciliation are unchanged, so
the wire contract and their unit tests are untouched.
This commit is contained in:
Marc-André Bombeck committed 2026-06-16 21:32:58 +02:00
1 parent eb40f9b46f
commit f3388ceb70
4 files changed
+344 -25

No files matched your search

@@ -0,0 +1,36 @@
import { describe, it, expect } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
import { FieldInfo } from "../field-info";
import { I18nProvider } from "@/lib/i18n/context";
function render(node: React.ReactNode) {
return renderToStaticMarkup(
<I18nProvider initialLocale="en">{node}</I18nProvider>,
);
}
describe("<FieldInfo>", () => {
it("is a real focusable button carrying the accessible label", () => {
const html = render(
<FieldInfo
label="What is basal body temperature?"
detail="Your resting temperature."
/>,
);
// A real <button type="button"> — keyboard- and SR-reachable, not hover-only.
expect(html).toContain('type="button"');
expect(html).toContain('aria-label="What is basal body temperature?"');
// The e2e hook the cycle sheet asserts on.
expect(html).toContain('data-slot="cycle-field-info"');
});
it("starts closed so the explainer opens on tap/focus, not hover-only", () => {
// Radix renders the tooltip content lazily (portal, on open); the trigger
// therefore reports a closed state until interacted with.
const html = render(
<FieldInfo label="Cervical mucus" detail="Discharge changes across the cycle." />,
);
expect(html).toContain('data-state="closed"');
});
});
@@ -0,0 +1,73 @@
import { describe, it, expect } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
import { PhaseDayHeader } from "../log-day-sheet";
import { I18nProvider } from "@/lib/i18n/context";
function render(node: React.ReactNode) {
return renderToStaticMarkup(
<I18nProvider initialLocale="en">{node}</I18nProvider>,
);
}
const okGate = {
predictionEnabled: true,
rawChartMode: false,
cyclesObserved: 4,
};
describe("<PhaseDayHeader> (honesty gate)", () => {
it("shows the phase + day when the gate passes", () => {
const html = render(
<PhaseDayHeader phase="OVULATORY" dayOfCycle={14} {...okGate} />,
);
expect(html).toContain('data-slot="cycle-log-phase-header"');
expect(html).toContain('data-phase="OVULATORY"');
// "Day 14 · Ovulatory" — the phase word is only claimed under a passing gate.
expect(html).toContain("Day 14");
expect(html).toContain("Ovulatory");
});
it("makes no phase claim when prediction is off (neutral day header)", () => {
const html = render(
<PhaseDayHeader
phase="OVULATORY"
dayOfCycle={14}
predictionEnabled={false}
rawChartMode={false}
cyclesObserved={4}
/>,
);
expect(html).toContain('data-phase="none"');
// Still anchors to the day count, but never names the phase.
expect(html).toContain("Day 14");
expect(html).not.toContain("Ovulatory");
});
it("makes no phase claim with too few observed cycles", () => {
const html = render(
<PhaseDayHeader
phase="LUTEAL"
dayOfCycle={20}
predictionEnabled
rawChartMode={false}
cyclesObserved={1}
/>,
);
expect(html).toContain('data-phase="none"');
expect(html).not.toContain("Luteal");
});
it("renders nothing when neither a trustworthy phase nor a day count exists", () => {
const html = render(
<PhaseDayHeader
phase={null}
dayOfCycle={null}
predictionEnabled={false}
rawChartMode={false}
cyclesObserved={0}
/>,
);
expect(html).toBe("");
});
});