Skip to content

Commit

Permalink
[example] add announcement of text being copied
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus committed Oct 23, 2023
1 parent a043058 commit bd69de3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
<script>
document.addEventListener('clipboard-copy', function (event) {
const notice = event.target.querySelector('.notice')
announce.setAttribute('aria-label', 'Copied');
notice.hidden = false
setTimeout(function () {
announce.setAttribute('aria-label', '');
notice.hidden = true
}, 1000)
})
Expand All @@ -45,6 +47,7 @@
<body>
<main aria-labelledby="h">
<h1 id="h">Demo</h1>
<div aria-live="polite" id="announce"></div>
<section>
<p>Copy from <code>value</code> attribute:</p>
<clipboard-copy value="@hubot copied from [value]">
Expand Down

0 comments on commit bd69de3

Please sign in to comment.