Skip to content

Commit 3bc4bf6

Browse files
authored
docs(svg): add JSDoc for computeTowers (JhaSourav07#753)
2 parents 4e27e7f + 6cb3619 commit 3bc4bf6

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

lib/svg/layout.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,44 @@ function computeFaceOpacity(count: number, isGhostCityMode: boolean): FaceOpacit
5555
}
5656

5757
/**
58-
* Computes tower positions and heights from the last 14 weeks of
59-
* contribution data. The layout math is identical for both the
60-
* static-theme and auto-theme rendering paths.
58+
* Computes the full isometric tower layout used by the SVG renderer.
59+
*
60+
* The function transforms the GitHub contribution calendar into a
61+
* normalized array of TowerData objects consumed by both the static-theme
62+
* and auto-theme rendering paths.
63+
*
64+
* Only the most recent 14 weeks are rendered to keep the visualization
65+
* compact and visually consistent across different contribution histories.
66+
*
67+
* Ghost city mode is enabled when the visible 14-week window contains
68+
* zero contributions. In this mode, empty towers render with minimal
69+
* placeholder height/opacities so the scene still has visible structure.
70+
*
71+
* The todayDate parameter is used to determine which tower should receive
72+
* the animated "today" pulse effect. If the supplied date does not exist
73+
* inside the visible 14-week slice (for example because of stale cache
74+
* data or timezone differences), the final visible day automatically
75+
* falls back to being treated as "today" so the pulse animation always
76+
* remains visible.
77+
*
78+
* Each TowerData object contains:
79+
* - x/y: projected isometric screen coordinates
80+
* - h: tower height in pixels
81+
* - hasCommits: whether the day has contributions
82+
* - isGhost: whether ghost city rendering is active for the tower
83+
* - isToday: whether the tower represents the current local day
84+
* - isTodayWithCommits: whether today also contains contributions
85+
* - tooltip: hover label shown in the SVG
86+
* - contributionCount: raw GitHub contribution count
87+
* - faceOpacity: opacity configuration for isometric faces
88+
* - strokeOpacity/strokeWidth: outline styling for ghost towers
89+
* - row/col: logical grid coordinates used for staggered animations
90+
*
91+
* @param calendar GitHub contribution calendar response data.
92+
* @param scale Height scaling mode used for tower height calculation.
93+
* @param todayDate Local current date string used to determine the
94+
* animated "today" tower highlight.
95+
* @returns Array of normalized TowerData objects used by SVG renderers.
6196
*/
6297
export function computeTowers(
6398
calendar: ContributionCalendar,

0 commit comments

Comments
 (0)