From 8e02edf8ce7ec9f34b554e74b6f6e53b238d481c Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Fri, 6 Jan 2023 19:02:07 -0800 Subject: [PATCH] Add a demo test page for the main readme-example. The demo isn't perfect, since it's compiled before being served, but it's a start. --- script/dev.js | 1 + src/demo/readme-examples/main.html | 1 + src/demo/readme-examples/main.ts | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 src/demo/readme-examples/main.html create mode 100644 src/demo/readme-examples/main.ts diff --git a/script/dev.js b/script/dev.js index cf88fdd..68d566e 100644 --- a/script/dev.js +++ b/script/dev.js @@ -5,5 +5,6 @@ barelyServe({ outDir: "./.temp/dev", esbuildOptions: { target: "es5", + splitting: false, }, }); diff --git a/src/demo/readme-examples/main.html b/src/demo/readme-examples/main.html new file mode 100644 index 0000000..f586ba3 --- /dev/null +++ b/src/demo/readme-examples/main.html @@ -0,0 +1 @@ + diff --git a/src/demo/readme-examples/main.ts b/src/demo/readme-examples/main.ts new file mode 100644 index 0000000..edff25f --- /dev/null +++ b/src/demo/readme-examples/main.ts @@ -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); +});