feat(constellation): add celestial star-map SVG visualization with pr…#4735
feat(constellation): add celestial star-map SVG visualization with pr…#4735MasterJi27 wants to merge 2 commits into
Conversation
|
@MasterJi27 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new “constellation” view that renders a star-map style SVG visualization of a user’s GitHub contributions and wires it into the streak API.
Changes:
- Extends request validation + API routing to support
view=constellation - Introduces a new constellation SVG generator and its associated constants
- Adds Vitest coverage for the new generator
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/validations.ts | Allows constellation as a valid view parameter |
| lib/svg/constellationConstants.ts | Adds layout/style constants for the constellation SVG |
| lib/svg/constellation.ts | Implements the constellation SVG generator (stars, ring, labels, CSS) |
| lib/svg/constellation.test.ts | Adds tests for SVG generation and key features |
| app/api/streak/route.ts | Routes view=constellation requests to the new generator |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function makeMockCalendar( | ||
| totalContributions: number, | ||
| days: { date: string; count: number }[] | ||
| ): ContributionCalendar { | ||
| // Split days into weeks (7 days per week) | ||
| const weeks: ContributionCalendar['weeks'] = []; | ||
| const sorted = [...days].sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()); | ||
|
|
||
| for (let i = 0; i < sorted.length; i += 7) { | ||
| const weekDays = sorted.slice(i, i + 7); | ||
| // Pad to 7 days | ||
| while (weekDays.length < 7) { | ||
| const lastDate = weekDays[weekDays.length - 1]?.date || '2025-01-01'; | ||
| const nextDate = new Date(lastDate + 'T12:00:00Z'); | ||
| nextDate.setDate(nextDate.getDate() + 1); | ||
| weekDays.push({ | ||
| date: nextDate.toISOString().slice(0, 10), | ||
| count: 0, | ||
| }); | ||
| } | ||
| weeks.push({ contributionDays: weekDays }); | ||
| } | ||
|
|
||
| return { totalContributions, weeks }; | ||
| } |
|
|
||
| // ─── Background Starfield ─────────────────────────────────────────────────── | ||
|
|
||
| function generateBackgroundStars(seed: string, density: number, bgColor: string): BackgroundStar[] { |
| function buildConstellationLines( | ||
| stars: ContributionStar[], | ||
| accentColor: string | ||
| ): ConstellationLines[] { |
| const sorted = brightest.sort( | ||
| (a, b) => new Date(a.date).getTime() - new Date(b.date).getTime() | ||
| ); |
| export function generateConstellationSVG( | ||
| stats: StreakStats, | ||
| params: BadgeParams, | ||
| calendar: ContributionCalendar | ||
| ): string { |
| const year = firstDay | ||
| ? new Date(firstDay.date + 'T12:00:00Z').getUTCFullYear() | ||
| : new Date().getUTCFullYear(); | ||
| const currentMonthIndex = new Date().getUTCMonth(); |
| } else if (normalizedView === 'constellation') { | ||
| const stats = calculateStreak(calendar, timezone, undefined, grace); | ||
| svg = generateConstellationSVG(stats, params, calendar); |
| // Parse density from params or use default | ||
| const density = DEFAULT_BG_STAR_COUNT; |
|
🚨 Hey @MasterJi27, the CI Pipeline is failing on this PR and it has been marked as Please fix the issues before this can be reviewed. Here's how: 1. Run checks locally before pushing: npm run format:check # Check Prettier formatting
npm run lint # Run ESLint
npm run typecheck # TypeScript type check
npm run test # Run unit tests (Vitest)
npm run build # Verify production build passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
…ocedural night sky, constellation lines, and timezone-aware zodiac ring
| // Determine year from calendar data | ||
| const firstDay = calendar.weeks[0]?.contributionDays[0]; | ||
| const year = firstDay | ||
| ? new Date(firstDay.date + 'T12:00:00Z').getUTCFullYear() | ||
| : new Date().getUTCFullYear(); |
| const posSeed = deterministicRandom(`${seed}:bg:pos:${i}`); | ||
| const brightnessSeed = deterministicRandom(`${seed}:bg:bright:${i}`); | ||
| const delaySeed = deterministicRandom(`${seed}:bg:delay:${i}`); | ||
|
|
||
| // Position: spread across the full canvas, avoiding the very center ring area slightly | ||
| const cx = STARFIELD_MIN_X + posSeed * (STARFIELD_MAX_X - STARFIELD_MIN_X); | ||
| const cy = STARFIELD_MIN_Y + brightnessSeed * (STARFIELD_MAX_Y - STARFIELD_MIN_Y); |
| const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${CONSTELLATION_SVG_WIDTH}" height="${CONSTELLATION_SVG_HEIGHT}" viewBox="0 0 ${CONSTELLATION_SVG_WIDTH} ${CONSTELLATION_SVG_HEIGHT}" role="img" aria-labelledby="cp-constellation-title cp-constellation-desc"> | ||
| <title id="cp-constellation-title">CommitPulse Constellation Map for ${safeUser}</title> | ||
| <desc id="cp-constellation-desc">A celestial star-map visualization of ${safeUser}'s GitHub contributions in ${year}. Each star represents a day with contributions; brighter stars indicate more commits. Constellation lines connect the brightest stars within each month.</desc> |
| @keyframes ${CSS_PREFIX}-milkyway-rotate { | ||
| 0% { transform: rotate(0deg); } | ||
| 100% { transform: rotate(360deg); } | ||
| }`; |
| <!-- Milky Way gradient band --> | ||
| <rect x="0" y="0" width="${CONSTELLATION_SVG_WIDTH}" height="${CONSTELLATION_SVG_HEIGHT}" fill="url(#${CSS_PREFIX}-milkyway)" /> |
| it('includes the zodiac ring with 12 arcs', () => { | ||
| const calendar = makeMockCalendar(24, [ | ||
| { date: '2025-01-15', contributionCount: 2 }, | ||
| { date: '2025-06-15', contributionCount: 2 }, | ||
| { date: '2025-12-25', contributionCount: 2 }, | ||
| ]); | ||
| const svg = generateConstellationSVG(makeMockStats(), makeMockParams(), calendar); | ||
|
|
||
| // Should have 12 path elements for the zodiac ring arcs | ||
| const arcMatches = svg.match(/id="ck-zodiac-ring"/); | ||
| expect(arcMatches).not.toBeNull(); | ||
| }); |
- Add 'constellation' to BadgeParams.view type union in types/index.ts - Remove unused ContributionCalendar import in app/api/streak/route.ts Fixes CI lint (no-unused-vars) and typecheck failures on PR JhaSourav07#4735.
feat: Contribution Constellation — Star-Map SVG Visualization with Procedural Night Sky, Constellation Lines, and Timezone-Aware Zodiac Ring
Description
Fixes #4734
Adds a new
?view=constellationvisualization mode that renders GitHub contribution history as a celestial star map with procedural night sky, constellation lines connecting bright contribution clusters, a timezone-aware zodiac ring, and CSS animations.Pillar
Visual Preview
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=jhasourav07&view=constellation&theme=neon).npm run formatandnpm run lintlocally and resolved all errors.README.mdif I added a new theme or URL parameter.