Skip to content

feat(customize): add dark/light preview background toggle for contribution graph - #8308

Open
armanpanigrahi59 wants to merge 1 commit into
JhaSourav07:mainfrom
armanpanigrahi59:feat/dark-light-toggle-preview-2425
Open

feat(customize): add dark/light preview background toggle for contribution graph#8308
armanpanigrahi59 wants to merge 1 commit into
JhaSourav07:mainfrom
armanpanigrahi59:feat/dark-light-toggle-preview-2425

Conversation

@armanpanigrahi59

Copy link
Copy Markdown
Contributor

Add a Sun/Moon toggle button to the Live Preview section of the contribution graph embed preview page (/customize). Clicking the button switches the preview container background between GitHub dark (#0d1117) and GitHub light (#ffffff), letting users instantly visualise how their isometric SVG embed will appear in both dark and light README contexts.

Key design decisions:

  • Toggle state (previewBg) is intentionally local (useState) and is never synced to URL params, so it has zero effect on the export snippet or the API request.
  • The preview container background is driven by Tailwind utility classes chosen to match the exact GitHub README background colours.
  • Sun icon shows when the page is in dark-preview mode (click → switch to light); Moon icon shows in light-preview mode (click → switch to dark).
  • Button carries a descriptive �ria-label and itle that update together with the icon and label text.
  • All i18n keys are added to all 9 locale files (en, de, es, fr, hi, ja, ko, pt, zh); locale parity tests pass.

Tests added (page.preview-bg-toggle.test.tsx, 7 cases):

  1. Toggle button renders on page load.
  2. Preview container initialises with data-preview-bg=dark.
  3. First click switches container to data-preview-bg=light.
  4. After switching to light, button shows Dark label.
  5. Second click toggles back to data-preview-bg=dark.
  6. Export snippet URL is not polluted by the toggle state.
  7. history.replaceState is not called when toggling.

Fixes: #2425

Description

Fixes # (issue number)

Pillar

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

Visual Preview

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).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@retenta-bot

retenta-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

This PR adds a valuable feature that enhances the user interface by allowing users to preview their contributions in both dark and light modes. It aligns well with our previous decision to improve the customization options in the studio, similar to the 'Copy SVG' button feature. Great job on ensuring comprehensive test coverage as well! Looking forward to your contributions. 😊

@retenta-bot retenta-bot Bot changed the title feat(customize): add dark/light preview background toggle (#2425) feat(customize): add dark/light preview background toggle for contribution graph Jul 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

Asset PR Size Base Size Difference Status
static/chunks/6247-[hash].js 36.23 KB 35.85 KB +0.37 KB (+1.04%) 🔴 Regression
static/chunks/app/customize/page-[hash].js 22.26 KB 21.80 KB +0.47 KB (+2.14%) 🔴 Regression

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 4056.51 KB 4052.50 KB +4.01 KB (+0.10%)
Total CSS 338.94 KB 338.94 KB 0 B

…7#2425)

Add a Sun/Moon toggle button to the Live Preview section of the
contribution graph embed preview page (/customize). Clicking the button
switches the preview container background between GitHub dark (#0d1117)
and GitHub light (#ffffff), letting users instantly visualise how their
isometric SVG embed will appear in both dark and light README contexts.

Key design decisions:
- Toggle state (previewBg) is intentionally local (useState) and is
  never synced to URL params, so it has zero effect on the export
  snippet or the API request.
- The preview container background is driven by Tailwind utility classes
  chosen to match the exact GitHub README background colours.
- Sun icon shows when the page is in dark-preview mode (click → switch
  to light); Moon icon shows in light-preview mode (click → switch to
  dark).
- Button carries a descriptive �ria-label and 	itle that update
  together with the icon and label text.
- All i18n keys are added to all 9 locale files (en, de, es, fr, hi,
  ja, ko, pt, zh); locale parity tests pass.

Tests added (page.preview-bg-toggle.test.tsx, 7 cases):
1. Toggle button renders on page load.
2. Preview container initialises with data-preview-bg=dark.
3. First click switches container to data-preview-bg=light.
4. After switching to light, button shows Dark label.
5. Second click toggles back to data-preview-bg=dark.
6. Export snippet URL is not polluted by the toggle state.
7. history.replaceState is not called when toggling.

Fixes: JhaSourav07#2425
@armanpanigrahi59
armanpanigrahi59 force-pushed the feat/dark-light-toggle-preview-2425 branch from 889962c to 028846c Compare July 24, 2026 14:32
@Aamod007 Aamod007 added level:intermediate Moderate complexity tasks quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. mentor:Aamod007 type:feature New features, additions, or enhancements type:testing Adding, updating, or fixing tests labels Jul 27, 2026

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

Dark/light preview background toggle for the contribution graph customizer — spans 11 files including locale updates. CI failing, please fix.

Labels: level:intermediate (11 files but mostly locale strings), quality:clean, type:feature, type:testing, mentor:Aamod007

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

Re-reviewing after noting the only CI failure is Vercel authorization (not code-related). All other checks (Format · Lint · Typecheck · Test, Production Build, CodeQL) pass. Approving — the Vercel deploy auth is a repo-level config issue, not a code problem.

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

Labels

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 type:testing Adding, updating, or fixing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add dark/light mode toggle for the contribution graph embed preview page

2 participants