Skip to content

feat(ch-copy-button): copy value to clipboard with feedback - #140

Merged
hectorpalmatellez merged 1 commit into
mainfrom
feat/copy-button-137
Nov 28, 2026
Merged

hectorpalmatellez merged 1 commit into
mainfrom
feat/copy-button-137

Conversation

@hectorpalmatellez

Copy link
Copy Markdown
Member

Summary

Closes #137 — ch-copy-button, a clipboard button composed on ch-button.

  • value is written via navigator.clipboard.writeText; empty value disables the button.
  • The default slot is the label; on success copiedLabel (default Copied) + a check icon show for copiedDuration ms (default 2000), then revert.
  • chCopy on success, chCopyError when the clipboard API is missing (insecure context) or the write rejects.
  • variant, size, disabled, label forward to the inner ch-button; icon-only use warns via warnMissingName like ch-button.
  • Surfaces: package export, docs/ai.md (now 40 components), gallery entry, llms.txt + docs-site regenerated.

Test plan

  • pnpm lint, pnpm run format:check
  • pnpm build + wrapper builds
  • pnpm exec vitest run --project components — 333 tests (7 new)
  • pnpm exec vitest run --project browser — includes new spec verifying real slot projection through two shadow roots (mock-doc cannot project a slot assigned to another component's slot)
  • pnpm run generate:gallery && pnpm run generate:llms && pnpm run check:ai

Note: needs a release after merge before check:released passes on main.

Composes ch-button so variant, size, disabled and label behave as
there. The slot content is the label; on a successful clipboard write
the button shows copiedLabel and a check icon for copiedDuration ms,
then reverts. Emits chCopy on success and chCopyError when the
clipboard API is missing (insecure context) or the write rejects.

Slot forwarding through two shadow roots is covered in the browser
project, which mock-doc cannot project.
@hectorpalmatellez
hectorpalmatellez merged commit 1397728 into main Nov 28, 2026
4 checks passed
@hectorpalmatellez
hectorpalmatellez deleted the feat/copy-button-137 branch November 28, 2026 22:50
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.

Agregar componente ch-copy-button

1 participant