feat(ui): add reusable copy-to-clipboard component with success anima…#2884
Open
Honey-pg wants to merge 2 commits into
Open
feat(ui): add reusable copy-to-clipboard component with success anima…#2884Honey-pg wants to merge 2 commits into
Honey-pg wants to merge 2 commits into
Conversation
…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.
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
What Changed
src/lib/copy-to-clipboard.ts— shared clipboard API withexecCommandfallbacksrc/hooks/useCopyToClipboard.ts— copied state (2.5s reset), optional toast, per-id tracking,onSuccesscallbacksrc/components/CopyToClipboardButton.tsx— reusable button with Copy/Check icons,aria-live, and optionalshowToastsrc/components/CopyLinkButton.tsx— thin wrapper preserving existingurlprop APIShareProfileButton, dashboard settings page,WeeklySummaryCard,StreakTracker,GoalTracker,BadgeSection,ExportPanel,ResumePreview,RoastHypeWidgettest/copy-to-clipboard.test.ts— utility + hook testsHow to Test
npm test test/copy-to-clipboard.test.ts/dashboard→ click Share Profile in the header — confirm checkmark + "Copied" for ~2.5s (toast optional)/u/[username]Copy link — same feedback patternExpected result: Every copy action shows a checkmark animation and temporary success state. Optional toasts appear only where
showToastis 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).
Checklist
console.log, debug code, or commented-out blocksnpm run lintpasses locallynpm run type-check) — pre-existing failure: missing@google/generative-aiin unrelated fileAccessibility (UI changes only)
Buttoncomponentvar(--success)aria-live="polite", dynamicaria-labelon copy/copiedAdditional Context
CopyLinkButtonAPI is unchanged for existing consumers (ShareProfileSection, public profile page).showToastprop, defaultfalse); enabled where they existed before (profile share, settings, streak copy).useCopyToClipboardsupports per-item tracking viacopy(text, id)for list UIs like goal share links.