forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add copy button to code blocks (github#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>
- Loading branch information
Showing
9 changed files
with
175 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.