From 02307aa2ee9b2761ad753c973ea2f4f9d7f07772 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Wed, 7 Oct 2026 23:28:31 -0400 Subject: [PATCH] fix(npc-dialogue): split countdown units into controlled-gap cells The countdown rendered each time unit with a raw monospace space, which reads wide and odd when inline with proportional text. Split the value into per-unit inline-flex cells separated by a CSS gap so spacing stays consistent, and cover the new markup in the interpolate integration test. --- src/lib/npc-dialogue/DialogueText.tsx | 12 ++++++++++-- tests/int/npc-dialogue-interpolate.int.spec.ts | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lib/npc-dialogue/DialogueText.tsx b/src/lib/npc-dialogue/DialogueText.tsx index c4669f5d..402b577a 100644 --- a/src/lib/npc-dialogue/DialogueText.tsx +++ b/src/lib/npc-dialogue/DialogueText.tsx @@ -329,12 +329,20 @@ function Countdown({ value }: { value: string }) { const remaining = target - now; if (remaining <= 0) return ready; + // Each unit is its own inline-flex cell so the gap between them is controlled + // (a monospace font's raw space reads wide/odd inline with proportional text). return ( - {formatRemaining(remaining)} + {formatRemaining(remaining) + .split(" ") + .map((unit, i) => ( + + {unit} + + ))} ); } diff --git a/tests/int/npc-dialogue-interpolate.int.spec.ts b/tests/int/npc-dialogue-interpolate.int.spec.ts index 91c60597..9f71821b 100644 --- a/tests/int/npc-dialogue-interpolate.int.spec.ts +++ b/tests/int/npc-dialogue-interpolate.int.spec.ts @@ -394,6 +394,11 @@ describe("markup accumulation + links + countdowns", () => { const empty = render("x{cd|}y"); expect(empty).toContain("xy"); expect(empty).not.toContain("cd|"); + // Each unit is its own inline-flex cell (CSS gap) so the gap between units + // is controlled instead of the raw monospace space reading wide/odd inline. + const html = render(`{cd|${future}}`); + expect(html).toContain("inline-flex"); + expect(html.match(/whitespace-nowrap/g)?.length).toBe(2); }); it("formats remaining time compactly", () => {