Skip to content

feat(ui): add reusable copy-to-clipboard component with success anima…#2884

Open
Honey-pg wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
Honey-pg:feat/copy-to-clipboard
Open

feat(ui): add reusable copy-to-clipboard component with success anima…#2884
Honey-pg wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
Honey-pg:feat/copy-to-clipboard

Conversation

@Honey-pg

Copy link
Copy Markdown
Contributor

Introduce shared clipboard utility, hook, and CopyToClipboardButton with checkmark feedback and a 2.5s Copied state. Migrate existing copy actions across profile sharing, settings, goals, streaks, and career tools.

Summary

Adds a reusable copy-to-clipboard system with consistent visual feedback (Copy → checkmark animation + temporary "Copied!" state). Replaces 10+ ad-hoc clipboard implementations across the app so profile links, share actions, and content copies behave the same way.

Closes #1937


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📝 Documentation update
  • ♻️ Refactor / code cleanup (no functional change)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🧪 Tests only

What Changed

  • Added src/lib/copy-to-clipboard.ts — shared clipboard API with execCommand fallback
  • Added src/hooks/useCopyToClipboard.ts — copied state (2.5s reset), optional toast, per-id tracking, onSuccess callback
  • Added src/components/CopyToClipboardButton.tsx — reusable button with Copy/Check icons, aria-live, and optional showToast
  • Refactored src/components/CopyLinkButton.tsx — thin wrapper preserving existing url prop API
  • Migrated copy actions in: ShareProfileButton, dashboard settings page, WeeklySummaryCard, StreakTracker, GoalTracker, BadgeSection, ExportPanel, ResumePreview, RoastHypeWidget
  • Added test/copy-to-clipboard.test.ts — utility + hook tests

How to Test

  1. Run unit tests: npm test test/copy-to-clipboard.test.ts
  2. Open /dashboard → click Share Profile in the header — confirm checkmark + "Copied" for ~2.5s (toast optional)
  3. Visit Settings → public profile URL Copy, and a public profile /u/[username] Copy link — same feedback pattern
  4. Test other migrated surfaces: goal share link, streak copy button, AI summary copy, roast/hype output copy, resume export copy

Expected result: Every copy action shows a checkmark animation and temporary success state. Optional toasts appear only where showToast is enabled (e.g. profile share, settings, streak stats). No duplicate or inconsistent "Copied" UI.


Screenshots / Recordings

Recommended: short screen recording of Share Profile → Copied state, and one icon-only copy (e.g. streak or AI summary).

Before After
Mixed copy feedback (text-only, icons, toasts, inconsistent timing) Unified Copy → Check animation + 2.5s "Copied!" state

Checklist

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check) — pre-existing failure: missing @google/generative-ai in unrelated file
  • Added or updated tests where applicable
  • Updated documentation / comments if behavior changed

Accessibility (UI changes only)

  • Keyboard navigation works correctly — uses standard Button component
  • Color contrast meets WCAG AA standard — success state uses var(--success)
  • ARIA labels / roles added where needed — aria-live="polite", dynamic aria-label on copy/copied
  • Tested on mobile / responsive layout

Additional Context

  • CopyLinkButton API is unchanged for existing consumers (ShareProfileSection, public profile page).
  • Toast notifications are optional (showToast prop, default false); enabled where they existed before (profile share, settings, streak copy).
  • useCopyToClipboard supports per-item tracking via copy(text, id) for list UIs like goal share links.

…tion

Introduce shared clipboard utility, hook, and CopyToClipboardButton with
checkmark feedback and a 2.5s Copied state. Migrate existing copy actions
across profile sharing, settings, goals, streaks, and career tools.
@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts) type:bug GSSoC type bonus: bug fix type:performance GSSoC type bonus: performance (+15 pts) and removed gssoc26 GSSoC 2026 contribution labels Jun 28, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the gssoc26 GSSoC 2026 contribution label Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "Copy Success" Visual Feedback Animation to All Copy Actions

1 participant