mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
fix(ui): announce failures, keep focus honest and stop the last layout shifts
Hidden states of the floating coach button now leave the tab order and accessibility tree, its focus ring carries an offset, its icon is dark on the gradient, an unread nudge is announced once via a live region, and it sits correctly above the fold on tablet widths and yields to the onboarding tour. Chart error cards announce themselves, share the exact height variables of the skeleton band, carry per-chart retry labels, and a failed chunk renders inside the regular card shell. The header icon cluster spaces its extended hit areas apart, the tab strip keeps horizontal paint room for focus rings, the streak row reserves its slot in every card state, the selection bar clears the bottom nav on landscape phones, and the version poller keeps an in-memory reload guard for browsers that block session storage. Mood notes render as plain paragraphs with a toggle that appears only when text is actually clamped, the remember control reveals on hover and hands focus to its confirmation, and the hypnogram names its source and paints only the lanes the night contains.
This commit is contained in:
1 parent
a2a995e429
commit
95f21bfa4d
29 files changed
+703
-137
No files matched your search
@@ -11,6 +11,7 @@ import {
|
||||
import {
|
||||
MedicationComplianceBars,
|
||||
MedicationComplianceError,
|
||||
MedicationComplianceSkeleton,
|
||||
} from "@/components/medications/card-parts/medication-compliance-bars";
|
||||
import { MedicationStatusPill } from "@/components/medications/card-parts/medication-status-pill";
|
||||
import { MedicationIntakeActions } from "@/components/medications/card-parts/medication-intake-actions";
|
||||
@@ -88,6 +89,25 @@ describe("medication card-parts — shared presentational components", () => {
|
||||
expect(html).not.toContain("lucide-flame");
|
||||
});
|
||||
|
||||
it("compliance bars reserve the streak row across loaded, zero-streak, skeleton, and error states", () => {
|
||||
// A streak arriving used to ADD a row, growing the card and shifting
|
||||
// the grid; the `min-h-4` slot is now always mounted in every state so
|
||||
// the card height is invariant to the streak.
|
||||
const withStreak = render(
|
||||
<MedicationComplianceBars rate7={90} rate30={88} streak={5} />,
|
||||
);
|
||||
const withoutStreak = render(
|
||||
<MedicationComplianceBars rate7={90} rate30={88} streak={0} />,
|
||||
);
|
||||
const skeleton = render(<MedicationComplianceSkeleton />);
|
||||
const error = render(
|
||||
<MedicationComplianceError onRetry={() => undefined} />,
|
||||
);
|
||||
for (const html of [withStreak, withoutStreak, skeleton, error]) {
|
||||
expect(html).toContain("min-h-4");
|
||||
}
|
||||
});
|
||||
|
||||
it("compliance bars render the percentage only — no dose count beside it", () => {
|
||||
// v1.15.9 — the operator does not want a count next to the percentage.
|
||||
// The auto-miss engine now makes the two windows' percentages genuinely
|
||||
|
||||
@@ -94,10 +94,13 @@ export function MedicationComplianceBars({
|
||||
<Progress value={rate30} className="h-2" aria-label={longLabel} />
|
||||
</div>
|
||||
|
||||
{/* Streak flame — only mounted when there's a streak so an empty
|
||||
row doesn't leave a residual gap below the bars. */}
|
||||
{streak > 0 && (
|
||||
<div className="flex items-center gap-4 text-xs">
|
||||
{/* Streak flame — the row is ALWAYS mounted at `min-h-4` so a
|
||||
streak arriving (or expiring) never changes the card height
|
||||
and the action row below stays on one baseline across a grid
|
||||
row. The flame itself still gates on `streak > 0`; the
|
||||
skeleton and error fallbacks reserve the same slot. */}
|
||||
<div className="flex min-h-4 items-center gap-4 text-xs">
|
||||
{streak > 0 && (
|
||||
<span className="text-warning flex items-center gap-1 font-medium">
|
||||
<Flame className="h-3.5 w-3.5" />
|
||||
{streak}{" "}
|
||||
@@ -105,8 +108,8 @@ export function MedicationComplianceBars({
|
||||
? t("medications.dayStreakOne")
|
||||
: t("medications.dayStreak")}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -121,9 +124,10 @@ export function MedicationComplianceBars({
|
||||
* footprint so the card body keeps a constant inventory and the action row
|
||||
* pins to the same baseline across the row.
|
||||
*
|
||||
* The streak-flame row height is intentionally NOT reserved — the flame is
|
||||
* gated on `streak > 0` on the loaded card too, so reserving it would make
|
||||
* every streak-less card taller than its own loaded self.
|
||||
* The streak-flame slot IS reserved (`min-h-4`, matching the loaded card's
|
||||
* always-mounted row) — the loaded card reserves it whether or not a streak
|
||||
* exists, so the skeleton must too or a resolving card would grow by one
|
||||
* row and shift the grid.
|
||||
*/
|
||||
export function MedicationComplianceSkeleton() {
|
||||
return (
|
||||
@@ -142,6 +146,7 @@ export function MedicationComplianceSkeleton() {
|
||||
</div>
|
||||
<div className="bg-muted h-2 rounded" />
|
||||
</div>
|
||||
<div className="min-h-4" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -184,6 +189,8 @@ export function MedicationComplianceError({
|
||||
</div>
|
||||
<div className="bg-muted/40 h-2 rounded" />
|
||||
</div>
|
||||
{/* Streak-slot parity with the loaded card + skeleton. */}
|
||||
<div className="min-h-4" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user