Commit 59b37f4
authored
fix(svg): use actual weekday for tower positioning (JhaSourav07#2044)
## Description
Fixes JhaSourav07#2043
This PR fixes an SVG layout bug where contribution towers are rendered
in incorrect day-of-week rows when the contribution range starts in the
middle of a week.
Previously, `computeTowers()` used the array index of `contributionDays`
as the day-of-week coordinate:
```ts
const coords = projectIsometric(i, j);
```
This incorrectly assumes that `contributionDays[0]` always represents
Sunday. For partial first weeks (e.g., custom `from` dates or new GitHub
accounts), the first entry may actually be Wednesday, Thursday, etc.,
causing towers to be shifted into the wrong rows.
The fix derives the actual weekday from the contribution date:
```ts
const dayOfWeekIndex = new Date(day.date).getUTCDay();
const coords = projectIsometric(i, dayOfWeekIndex);
```
This ensures correct tower placement regardless of whether a week is
complete or partial.
## Pillar
* [ ] 🎨 Pillar 1 — New Theme Design
* [x] 📐 Pillar 2 — Geometric SVG Improvement
* [ ] 🕐 Pillar 3 — Timezone Logic Optimization
* [x] 🛠️ Other (Bug fix, refactoring, docs)
## Visual Preview
N/A – layout positioning fix. SVG output was verified using a date range
that begins mid-week and towers now align with their correct weekday
rows.
## Checklist before requesting a review:
* [x] I have read the `CONTRIBUTING.md` file.
* [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
* [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors (CI will fail otherwise).
* [x] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
* [ ] I have updated `README.md` if I added a new theme or URL
parameter. (Not applicable)
* [x] I have started the repo.
* [x] I have made sure that i have only one commit to merge in this PR.
* [x] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
* [x] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.2 files changed
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
226 | 227 | | |
227 | 228 | | |
228 | | - | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
234 | | - | |
235 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
156 | | - | |
| 157 | + | |
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
| |||
0 commit comments