Skip to content

feature(share): add svg download option to share sheet#108

Merged
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
guptakaran20:feat/download-svg-button
May 16, 2026
Merged

feature(share): add svg download option to share sheet#108
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
guptakaran20:feat/download-svg-button

Conversation

@guptakaran20

Copy link
Copy Markdown
Contributor

Description

Fixes #52

Added a "Download SVG" option to the ShareSheet in the dashboard.

Users can now download the full-commit PNG. It fetches the SVG from the current endpoint /api/streak?user=${username}, converts to image/svg+xml, and forces a browser download of the filename [username]-commitpulse.svg.

The new functionality is added next to the current "Copy Markdown" functionality keeping in line with the existing Tailwind CSS Styles.

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

Screenshot 2026-05-15 212039 Screenshot 2026-05-15 212108

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).

Copilot AI review requested due to automatic review settings May 15, 2026 15:54
@vercel

vercel Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an SVG download action to the dashboard ShareSheet so users can save their generated CommitPulse badge locally, addressing #52.

Changes:

  • Added a “Download SVG” share option that fetches /api/streak?user=... and triggers a .svg download.
  • Added (or surfaced) a “Copy Markdown” option in the ShareSheet options list alongside existing share/download actions.
Comments suppressed due to low confidence (3)

components/dashboard/ShareSheet.tsx:125

  • The fetch URL interpolates username directly into the query string. If the username contains reserved characters (e.g. &, ?, #, spaces), it can break the request or inject extra query params (e.g. octo&refresh=true). Use encodeURIComponent(username) (or URLSearchParams) when building /api/streak?user=....
      const response = await fetch(`/api/streak?user=${username}`);
      if (!response.ok) throw new Error('Failed to fetch SVG');
      const svgText = await response.text();

components/dashboard/ShareSheet.tsx:134

  • After setting the SVG option state to success, the UI’s success label logic only special-cases copy, png, and json. As a result, the SVG action won’t show any distinct success feedback (it will keep displaying the default label). Update the success-label mapping to include the svg key (e.g. show “SVG Downloaded!”) to match the other download actions.
      URL.revokeObjectURL(url);
      setOptionState('svg', 'success');
    } catch {

components/dashboard/ShareSheet.tsx:238

  • The new “Copy Markdown” option uses the FileJson icon, which is the same icon used for “Download JSON” and is misleading for a markdown snippet action. Use a more appropriate icon (e.g. link/code/clipboard) so users can distinguish the actions.
      key: 'markdown',
      icon: FileJson,
      label: 'Copy Markdown',
      description: 'Copy markdown snippet for your README',

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +120 to +137
const handleDownloadSVG = async () => {
setOptionState('svg', 'loading');
try {
const response = await fetch(`/api/streak?user=${username}`);
if (!response.ok) throw new Error('Failed to fetch SVG');
const svgText = await response.text();
const blob = new Blob([svgText], { type: 'image/svg+xml' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.download = `${username}-commitpulse.svg`;
link.href = url;
link.click();
URL.revokeObjectURL(url);
setOptionState('svg', 'success');
} catch {
setOptionState('svg', 'error');
}
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Implemented all review suggestions:

  • Username encoded in SVG fetch URL
  • Added success-state feedback for the SVG image
  • Changed the markdown action icon to another one
  • Added SVG download test along with ShareSheet tests already available

I maintained my pull request as a single commit only.

@guptakaran20
guptakaran20 force-pushed the feat/download-svg-button branch from 9f8c1e6 to 1f3692d Compare May 15, 2026 16:18
@guptakaran20
guptakaran20 force-pushed the feat/download-svg-button branch from 1f3692d to 7bcb947 Compare May 15, 2026 16:25
@JhaSourav07

Copy link
Copy Markdown
Owner

@harxhe
can you review this PR?

@harxhe harxhe 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.

good to go

@vercel

vercel Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
commitpulse Ready Ready Preview, Comment May 16, 2026 9:53am

@JhaSourav07
JhaSourav07 merged commit 3d5001b into JhaSourav07:main May 16, 2026
4 checks passed
@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label May 16, 2026
@JhaSourav07

Copy link
Copy Markdown
Owner

Thanks for contributing to CommitPulse 🚀

To make collaboration, PR reviews, issue coordination, and future contributions smoother, we highly recommend joining the CommitPulse Discord community:

https://discord.gg/Cb73bS79j

Inside the server you can:
⚡ discuss implementations with contributors
🛠️ get faster support for setup/issues
🔍 request PR reviews easily
🧠 get guidance and mentorship from assigned mentors
🚀 stay updated with active development discussions

Most contributor coordination happens there, so joining will make the contribution experience much smoother 💜

@JhaSourav07 JhaSourav07 added this to the GSSoC 2026 milestone May 17, 2026
@github-actions github-actions Bot added the type:feature New features, additions, or enhancements label May 24, 2026
@JhaSourav07 JhaSourav07 added gssoc:approved PR has been reviewed and accepted for valid contribution points and removed gssoc:approved PR has been reviewed and accepted for valid contribution points labels Jun 17, 2026
MasterJi27 pushed a commit to MasterJi27/commitpulse that referenced this pull request Jul 4, 2026
## Description

Fixes JhaSourav07#52

Added a **"Download SVG"** option to the ShareSheet in the dashboard. 

Users can now download the full-commit PNG. It fetches the SVG from the
current endpoint `/api/streak?user=${username}`, converts to
`image/svg+xml`, and forces a browser download of the filename
`[username]-commitpulse.svg`.

The new functionality is added next to the current "Copy Markdown"
functionality keeping in line with the existing Tailwind CSS Styles.


## Pillar

* [ ] 🎨 Pillar 1 — New Theme Design
* [ ] 📐 Pillar 2 — Geometric SVG Improvement
* [ ] 🕐 Pillar 3 — Timezone Logic Optimization
* [x] 🛠️ Other (Bug fix, refactoring, docs)

## Visual Preview

<img width="1896" height="870" alt="Screenshot 2026-05-15 212039"
src="https://github.com/user-attachments/assets/95a63df4-289a-429a-a177-b5fe8473f5ea"
/>
<img width="808" height="100" alt="Screenshot 2026-05-15 212108"
src="https://github.com/user-attachments/assets/936165e7-05ca-4ebb-acf0-1ba0dc25c38a"
/>

## Checklist before requesting a review:

* [x] I have read the `CONTRIBUTING.md` file.
* [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
* [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors (CI will fail otherwise).
* [x] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
* [x] I have updated `README.md` if I added a new theme or URL
parameter.
* [x] I have started the repo.
* [x] I have made sure that i have only one commit to merge in this PR.
* [x] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points GSSoC 2026 level:intermediate Moderate complexity tasks mentor:harxhe type:feature New features, additions, or enhancements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add "Download as SVG" Button to Dashboard

4 participants