diff --git a/README.md b/README.md index e3d1c74..ad21a65 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ progress bar is removed once the delivery is complete: Postman - +
@@ -31,7 +31,7 @@ progress bar is removed once the delivery is complete: ``` -**postman.js** +**delivery.js** ```typescript import postman, { item } from "postman"; diff --git a/share/postman/examples/progressbar/delivery.js b/share/postman/examples/progressbar/delivery.js new file mode 100644 index 0000000..2d8b8a2 --- /dev/null +++ b/share/postman/examples/progressbar/delivery.js @@ -0,0 +1,25 @@ +import postman, { item } from "postman"; +document.addEventListener("DOMContentLoaded", () => { + const bar = document.querySelector("progress"); + const span = document.querySelector(".percentage"); + const delivery = postman( + item.font("Kanit Regular", "url(/fonts/kanit-regular.ttf)"), + item.script("/js/app.js"), + item.image("/images/app.png"), + item.css("/css/app.css"), + item.progress((percent) => { + bar.value = percent; + span.innerText = `${percent}%`; + }) + ).deliver(); + + delivery.then((package) => { + /* Add page assets */ + package.fonts.forEach((font) => documents.fonts.add(font)); + package.scripts.forEach((script) => document.body.appendChild(script)); + package.css.forEach((css) => document.head.appendChild(css)); + /* Replace progress bar */ + bar.remove(); + span.remove(); + }); +}); diff --git a/share/postman/examples/progressbar/index.html b/share/postman/examples/progressbar/index.html new file mode 100644 index 0000000..c874fbf --- /dev/null +++ b/share/postman/examples/progressbar/index.html @@ -0,0 +1,14 @@ + + + + Postman + + + +
+ + +
+
+ +