Skip to content

implementing copy code buttons throughout the site #157

@ghost

Description

I implemented a copy code button for the CDN links in the Getting Started section a while back, and just sent a PR updating the code to disable the button upon click.

I like the idea of adding buttons to the rest of the code snippets, but unsure of how to go about it, so I wanted to open up a discussion here. By using document.getElementById() for each button we'd end up with a ton of code, so another solution might be using document.getElementsByClassName() with other complexities added.

A few points on design:

  1. I think less intrusive Materialize copy icons + the inserted 'Copied!' text, at the top right corner of the gray code boxes would work best going forward. Without the current teal button, though I think it works for the CDN section.

  2. As a somewhat different example, I also like how the Bootstrap team did theirs - https://getbootstrap.com - just scroll down to the Installation section. We also have tooltips, but they might be a bit much.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions