Skip to content

Update - Extract shared clipboard copy utility across tool components #725

@markmead

Description

@markmead

The write-to-clipboard + button-text-reset pattern is implemented separately in three places:

  • src/components/TypographyMapper.astro (copyTextToClipboard)
  • src/components/DarkModeGenerator.astro
  • src/components/PreviewCopy.astro (approximate)

Each implementation does the same thing: navigator.clipboard.writeText → set "Copied" → setTimeout → reset to "Copy".

Extracting this to a shared ES module (e.g. src/lib/clipboard.ts) would mean any future change to copy behaviour (delay, error feedback, aria-pressed state) only needs to happen once.

The current blocker is that these live inside <script> blocks in Astro components. A shared module import would resolve this cleanly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions