refactor(timeline): centralize time-pixel scale#200
Conversation
Extract timeToOffset/offsetToTime as the single place the 2px/minute timeline scale lives; TimeScale and set positioning now consume them instead of re-deriving the 2/120 constants. Closes #191
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR centralizes the schedule timeline’s time↔pixel scale in src/lib/timelineCalculator.ts by introducing shared conversion helpers, then updates the horizontal timeline UI and layout calculations to consume those helpers instead of re-deriving 2px/min / 120px/hr constants.
Changes:
- Added
timeToOffset/offsetToTimehelpers (and a singlePX_PER_MINUTEconstant) to the timeline geometry module. - Updated
TimeScalehour-marker and day-boundary positioning to usetimeToOffset. - Refactored set positioning and
totalWidthcomputation incalculateTimelineDatato use the new mapping, and added unit tests for the mapping and boundary behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/pages/EditionView/tabs/ScheduleTab/horizontal/TimeScale.tsx | Replaces hardcoded pixel math with timeToOffset for axis/day-boundary positioning. |
| src/lib/timelineCalculator.ts | Introduces centralized time↔pixel conversion helpers and refactors layout math to use them. |
| src/lib/timelineCalculator.test.ts | Adds unit coverage for the new mapping helpers and timeline boundary calculations. |
differenceInMinutes truncates to whole minutes, so timeToOffset and offsetToTime did not round-trip for sub-minute moments. Base the conversion on epoch milliseconds; output is unchanged for whole-minute inputs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AziTqr3f12fxALYD6jhrW8
Extracts
timeToOffset/offsetToTimeintimelineCalculator.tsas the single place the timeline's 2px/minute scale lives, soTimeScaleand set-block positioning consume the mapping instead of re-deriving the 2/120 pixel constants.Rendering is unchanged — blocks and axis marks land at identical pixel positions before and after.
Closes #191
Verification
pnpm run lint,pnpm run typecheck, andpnpm vitest runall pass (367 tests, including newsrc/lib/timelineCalculator.test.ts).src/pages/EditionView/tabs/ScheduleTab/horizontal/still hardcodes the2/120pixel-per-minute/hour scale (grep -rn "\* 2\b\|\* 120\b" src/pages/EditionView/tabs/ScheduleTab).Generated by Claude Code