Skip to content

feat: add public profile QR code sharing with image download#1821

Open
Pranav-chaudhari-2006 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
Pranav-chaudhari-2006:feat/profile-qr-sharing
Open

feat: add public profile QR code sharing with image download#1821
Pranav-chaudhari-2006 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
Pranav-chaudhari-2006:feat/profile-qr-sharing

Conversation

@Pranav-chaudhari-2006
Copy link
Copy Markdown
Contributor

📱 Public Profile QR Code Sharing with High-Res Download

A premium, highly accessible in-person sharing solution for DevTrack public profiles. This feature enables users to generate a scannable, downloadable QR code of their public profile directly from the sharing section.


✨ Features Implemented

  • Premium Glassmorphism Design: A modern, blur-backed modal (backdrop-blur-sm bg-black/60) utilizing Lucide Icons and smooth micro-animations (zoom-in-95 animate-in) that match the premium visual language of DevTrack.
  • 100% Scan Reliability: Features a high-contrast white container wrapper around the QR code, ensuring flawless scanning by mobile cameras under both light and dark mode configurations.
  • Direct Image Export: Includes a one-click "Download QR Code" button that exports the high-resolution QR canvas directly as a PNG file (<username>-devtrack-qr.png).
  • Excellent UX & Scroll Management: Incorporates scroll locking (overflow = "hidden") when the modal is active and supports flexible dismiss mechanisms (backdrop click, explicit "X" button, or pressing the Escape key).
  • Supabase Offline Fallback: Includes a dynamic front-end mock preview that automatically boots a beautiful dummy page if Supabase is offline/disconnected. You can preview it immediately by visiting http://localhost:3000/u/<any_name>.

📂 Codebase Changes

Components & Views

  • [NEW] ProfileQrModal.tsx: High-fidelity canvas-based QR Modal featuring download capability, esc-key capture, scroll management, and clean transitions.
  • [MODIFY] ShareProfileSection.tsx: Integrates the "QR Code" control button alongside existing platforms, handling visibility states.
  • [MODIFY] page.tsx: Introduces a frontend mock fallback if Supabase client environment variables are unavailable, ensuring zero local preview blockages.

Testing Setup

  • [NEW] ProfileQrModal.test.tsx: Comprehensive testing suite evaluating conditional rendering, scroll-locking, multiple dismissal listeners (Esc/click outside), and download logic.

Video Reference

devtrack.QR.code.added.mp4

🧪 Quality Verification

All validation and code quality checks have been successfully run locally:

1. Unit & Integration Tests

We implemented a complete test suite covering visibility, scroll lock, dismiss actions, and downloads.

  • Test File: test/components/ProfileQrModal.test.tsx
  • Command:
    npx vitest run test/components/ProfileQrModal.test.tsx
    

Result: PASS (7/7 tests succeeded)

✓ test/components/ProfileQrModal.test.tsx (7)
✓ ProfileQrModal (7)
✓ does not render when isOpen is false
✓ renders modal content when isOpen is true
✓ calls onClose when Close button is clicked
✓ calls onClose when backdrop is clicked
✓ calls onClose when Escape key is pressed
✓ locks and unlocks body scroll appropriately
✓ triggers download of QR code when download button is clicked


2. TypeScript Compilation

No syntax, dependency, or structural type warnings were reported.

Command:
bash
npm run type-check

Result: Success (0 errors)


3. Production Build Validation

A clean, optimized production build was run to verify server-side rendering, routing structure, and PWA configurations.

Command:

bash
Remove-Item -Recurse -Force .next; npm run build

Result: Success (Compiled successfully)

Copilot AI review requested due to automatic review settings June 1, 2026 08:28
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

@Pranav-chaudhari-2006 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.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts) labels Jun 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a QR-code sharing flow for public profile URLs and introduces a modal UI to display/download the QR code, along with accompanying component tests and a local preview fallback for profile data.

Changes:

  • Add ProfileQrModal component that renders a QR code and supports download/close interactions.
  • Add a “QR Code” action to ShareProfileSection that opens the modal.
  • Add tests for ProfileQrModal; add qrcode.react dependency; add a mock profile fallback on public profile page fetch failure.

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/components/ProfileQrModal.test.tsx Adds interaction tests for the new QR modal (rendering, closing, download).
src/components/ShareProfileSection.tsx Adds QR Code button and state to open/close ProfileQrModal.
src/components/ProfileQrModal.tsx Implements the QR modal UI, body scroll locking, and QR download behavior.
src/app/u/[username]/page.tsx Wraps profile/session fetches with catch and adds a mock profile fallback for local preview.
package.json Adds qrcode.react dependency required by the new modal.
Comments suppressed due to low confidence (1)

test/components/ProfileQrModal.test.tsx:1

  • Two issues here: (1) if the test fails before line 127, toDataURL may never be restored, leaking state into other tests—prefer vi.spyOn(HTMLCanvasElement.prototype, \"toDataURL\") with automatic restoration or use try/finally. (2) inside the createElement spy, calling document.createElement(tagName) re-enters the mocked function and can recurse if invoked; capture the original implementation before spying and call that for non-a tags.
import React from "react";

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

Comment on lines +83 to +90
let [profile, loggedInUsername] = await Promise.all([
fetchPublicProfile(username, { includeAchievements: true }).catch(() => null),
getLoggedInGitHubUsername().catch(() => null),
]);

// Temporary mock fallback for local front-end preview when Supabase is not connected
if (!profile) {
profile = {

const profileUrl = getProfileUrl(username);

if (!profile) {
Comment on lines +22 to +23
useEffect(() => {
if (!isOpen) return;
Comment on lines +31 to +39
document.addEventListener("keydown", handleKeyDown);
// Lock background scrolling when modal is open
document.body.style.overflow = "hidden";

return () => {
document.removeEventListener("keydown", handleKeyDown);
document.body.style.overflow = "unset";
};
}, [isOpen, onClose]);
Comment on lines +103 to +105
<QRCodeCanvas
id="profile-qr-canvas"
value={profileUrl}
Comment on lines +70 to +76
<div
ref={modalRef}
role="dialog"
aria-modal="true"
aria-labelledby="qr-modal-title"
className="relative w-full max-w-sm transform overflow-hidden rounded-2xl border border-[var(--border)] bg-[var(--card)] p-6 shadow-2xl transition-all animate-in zoom-in-95 duration-200 text-center"
>
Comment thread test/components/ProfileQrModal.test.tsx Outdated
Comment on lines +62 to +65
const backdrop = screen.getByRole("dialog").previousSibling;
if (backdrop) {
fireEvent.click(backdrop);
}
Comment thread test/components/ProfileQrModal.test.tsx Outdated
Comment on lines +126 to +127
// Clean up prototypes
HTMLCanvasElement.prototype.toDataURL = originalToDataURL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants