Skip to content

feat(CopyButton): inline copy-to-clipboard button with success flash - #397

Open
ebellamy-bh wants to merge 2 commits into
mainfrom
feat/copy-button
Open

feat(CopyButton): inline copy-to-clipboard button with success flash#397
ebellamy-bh wants to merge 2 commits into
mainfrom
feat/copy-button

Conversation

@ebellamy-bh

Copy link
Copy Markdown

Ports waggleline's row-level copy affordance into the design system — the inline copy-to-clipboard button the library has been missing next to IDs, emails, phone numbers, and API keys.

What it does

  • Writes value to the clipboard and flashes a success check (copiedLabel, configurable timeout), then reverts
  • Stops propagation and prevents default, so it is safe inside clickable rows, links, and grid cells
  • Silent when clipboard access is denied; onCopied callback for toasts/analytics
  • Per-instance state — drop any number into a table

Screenshots

Detail fields with the email just copied (success check showing):

Light Dark
CopyButton light CopyButton dark

Provenance

Port of waggleline/app/imports/ui/components/CopyButton.tsx; FontAwesome → lucide Copy/Check, hardcoded grays → semantic tokens, plus a success-token flash, configurable labels, and an onCopied hook.

Testing

  • 4 unit tests (copy + flash + revert under fake timers, custom labels, propagation stop, denied clipboard)
  • 2 stories (inline usage, detail-field rows)
  • typecheck / lint / format / rtl:scan clean; combined batch suite 651/651

Ported from waggleline's row-level copy affordance: stops propagation
so it is safe inside clickable rows, flashes a success check with
configurable labels/timeout, and stays silent when clipboard access is
denied. FontAwesome icons become lucide Copy/Check on semantic tokens.
Copilot AI lite review requested due to automatic review settings August 23, 2026 04:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new inline CopyButton component to the design system for row-level “copy to clipboard” affordances (IDs/emails/keys), and wires it into the library’s public exports and build entries.

Changes:

  • Introduces CopyButton (inline icon button) that writes a provided value to the clipboard and briefly flashes a success state.
  • Adds unit tests and Storybook stories for the new component.
  • Exports the component from the package entrypoints and registers it in tsup for bundling.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tsup.config.ts Adds a new tsup entrypoint for components/CopyButton.
src/index.ts Re-exports CopyButton from the library root.
src/components/CopyButton/index.ts Adds the component barrel export.
src/components/CopyButton/CopyButton.tsx Implements the new copy-to-clipboard icon button.
src/components/CopyButton/CopyButton.test.tsx Adds unit tests for copy/flash/revert/propagation/denied clipboard.
src/components/CopyButton/CopyButton.stories.tsx Adds Storybook stories for inline and detail-field usage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/components/CopyButton/CopyButton.test.tsx
Comment thread src/components/CopyButton/CopyButton.tsx
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 23, 2026

Copy link
Copy Markdown

Deploying ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: e66bebe
Status: ✅  Deploy successful!
Preview URL: https://85350427.ui-6d0.pages.dev
Branch Preview URL: https://feat-copy-button.ui-6d0.pages.dev

View logs

…icit displayName

- Tests stub navigator via vi.stubGlobal + vi.unstubAllGlobals (SuperChat
  pattern) instead of mutating the real global
- Explicit CopyButton.displayName for DevTools parity with the library's
  forwardRef components
Copilot AI review requested due to automatic review settings August 23, 2026 04:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

src/components/CopyButton/CopyButton.tsx:91

  • {...props} is spread after type, title, and aria-label, so callers can accidentally override these (e.g. type="submit" inside a form, or a fixed aria-label that never updates to "Copied"). Since this component intentionally forces type="button" and manages its own accessible label, spread props earlier so the component-controlled attributes always win.
          className
        )}
        {...props}
      >
        {copied ? (

src/components/CopyButton/CopyButton.tsx:34

  • The docstring says “Stateless across instances”, but the component has internal state (copied) and a timer; what you likely mean is that state is isolated per instance. Wording this accurately avoids confusion for consumers.
 * An inline copy-to-clipboard icon button with a brief success check.
 * Stateless across instances — safe to drop into table rows, ID chips,
 * and detail fields.

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.

2 participants