Ultimate Full-Width Profile Dashboard (830px).#18
Merged
Conversation
- Implemented a massive 830px wide Mastercard that covers the entire README. - Dashboard includes: Header, Primary Stats Row, Language Usage Mastery, Weekly Activity Chart, Top Repositories, Performance Streaks, and 12-month Heatmap. - Restored critical helper functions in `src/github.js` to fix regressions in standalone cards. - Enhanced robustness with parallel fetching, individual error handling, and robust timeouts. - Polished visuals with premium SVG styling and high-contrast accents. - Updated documentation and landing page with the new dashboard examples. Co-authored-by: Chintanpatel24 <216989679+Chintanpatel24@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR updates the “master” (830px) full-width dashboard card by redesigning the SVG layout/styling and adjusting the data-fetching helpers and API endpoint to support the new dashboard content and improved resiliency.
Changes:
- Revamps
src/svg-master.jsto a new 830px “full dashboard” layout (header, 5-stat row, language usage, weekly activity, repos, streaks, 12-month heatmap). - Refactors
api/master.jsto fetch dashboard inputs in parallel with per-call fallbacks and a new cache key version. - Updates
src/github.jshelper behavior (safeFetch timeout param, simplified PR/stars/languages/contribution parsing, compatibility exports).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
src/svg-master.js |
Updates the master dashboard SVG layout, metrics displayed, and styling for the 830px card. |
src/github.js |
Adjusts GitHub data fetch helpers (timeouts, paging strategy, contribution parsing) used by dashboard APIs. |
api/master.js |
Updates the master dashboard endpoint to use parallel fetching with fallbacks and new cached payload fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
42
to
47
| async function fetchUserPullRequests(username) { | ||
| const perPage = 100; | ||
| let page = 1; | ||
| let allPRs = []; | ||
| try { | ||
| while (page <= 2) { // Limited to 2 pages to save rate limit | ||
| const url = `${GITHUB_API}/search/issues?q=author:${encodeURIComponent(username)}+type:pr&per_page=${perPage}&page=${page}`; | ||
| const data = await safeFetch(url); | ||
| if (!data || !data.items || data.items.length === 0) break; | ||
| allPRs = allPRs.concat(data.items); | ||
| if (allPRs.length >= data.total_count || data.items.length < perPage) break; | ||
| page++; | ||
| } | ||
| } catch (e) {} | ||
| return allPRs; // Returns empty array if fails | ||
| const encUser = encodeURIComponent(username); | ||
| const url = `${GITHUB_API}/search/issues?q=author:${encUser}+type:pr&per_page=100&page=1`; | ||
| const data = await safeFetch(url); | ||
| return data?.items || []; | ||
| } |
Comment on lines
+168
to
+171
| const url = `${GITHUB_API}/users/${encUser}/repos?type=owner&per_page=100`; | ||
| const data = await safeFetch(url); | ||
| if (!Array.isArray(data)) return 0; | ||
| return data.reduce((sum, repo) => sum + (repo.stargazers_count || 0), 0); |
Comment on lines
135
to
+149
| const entryRegex = /<(?:td|rect)\b[^>]*\bdata-date="(\d{4}-\d{2}-\d{2})"[^>]*data-level="(\d+)"[^>]*>/g; | ||
| const dates = []; | ||
| let match; | ||
| while ((match = entryRegex.exec(html)) !== null) { | ||
| const date = match[1]; | ||
| const level = parseInt(match[2], 10); | ||
| const tag = match[0]; | ||
| const idMatch = tag.match(/\bid="([^"]+)"/); | ||
|
|
||
| dates.push({ | ||
| id: idMatch ? idMatch[1] : `day-${dates.length}`, | ||
| date, | ||
| level, | ||
| date: match[1], | ||
| level: parseInt(match[2], 10), | ||
| count: 0 | ||
| }); | ||
| } | ||
|
|
||
| const tipRegex = /<tool-tip[^>]*for="([^"]+)"[^>]*>([\s\S]*?)<\/tool-tip>/g; | ||
| const countById = new Map(); | ||
| while ((match = tipRegex.exec(html)) !== null) { | ||
| const targetId = match[1]; | ||
| const tipText = match[2].replace(/\s+/g, " ").trim(); | ||
| const countMatch = tipText.match(/(\d+)\s+contribution/i); | ||
| const count = countMatch ? parseInt(countMatch[1], 10) : 0; | ||
| countById.set(targetId, count); | ||
| } | ||
|
|
||
| const days = []; | ||
| for (let i = 0; i < dates.length; i++) { | ||
| const count = countById.has(dates[i].id) ? countById.get(dates[i].id) : (dates[i].level * 2); | ||
| days.push({ | ||
| date: dates[i].date, | ||
| count: count, | ||
| level: dates[i].level, | ||
| }); | ||
| } | ||
| const days = dates.map(d => ({ | ||
| ...d, | ||
| count: d.level * 2 // Fallback | ||
| })); |
| const encUser = encodeURIComponent(username); | ||
| const url = `${GITHUB_API}/search/commits?q=author:${encUser}&per_page=100&sort=author-date`; | ||
| const data = await safeFetch(url, { headers: { Accept: "application/vnd.github.cloak-preview" } }); | ||
| const allCommits = (data?.items || []).map(c => ({ timestamp: new Date(c.commit?.author?.date).getTime() })); |
Comment on lines
+58
to
+80
| // Parallel fetch with individual error handling to prevent total failure | ||
| const [ | ||
| prs, profile, contributionData, langData, | ||
| totalCommits, totalIssues, openIssues, closedIssues, | ||
| mergedPRCount, totalStars, openPRCount | ||
| ] = await Promise.all([ | ||
| safe(fetchUserPullRequests(username), []), | ||
| safe(fetchUserProfile(username), { login: username, public_repos: 0 }), | ||
| safe(fetchContributionData(username), { totalContributions: 0, days: [] }), | ||
| safe(fetchUserLanguages(username), { languages: [], totalRepos: 0 }), | ||
| safe(fetchTotalCommitCount(username), 0), | ||
| safe(fetchUserIssues(username), 0), | ||
| safe(fetchOpenIssues(username), 0), | ||
| safe(fetchClosedIssues(username), 0), | ||
| safe(fetchMergedPullRequests(username), 0), | ||
| safe(fetchUserTotalStars(username), 0), | ||
| safe(fetchOpenPullRequests(username), 0) | ||
| ]); | ||
|
|
||
| const linesChanged = await safe(fetchRecentPRLinesChanged(prs, 3), 0); | ||
|
|
||
| const days = contributionData?.days || []; | ||
| const sortedDays = [...days].sort((a, b) => a.date.localeCompare(b.date)); |
Comment on lines
+111
to
+118
| data = { | ||
| username: profile.login || username, | ||
| name: profile.name || profile.login || username, | ||
| totalPRs: prs.length || 0, | ||
| openPRs: openPRCount || 0, | ||
| mergedPRs: mergedPRCount || 0, | ||
| repoCount: profile.public_repos || 0, | ||
| languages: langData.languages || [], |
Comment on lines
+44
to
52
| // --- MAIN STATS ROW --- | ||
| const statW = Math.floor(innerW / 5); | ||
| const heroStats = [ | ||
| { label: "Commits", value: totalCommits.toLocaleString(), color: accentColor }, | ||
| { label: "Stars", value: totalStars.toLocaleString(), color: "eab308" }, | ||
| { label: "PRs", value: totalPRs, color: "8b5cf6" }, | ||
| { label: "Issues", value: totalIssues, color: "f85149" }, | ||
| { label: "Contribs", value: contributions.toLocaleString(), color: "39d353" }, | ||
| { label: "Lines +/-", value: linesChanged.toLocaleString(), color: "fb923c" }, | ||
| { label: "Contributions", value: contributions.toLocaleString(), color: "39d353" }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
src/github.jsto fix regressions in standalone cards.