Skip to content

refactor(layout): extract ghost-city detection into a named isGhostCity() predicate #293

@JhaSourav07

Description

@JhaSourav07

🧩 Background

lib/svg/layout.ts inline-computes shouldShowGhostCity via a totalVisibleContributions === 0 check spread across a forEach loop. The intent is clear but the implementation is implicit.

🎯 Objective

Extract into function isGhostCity(weeks: ContributionWeek[]): boolean and call it from computeTowers.

📁 Files to touch

  • lib/svg/layout.ts

🛠️ Implementation steps

  • Write the pure predicate function.
  • Replace the inline computation.
  • Export it and add a small unit test covering 0-contribution and >0-contribution calendars.

✅ Definition of done

  • isGhostCity is a named, exported, tested function.
  • computeTowers reads clearly.
  • All layout and SVG tests pass.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions