Skip to content

refactor(timeline): centralize time-pixel scale#200

Open
chiptus wants to merge 2 commits into
mainfrom
claude/188-191-timeline-geometry
Open

refactor(timeline): centralize time-pixel scale#200
chiptus wants to merge 2 commits into
mainfrom
claude/188-191-timeline-geometry

Conversation

@chiptus

@chiptus chiptus commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Extracts timeToOffset/offsetToTime in timelineCalculator.ts as the single place the timeline's 2px/minute scale lives, so TimeScale and 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, and pnpm vitest run all pass (367 tests, including new src/lib/timelineCalculator.test.ts).
  • Open the horizontal Schedule timeline tab; hour markers, day-boundary labels, and set blocks render at the same positions as before this change.
  • Confirm no other file under src/pages/EditionView/tabs/ScheduleTab/horizontal/ still hardcodes the 2/120 pixel-per-minute/hour scale (grep -rn "\* 2\b\|\* 120\b" src/pages/EditionView/tabs/ScheduleTab).

Generated by Claude Code

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
Copilot AI review requested due to automatic review settings July 14, 2026 18:20
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
upline Ready Ready Preview, Comment Jul 14, 2026 6:26pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / offsetToTime helpers (and a single PX_PER_MINUTE constant) to the timeline geometry module.
  • Updated TimeScale hour-marker and day-boundary positioning to use timeToOffset.
  • Refactored set positioning and totalWidth computation in calculateTimelineData to 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.

Comment thread src/lib/timelineCalculator.ts
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
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.

prefactor: timeline geometry owns the time↔pixel mapping

3 participants