Skip to content

fix(web): keep close method-spectrum labels from colliding - #46

Merged
Stanback merged 1 commit into
mainfrom
fix/method-spectrum-labels
Oct 24, 2026
Merged

Stanback merged 1 commit into
mainfrom
fix/method-spectrum-labels

Conversation

@Stanback

Copy link
Copy Markdown
Owner

Problem

On the converter's Compare methods card, each spectrum pin centred its name and time under its dot. When two methods convert to nearby times, the labels printed over each other. With women's 1650 SCY 17:36.20 → 1500 SCM, NCAA (17:33.04) and Equivalence (17:45.52) are about 10% of the track apart, so the card showed "NCAAEquivalence" and "17:33.0417:45.52".

Fix (src/lib/MethodComparison.svelte)

  • Each dot stays on a zero-width anchor at its true position, the same anchor idea as the MCP card.
  • The track and labels are measured with Svelte bind: bindings. Each label centres on its pin when it fits, is clamped inside the track, and moves to the first lower row where it touches no other label, with a leader tick back to its dot. Rows where no leader runs through a label are preferred. Labels have an opaque surface background, so an unavoidable leader passes behind text, not over it.
  • The row pitch comes from the measured label height, so enlarged text still separates. Before measuring, labels are centred under their pins with a rem fallback pitch.
  • The label is now the <button>, so its focus ring and hit area match what is drawn.
  • No new dependencies, and the common cases look the same as before (e.g. 100 free → LCM, where all three labels fit on one row).

Test

New Playwright case method spectrum keeps close method labels apart and inside the card. It uses the 1650 example at desktop and 390px, in light and dark, and asserts that:

  • no two name/time boxes overlap
  • every label stays inside the card
  • dots keep their true order and relative spacing

It fails on main with "NCAA overlaps Equivalence".

Other surfaces

  • iOS / Android: these show only a "Method spread (all 3)" text row, with no spectrum, so they're unaffected.
  • MCP card: has the same collision (at 390px "NCAA" spans x 76–109 and "Equivalence" x 91–159). It's left unchanged here because the fix isn't small. The card builds its DOM imperatively, so it needs post-layout measurement, a resize observer and harness changes. It's best as a follow-up.

Verification

npm run check, npm test (187), npx playwright test (57 passed, 1 pre-existing mobile-only skip), node --test scripts/ci-changes.test.mjs scripts/native-test-support.test.mjs (84).

🤖 Generated with Claude Code

Each spectrum pin centred its name and time under the dot, so methods whose
converted times sit close together printed over each other (women's 1650 SCY
17:36.20 -> 1500 SCM rendered "NCAAEquivalence" / "17:33.04 17:45.52").

Dots stay on a zero-width anchor at their true position. Labels are measured
and laid out separately: centred on the pin when it fits, clamped inside the
track, and moved to the first lower row where they touch no other label, with
a leader tick back to the dot. The label is now the button, so its focus ring
and hit area match what is drawn.

The Playwright case reproduces the 1650 example at desktop and 390px in light
and dark, asserting no label overlap, containment in the card and true dot
positions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Stanback
Stanback merged commit e446ea7 into main Oct 24, 2026
12 checks passed
@Stanback
Stanback deleted the fix/method-spectrum-labels branch October 24, 2026 08:55
Stanback added a commit that referenced this pull request Oct 24, 2026
The MCP card had the same collision the web fixed in #46: at phone width the
women's 1650 SCY 17:36.20 -> SCM card printed "NCAA" and "Equivalence" over
each other. The label layout now lives in src/lib/spectrum-layout.ts and both
the web component and the card call it. The card lays labels out after its
collapsed details open (a ResizeObserver on the track), dropping a colliding
label to a lower row with a leader tick; dots keep their true positions.

The card resource moves to ui://turnmark/conversion/0.3.0-r8.html so hosts do
not reuse the cached r7 view. test-mcp-ui reproduces the 1650 card at 680px and
390px (it fails on the previous card at 390px), and a unit test covers the
shared layout.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant