Name the type on every mobile measurement row

On a phone the list showed an icon and a value only, so two readings in
the same unit (HRV and RMSSD, two weights) could not be told apart, and
only blood pressure carried a label. Each row now names its type above
the value. Score and rating tokens no longer print as units.
This commit is contained in:
Marc-André Bombeck committed 2026-10-08 16:34:53 +02:00
1 parent 75a0f00be9
commit 9fd43623dd
4 files changed
+31 -10

No files matched your search

@@ -131,4 +131,11 @@ describe("MeasurementList — Sys/Dia disambiguation badge (mobile list)", () =>
expect(countOccurrences(mobile, ">Sys<")).toBe(1);
expect(countOccurrences(mobile, ">Dia<")).toBe(1);
});
it("names the type on every mobile row, not only blood pressure", () => {
vi.mocked(useIsMobile).mockReturnValue(true);
expect(
countOccurrences(render("en"), 'data-slot="measurement-row-type"'),
).toBe(baseMeasurements.length);
});
});
@@ -56,4 +56,8 @@ describe("measurementUnitLabel", () => {
it("passes every other unit through", () => {
expect(measurementUnitLabel("WEIGHT", "kg", t)).toBe("kg");
});
it("drops the score and rating tokens", () => {
expect(measurementUnitLabel("RECOVERY_SCORE", "score", t)).toBe("");
expect(measurementUnitLabel("VISCERAL_FAT", "rating", t)).toBe("");
});
});
@@ -417,5 +417,11 @@ export function measurementUnitLabel(
t: (key: string) => string,
): string {
const key = MEASUREMENT_UNIT_LABEL_KEYS[type];
return key ? t(key) : unit;
if (key) return t(key);
// A score or a rating is a bare number; "72 score" reads as a stray
// English token next to the German label, not as a unit.
if (UNITLESS_TOKENS.has(unit)) return "";
return unit;
}
const UNITLESS_TOKENS: ReadonlySet<string> = new Set(["score", "rating"]);
@@ -1462,15 +1462,19 @@ export function MeasurementList({
token `text-xs` (12 px, the mobile legibility
baseline) instead of an arbitrary per-site
size, so the row tracks the type scale. */}
{(m.type === "BLOOD_PRESSURE_SYS" ||
m.type === "BLOOD_PRESSURE_DIA") && (
<Badge
variant="outline"
className="mr-1.5 h-5 px-1 text-xs"
>
{t(TYPE_LABEL_KEYS[m.type])}
</Badge>
)}
{/* The type names the row: without it two
readings in the same unit ("55 ms" HRV and
"63 ms" RMSSD) could not be told apart on a
phone, where the desktop table's type column
does not exist. */}
<p
className="truncate text-xs font-medium"
data-slot="measurement-row-type"
>
{TYPE_LABEL_KEYS[m.type]
? t(TYPE_LABEL_KEYS[m.type])
: m.type}
</p>
<span
className="font-semibold tabular-nums"
data-slot="measurement-row-value"