Skip to content

Feat/repo contribution distribution chart#367

Open
prashant2007-wq wants to merge 12 commits into
Priyanshu-byte-coder:mainfrom
prashant2007-wq:feat/repo-contribution-distribution-chart
Open

Feat/repo contribution distribution chart#367
prashant2007-wq wants to merge 12 commits into
Priyanshu-byte-coder:mainfrom
prashant2007-wq:feat/repo-contribution-distribution-chart

Conversation

@prashant2007-wq
Copy link
Copy Markdown

@prashant2007-wq prashant2007-wq commented May 19, 2026

Summary

Added a Repository Contribution Distribution Chart below the Contribution Heatmap section on the dashboard.

This chart helps users understand which repositories they contribute to the most by showing repository-wise commit distribution, percentage contribution, and hover tooltip details.

The chart uses real GitHub contribution data from the existing backend endpoint:

/api/metrics/repos?days=365

So it displays repository data for the logged-in GitHub user instead of using sample/static data.

Closes #308

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup

Changes Made

  • Added a new RepoContributionDistribution component.
  • Placed the chart below the Contribution Heatmap section on the dashboard.
  • Used the existing /api/metrics/repos?days=365 endpoint to fetch real repository metrics.
  • Added repository-wise commit count display.
  • Added percentage contribution calculation per repository.
  • Added Pie chart view for contribution share.
  • Added Bar chart view for repository comparison.
  • Added toggle support between Pie and Bar chart modes.
  • Added hover tooltips showing:
    • Repository name
    • Commit count
    • Percentage contribution
  • Added loading state while data is being fetched.
  • Added empty state when no repository contribution data is available.
  • Added error state if repository metrics fail to load.
  • Updated chart styling to support both light and dark mode.
  • Replaced hardcoded theme-breaking UI colors with CSS variables where applicable.
  • Used var(--accent) for the first chart color.
  • Added a comment explaining that the remaining chart colors are intentional categorical hues for distinguishing repositories.
  • Replaced hardcoded error text color with text-[var(--destructive)].
  • Removed the accidentally committed .env.localø file.
  • Added .env.local* to .gitignore so local environment files are not tracked.
  • Ensured RepoContributionDistribution.tsx ends with a newline.

How to Test

Steps for the reviewer to verify this works:

  1. Pull this branch locally.

  2. Install dependencies:

npm install
  1. Add the required environment variables in .env.local:
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=

NEXTAUTH_SECRET=
NEXTAUTH_URL=http://localhost:3000

GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
  1. Start the development server:
npm run dev
  1. Open the dashboard:
http://localhost:3000/dashboard
  1. Log in using GitHub.

  2. Scroll below the Contribution Heatmap section.

  3. Verify that the Repository Contribution Distribution Chart is visible.

  4. Verify that the chart displays real repository contribution data from the logged-in user.

  5. Test both chart modes:

    • Pie chart
    • Bar chart
  6. Hover over chart items and verify that the tooltip displays:

    • Repository name
    • Commit count
    • Percentage contribution
  7. Verify all UI states:

    • Loading state
    • Empty state
    • Error state
    • Success state
  8. Switch between light and dark mode and verify that the chart container, text, controls, and error state remain readable.

Screenshots (if UI change)

Add screenshots here:

  • Dashboard with Repository Contribution Distribution Chart
  • Pie chart view
  • Bar chart view
  • Tooltip hover state
  • Light mode view
  • Dark mode view

Checklist

  • Linked issue in summary
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Self-reviewed the diff
  • Removed accidentally committed env file
  • Added .env.local* to .gitignore
  • Replaced hardcoded theme-breaking UI colors with CSS variables where applicable
  • Documented intentional chart-specific categorical colors
  • Ensured RepoContributionDistribution.tsx ends with a newline
  • Added/updated tests if applicable

@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

@prashant2007-wq is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your first PR on DevTrack! 🎉

A maintainer will review it within 48 hours. While you wait:

  • Make sure CI is passing (type-check + lint)
  • Double-check the PR description is filled out and the issue is linked
  • Feel free to ask questions in Discussions if you need help

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

Two critical fixes needed before merge:

1. Remove committed env file (critical)

.env.localø (note the odd character in the filename) is committed to this PR. Even with dummy values, env files must not be tracked in git — they can cause confusion and bad habits. Remove it:

git rm ".env.localø"
git push

Also add .env.local* to .gitignore if not already there.

2. Hardcoded Tailwind colors break dark mode

The component uses Tailwind utility classes that assume a dark background and break in light mode:

// Current (broken in light mode):
"border-white/10 bg-white/5"    border-[var(--border)] bg-[var(--card)]
"bg-black/10"                   bg-[var(--control)]
"text-muted-foreground"         text-[var(--muted-foreground)]
"bg-primary text-primary-foreground"  bg-[var(--accent)] text-[var(--accent-foreground)]

Also, the first chart color "#6366f1" in the COLORS array is the accent color — use var(--accent) there. The remaining chart colors (different hues for different repos) are acceptable as-is.

Fix these two and the PR is mergeable.

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded hex colors break theming — 7 of 8 entries in the COLORS array are raw hex values that won't adapt to dark/light mode or custom themes:

// Change these to CSS vars or project tokens
"#22c55e"  consider var(--success) if defined, or keep as chart-specific color
"#f97316", "#06b6d4", etc.

For rotating chart colors with no CSS var equivalent, document the decision with a comment. But text-red-300 in the error state must become text-[var(--destructive)].

Missing EOF newline in RepoContributionDistribution.tsx.

Link the issue — PR checklist is entirely blank. Add the issue number this closes.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature labels May 20, 2026
@Priyanshu-byte-coder Priyanshu-byte-coder added the level:intermediate GSSoC: Intermediate difficulty (35 pts) label May 20, 2026
Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issues found in this PR:

  • Raw Tailwind color classes — replace text-red-* / bg-red-* with text-[var(--destructive)] / appropriate CSS var equivalents. All colors must use CSS variables for theme support.

@prashant2007-wq
Copy link
Copy Markdown
Author

Fixed the remaining raw Tailwind color issue.

  • Replaced the error-state raw red color utilities with theme CSS variables.
  • The error state now uses:
    • border-[var(--destructive)]
    • bg-[var(--card)]
    • text-[var(--destructive)]
  • Confirmed there are no remaining text-red-*, bg-red-*, or border-red-* classes in RepoContributionDistribution.tsx.

I also ran:

npm run lint
npm run type-check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution level:intermediate GSSoC: Intermediate difficulty (35 pts) type:feature GSSoC type bonus: new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Repository Contribution Distribution Chart Below Contribution Heatmap

2 participants