Update example

This commit is contained in:
0x1eef 2024-07-10 17:22:17 -03:00
parent 39d5f51ee0
commit bb1d672339

View file

@ -36,27 +36,28 @@ progress bar is removed once the delivery is complete:
```typescript
import postman, { item } from "postman";
document.addEventListener("DOMContentLoaded", () => {
const progressBar = document.querySelector("progress");
const bar = document.querySelector("progress");
const span = document.querySelector(".percentage");
postman(
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) => {
progressBar.value = percent;
bar.value = percent;
span.innerText = `${percent}%`;
})
).deliver()
.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 */
progressBar.remove();
span.remove();
});
).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();
});
});
```