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.
This commit is contained in:
parent
375023f708
commit
02307aa2ee
2 changed files with 15 additions and 2 deletions
|
|
@ -329,12 +329,20 @@ function Countdown({ value }: { value: string }) {
|
|||
|
||||
const remaining = target - now;
|
||||
if (remaining <= 0) return <span className="font-mono text-emerald-400">ready</span>;
|
||||
// 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 (
|
||||
<span
|
||||
className="font-mono tabular-nums text-cyan-300"
|
||||
className="inline-flex items-center gap-1.5 font-mono tabular-nums text-cyan-300"
|
||||
title={new Date(target).toISOString()}
|
||||
>
|
||||
{formatRemaining(remaining)}
|
||||
{formatRemaining(remaining)
|
||||
.split(" ")
|
||||
.map((unit, i) => (
|
||||
<span key={i} className="whitespace-nowrap">
|
||||
{unit}
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue