Skip to content

feat(profile): show the user's real GitHub contribution graph (#61)#68

Open
bae080311 wants to merge 10 commits into
Younesfdj:masterfrom
bae080311:feat/contribution-graph
Open

feat(profile): show the user's real GitHub contribution graph (#61)#68
bae080311 wants to merge 10 commits into
Younesfdj:masterfrom
bae080311:feat/contribution-graph

Conversation

@bae080311

Copy link
Copy Markdown

What

Closes #61.

Adds the user’s actual GitHub contribution graph to the profile page.

This addresses the maintainer’s feedback:

  • Reuses the existing background grid’s cell size, radius, and green through shared GRID_* constants, rather than introducing a second grid style.
  • Uses the existing contributionCalendar GraphQL query, so no additional API request is made.
  • Adds a pure calendar transformation in lib/contributions.ts, covering weekday alignment, padding, intensity levels, streaks, and month labels.
  • Adds tests for the transformation logic.

The contribution days are flattened from the existing GraphQL response and passed through scout.ts onto Card. recentActiveDays is now derived from the same flattened data.

Screenshots

Notes

  • The public /api/card/:username response does not include contribution-day data, since it is only used by the server-rendered profile page.
  • Bumped the Redis card cache version because the Card shape changed.

Tests

  • npm test — 230 passed
  • npm run lint — 0 errors
  • npm run build — passed

An AI assistant helped with the implementation. I reviewed the changes and ran the tests, lint, and build locally.

bae080311 and others added 10 commits July 15, 2026 10:20
Reshapes a user's real per-day contribution counts into a rendering-ready
grid (Sun..Sat weeks, month labels, per-user quartile intensity levels,
current streak). Framework-agnostic and fetch-free so it's trivially
unit-tested on its own, ahead of wiring it into any UI.
…he profile fetch

The scout already requests contributionCalendar in the profile query, but
only reduced it to a single recentActiveDays count. Add `date` to the
existing field selection (no new API call) and flatten the calendar into
RawPayload.contributionDays; recentActiveDays now derives from that same
array instead of walking the tree twice.
Card gains an optional contributionDays field, attached alongside
buildCard's output in buildFresh rather than folded into Signals/buildCard
itself — it's display data for the profile page, not a scoring input.
Bumps the Redis cache version since this changes Card's cached shape.
Adds ContributionPanel — a real per-user grid rendered full-width below the
scouting report, styled like the other report panels. Reuses the decorative
Background motif's exact cell geometry and green (now exported as GRID_*
constants) so the page never shows two different-looking grids, and
suppresses that decorative strip only once a card actually has calendar data
to replace it with.
The public /api/card/:username response has no reason to carry ~365 extra
{date,count} rows per request — that data only feeds the profile page's own
ContributionPanel render, which already has it via the server-rendered Card.
Adding a fourth section (the contribution graph) pushed the result page
past typical laptop heights. Scale several previously width-only or fixed
values (card size, grade stamp, name, vertical margins) with viewport
height too, so the whole report — card, attributes, metrics, distribution,
contributions — fits without scrolling on common desktop sizes (~1512x980+)
and comes close on smaller ones (~1440x900), without touching the
mobile-stacked layout (still governed by the max-[980px] breakpoint).

Raised the card's width floor from 220 to 260 — CardActions' Download
button needs that much room before its label starts truncating, which the
more aggressive height-based shrinking would otherwise have hit.
…, not a new section

The standalone ContributionPanel section added real page height on top of an
already content-heavy result page, reintroducing the scroll it was meant to
avoid. Since the decorative grid motif in Background.tsx is purely an
absolutely-positioned layer (zero document-flow height), swapping in the
user's real per-day calendar there instead costs nothing extra — same spot,
same cell size/rounding/green, just real data instead of a seeded pattern.

Falls back to the fake pattern whenever there's no real calendar to show
(demo/sample cards, cards cached before contributionDays existed, or no card
at all), so every page still gets *a* motif, just not a fabricated one when
real data is available.

ContributionPanel.tsx is removed; lib/contributions.ts (the pure transform)
stays — Background now builds the real grid's SVG string from its output
directly, the same way it already did for the fake one.
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.

feat: show GitHub contribution graph in the card background

1 participant