Skip to content

feat(api): add compact=true param for slim single-row streak card#6130

Merged
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
vbarik317-droid:feat/compact-streak-card
Jun 21, 2026
Merged

feat(api): add compact=true param for slim single-row streak card#6130
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
vbarik317-droid:feat/compact-streak-card

Conversation

@vbarik317-droid

Copy link
Copy Markdown
Contributor

Closes #5724.

Summary

Adds a compact=true query param to /api/streak that renders a slim, single-row version of the streak card (280×100px) instead of the full 3D isometric grid. Useful for narrow README layouts and sidebar badges.

Changes

  • types/index.ts: added compact?: boolean to BadgeParams
  • app/api/streak/route.ts: parses compact from the query string and passes it through to the badge params
  • lib/svg/generator.ts: added generateCompactSVG() and branched generateSVG() to call it early when params.compact is true, before the expensive tower computation runs

Behavior

  • compact=true → renders username + 🔥 current streak count in a slim card, no isometric towers
  • compact omitted → full isometric card renders unchanged (no regression)
  • Existing bg, accent, text, and font params are sanitized and applied the same way as the full card, so theming stays consistent

Testing

Tested locally with npm run dev + curl:

  • /api/streak?user=octocat&compact=true → 280×100 slim card
  • /api/streak?user=octocat → unchanged 600×420 full card
  • /api/streak?user=octocat&compact=true&bg=1a1a2e&accent=ff6b35&text=eaeaea → theme overrides apply correctly

Checklist

  • compact=true triggers slim card render
  • All theme/color params still apply
  • Full card renders when compact is omitted
  • Correct viewBox dimensions for compact layout

Adds a compact query param to /api/streak that renders a 280x100
single-row SVG with username and current streak count, skipping
the full isometric grid. Reuses existing theme/font/color
sanitization so bg, accent, text, and font params apply
consistently with the full card.

Closes JhaSourav07#5724
@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

@vbarik317-droid is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vbarik317-droid

Copy link
Copy Markdown
Contributor Author

Fix: streakParamsSchema already validated year correctly, but the route wasn't using the parsed value — it fell back to raw searchParams.get('year') for the date math, so invalid years slipped through. Now using the validated value consistently. Added a route-level test for year=2099 → 400.
@JhaSourav07 ready for review/merge when you get a chance, thanks!

@github-actions

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 3694.34 KB 3694.34 KB 0 B
Total CSS 296.06 KB 296.06 KB 0 B

@Aamod-Dev Aamod-Dev added GSSoC 2026 mentor:Aamod007 level:intermediate Moderate complexity tasks quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. feature A completely new feature or major addition to the project. labels Jun 21, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a great feature! The compact=true parameter gives users much-needed flexibility for integrating the streak card in tighter layouts like repository README sidebars. Bypassing the expensive isometric tower computation in generateSVG when params.compact is true is also a smart performance optimization. Approved!

@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Jun 21, 2026
@JhaSourav07 JhaSourav07 merged commit b4a71de into JhaSourav07:main Jun 21, 2026
10 of 11 checks passed
@github-actions github-actions Bot added this to the GSSoC 2026 milestone Jun 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Congratulations @vbarik317-droid! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

@github-actions github-actions Bot added the type:feature New features, additions, or enhancements label Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A completely new feature or major addition to the project. gssoc:approved PR has been reviewed and accepted for valid contribution points GSSoC 2026 level:intermediate Moderate complexity tasks mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:feature New features, additions, or enhancements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add compact=true param to render a smaller single-row version of the streak card

3 participants