mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 14:40:52 +00:00
feat(insights): mood calendar and chart arrive together; add via the header plus
On /insights/mood the line chart used to paint first and the calendar, whose aggregate is the slower read, pushed it down when it landed (CLS 0.16 at 390 px on a cold load). The page now holds both on final-height skeletons until the chart's read has settled and the calendar's has landed, then shows them in the same frame. The calendar's height is written in container-query units, so its box is the right size from the first paint, in the skeleton and the painted grid alike. A server wrapper prefetches both reads in parallel (time-boxed, skipped under a record switch, off when SSR prefetch is off), so on a warm cache they are in the first HTML. The route and the prefetch share `moodInsightsWire`, so the seeded cell is the route's shape. The "Log a mood entry" and "Take a mental-wellbeing check-in" text links under the heading are gone. Logging is the header plus, which opens the mood form in place; the check-in keeps its own place in the navigation. The plus is one shared component, `SubPageAddButton`, now also behind the measurement pages' capture link and the workouts page, which drew its own. An audit of every Insights page found no other text add-button of this kind; the remaining buttons are empty-state calls to action. A sweep keeps it that way. `e2e/v142-qol.spec.ts` covers all three surfaces of this change set.
This commit is contained in:
1 parent
1a5eab9f7c
commit
41ed8eb6a3
21 files changed
+1223
-339
No files matched your search
@@ -979,3 +979,30 @@ export async function fetchMoodAggregates(
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The `/api/mood/insights` wire for one stability window.
|
||||
*
|
||||
* The per-window map is the cache's, not the wire's: the chosen window is
|
||||
* served as `stability`. An aggregate cached before the map existed has only
|
||||
* the year, so a shorter window reads as not yet computed (`null`) until the
|
||||
* next rebuild rather than as the year's score under a new name.
|
||||
*
|
||||
* Shared by the route and by the `/insights/mood` server prefetch, so the
|
||||
* cell the prefetch seeds is byte-for-byte what the client's own fetch would
|
||||
* have put there — the same key with a different shape is silent cache poison.
|
||||
*/
|
||||
export function moodInsightsWire(
|
||||
result: MoodAggregates,
|
||||
stabilityWindowDays: MoodStabilityWindow,
|
||||
) {
|
||||
const { stabilityByWindow, ...wire } = result;
|
||||
return {
|
||||
...wire,
|
||||
stability:
|
||||
stabilityWindowDays === 365
|
||||
? result.stability
|
||||
: (stabilityByWindow?.[stabilityWindowDays] ?? null),
|
||||
stabilityWindowDays,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user