Skip to content

Commit

Permalink
Add a demo test page for the main readme-example.
Browse files Browse the repository at this point in the history
The demo isn't perfect, since it's compiled before being served, but it's a start.
  • Loading branch information
lgarron committed Jan 7, 2023
1 parent a904409 commit 8e02edf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions script/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ barelyServe({
outDir: "./.temp/dev",
esbuildOptions: {
target: "es5",
splitting: false,
},
});
1 change: 1 addition & 0 deletions src/demo/readme-examples/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script src="./main.js" href="./main.ts" type="module"></script>
18 changes: 18 additions & 0 deletions src/demo/readme-examples/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as clipboard from "../../clipboard-polyfill/entries/es6/clipboard-polyfill.es6";

function handler() {
clipboard.writeText("This text is plain.").then(
() => {
console.log("success!");
},
() => {
console.log("error!");
},
);
}

window.addEventListener("DOMContentLoaded", function () {
var button = document.body.appendChild(document.createElement("button"));
button.textContent = "Copy";
button.addEventListener("click", handler);
});

0 comments on commit 8e02edf

Please sign in to comment.