Skip to content

feat: add Copied! confirmation with check icon and i18n to CopyButton - #20

Merged
Meshmulla merged 4 commits into
stellar-kracken:mainfrom
vrickish:vrick_fix_fe_#2
Jul 16, 2026
Merged

feat: add Copied! confirmation with check icon and i18n to CopyButton#20
Meshmulla merged 4 commits into
stellar-kracken:mainfrom
vrickish:vrick_fix_fe_#2

Conversation

@vrickish

Copy link
Copy Markdown
Contributor

Closes #2

What does this PR do?

Adds a visible "Copied!" confirmation to the CopyButton component so users get clear feedback when content is copied to the clipboard.

Changes

src/components/CopyButton.tsx — When a copy succeeds, a green CheckIcon (HeroIcons) appears next to the label, the text turns green, and the button's aria-label updates dynamically (e.g. "Copy - Copied!") for screen readers. Labels now fall back to react-i18next translated strings (copyButton.copy, copyButton.copied, copyButton.failed) when not explicitly provided via props.

src/hooks/useCopyToClipboard.ts — Changed default success duration from 2000ms to 1500ms to match the issue spec.

src/i18n/locales/*.json (8 files) — Added a copyButton namespace with copy, copied, and failed keys in all supported languages.

src/components/CopyButton.test.tsx — Extended from 3 to 10 tests, covering: check icon rendering, dynamic aria-label, aria-live screen reader announcement, auto-revert after timeout, rapid repeated clicks without flicker, i18n default labels, and verifying no icon appears on failure.

How was this tested?

Ran vitest run src/components/CopyButton.test.tsx — all 10 tests pass.

Checklist

  • Code conforms to style guidelines
  • Unit tests passed (10/10)
  • No unrelated changes included

@Meshmulla
Meshmulla merged commit cf4284a into stellar-kracken:main Jul 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a "Copied!" confirmation to the CopyButton component

2 participants