1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/javascripts/copy-code.js
Jason Etcovitch efed031ea4 Add copy button to code blocks (#16052)
* Add deps

* Setup copy events

* Updoot

* Tweak styling

* Do a lil' proof-of-concept

* Updoot @github-docs/render-content

* Use SCSS variables for custom styles

* Adjust docs

* Ignore clipboard in check-deps

* Add copy annotation to quickstart workflow sample

Co-authored-by: Cynthia Rich <crichID@users.noreply.github.com>
2020-10-16 10:55:35 -04:00

16 lines
377 B
JavaScript

import Clipboard from 'clipboard'
export default () => {
const clipboard = new Clipboard('button.js-btn-copy')
clipboard.on('success', evt => {
const btn = evt.trigger
const beforeTooltip = btn.getAttribute('aria-label')
btn.setAttribute('aria-label', 'Copied!')
setTimeout(() => {
btn.setAttribute('aria-label', beforeTooltip)
}, 2000)
})
}