refactor(timeline): single-source the spine X position via --spine-x
All checks were successful
CI / fail2ban Regex (pull_request) Successful in 46s
CI / Semgrep Security Scan (pull_request) Successful in 22s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m9s
SDD Gate / RTM Check (pull_request) Successful in 18s
SDD Gate / Contract Validate (pull_request) Successful in 25s
SDD Gate / Constitution Impact (pull_request) Successful in 19s
CI / Unit & Component Tests (push) Successful in 4m33s
CI / OCR Service Tests (push) Successful in 24s
CI / Backend Unit Tests (push) Successful in 5m19s
CI / fail2ban Regex (push) Successful in 46s
CI / Semgrep Security Scan (push) Successful in 26s
CI / Compose Bucket Idempotency (push) Successful in 1m8s
CI / Unit & Component Tests (pull_request) Successful in 4m24s
CI / OCR Service Tests (pull_request) Successful in 24s
CI / Backend Unit Tests (pull_request) Successful in 5m21s

The spine offset (0.5rem phone / 50% desktop) was hard-coded in both
TimelineView's .timeline-axis::before and YearBand's .year-node/.letter-dot,
kept in sync only by a comment. Declare --spine-x once on .timeline-axis
and have the markers consume it by inheritance, so a change to the spine
position moves the markers with it. Add a test that the year-node tracks
the token.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit was merged in pull request #836.
This commit is contained in:
Marcel
2026-06-14 13:51:46 +02:00
parent 0a235dc911
commit 239565ea20
3 changed files with 36 additions and 11 deletions

View File

@@ -145,4 +145,23 @@ describe('YearBand', () => {
card.getBoundingClientRect().left + 0.5
);
});
it('positions the year-node from the inherited --spine-x token (REQ-003/004)', async () => {
await page.viewport(375, 800);
// The spine X lives once on .timeline-axis as --spine-x; the markers must
// track that token, not a hard-coded offset, so they never desync.
document.documentElement.style.setProperty('--spine-x', '3rem');
try {
render(YearBand, { year: makeYear(1914, [makeEntry()]) });
const node = document.querySelector('[data-testid="year-node"]') as HTMLElement;
const section = document.querySelector('section') as HTMLElement;
const n = node.getBoundingClientRect();
const s = section.getBoundingClientRect();
const nodeCenter = n.left + n.width / 2;
// --spine-x:3rem = 48px from the band's left edge
expect(Math.abs(nodeCenter - s.left - 48)).toBeLessThan(2);
} finally {
document.documentElement.style.removeProperty('--spine-x');
}
});
});