Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9955d09

Browse files
authored
Merge pull request #25 from github/demo
Improve demo page
2 parents 230556d + cfe43b7 commit 9955d09

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

examples/index.html

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22
<html>
33
<head>
44
<title>Clipboard copy examples</title>
5-
<script src="../dist/index.umd.js"></script>
5+
<script src="https://unpkg.com/@github/clipboard-copy-element@latest" defer></script>
6+
<!-- <script src="../dist/index.umd.js" defer></script> -->
67
<style>
78
clipboard-copy {
8-
border: 2px solid black;
9-
cursor: default;
9+
-webkit-appearance: button;
10+
-moz-appearance: button;
11+
padding: 0.2em 0.6em;
12+
font: 11px system-ui, sans-serif;
13+
display: inline-block;
1014
}
15+
.textarea { margin-top: 30px; display: block; }
1116
</style>
1217
<script>
13-
document.addEventListener('clipboard-copy', function() {
14-
const notice = document.getElementById('notice')
18+
document.addEventListener('clipboard-copy', function(event) {
19+
const notice = event.target.querySelector('.notice')
1520
notice.hidden = false
1621
setTimeout(function() {
1722
notice.hidden = true
@@ -20,17 +25,28 @@
2025
</script>
2126
</head>
2227
<body>
23-
<h2>Attribute</h2>
24-
<clipboard-copy value="@hubot">Copy</clipboard-copy>
28+
<h1>Demo</h1>
29+
<p>Copy from <code>value</code> attribute:</p>
30+
<clipboard-copy value="@hubot copied form [value]">
31+
Copy
32+
<span class="notice" hidden>Copied!</span>
33+
</clipboard-copy>
2534

26-
<h2>Element content</h2>
27-
<clipboard-copy for="name">Copy</clipboard-copy>
28-
<div id="name">Hubot</div>
35+
<p>Copy from an element specified by the <code>for</code> attribute:</p>
36+
<clipboard-copy for="name">
37+
Copy
38+
<span class="notice" hidden>Copied!</span>
39+
</clipboard-copy>
40+
<div id="name">@hubot copied form &lt;div&gt;</div>
2941

30-
<h2>Form input</h2>
31-
<clipboard-copy for="login">Copy</clipboard-copy>
32-
<input id="login" value="@hubot">
42+
<p>Copy from an input element specified by the <code>for</code> attribute:</p>
43+
<clipboard-copy for="login">
44+
Copy
45+
<span class="notice" hidden>Copied!</div><span>
46+
</clipboard-copy>
47+
<input id="login" value="@hubot copied form &lt;input&gt;" size="40">
3348

34-
<div id="notice" hidden>Copied to clipboard</div>
49+
<textarea class="textarea" rows="10" cols="50">Paste here.
50+
</textarea>
3551
</body>
3652
</html>

0 commit comments

Comments
 (0)