mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
fix(insights): keep a stat value and its unit on one line
With the day panel docked beside the blood-pressure page (1280 px and up), each half of the stat card is a narrow column, and its four cells still went side by side because the step followed the window's width. Every cell came out narrower than "112 mmHg": the systolic values broke onto two lines, the two-digit diastolic ones next to them did not. The stat strip now joins a value to its unit with a no-break space, and each series is a container whose cells go four-up only when the series itself has the room: from 28rem for a half-card column, from 36rem for a full-width strip (where the 640 px window step put it, so the longest unit written, mL/(kg·min), keeps a cell it fits in). The loading shell follows the same steps. Every page with a stat strip (pulse, weight, the HealthKit, lab and custom-metric pages) shares the component. A component test pins the no-break pair and the container steps; the day-view spec measures every blood-pressure value beside the docked day at 1280 px and fails on the old markup.
This commit is contained in:
1 parent
9cc77c79fc
commit
59a6ee9d05
4 files changed
+178
-13
No files matched your search
@@ -332,6 +332,40 @@ test.describe("the day view", () => {
|
||||
await expect(page.locator('[data-slot="day-strip"]')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("beside the docked day, every blood-pressure value keeps its unit on its line", async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
test.skip(
|
||||
testInfo.project.name !== "chromium-desktop",
|
||||
"docked from 1280 px",
|
||||
);
|
||||
// The narrowest docked width: each half of the stat card is narrowest
|
||||
// here. Four cells a row left "1xx mmHg" no room, so the systolic values
|
||||
// broke onto two lines while the two-digit diastolic ones fitted.
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await page.goto(`/insights/blood-pressure?day=${isoDaysAgo(3)}`);
|
||||
await expect(panel(page)).toHaveAttribute("data-shell", "docked");
|
||||
const values = page.locator(
|
||||
'[data-slot="metric-stat-series"] [data-slot="metric-stat"] > p:nth-child(2)',
|
||||
);
|
||||
await expect(values).toHaveCount(8);
|
||||
const cells = await values.evaluateAll((els) =>
|
||||
els.map((el) => {
|
||||
const lineHeight = parseFloat(getComputedStyle(el).lineHeight);
|
||||
return {
|
||||
text: el.textContent ?? "",
|
||||
lines: Math.round(el.getBoundingClientRect().height / lineHeight),
|
||||
overflow: el.scrollWidth - el.clientWidth,
|
||||
};
|
||||
}),
|
||||
);
|
||||
for (const cell of cells) {
|
||||
expect(cell.text, cell.text).toMatch(/mmHg$/);
|
||||
expect(cell.lines, cell.text).toBe(1);
|
||||
expect(cell.overflow, cell.text).toBeLessThanOrEqual(0);
|
||||
}
|
||||
});
|
||||
|
||||
test("the strip runs the full height; the search magnifier stays clear of it", async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
|
||||
Reference in new issue
Block a user