import { createElement } from "../lib/skeleton/index.js"; import rxjs from "../lib/rx.js"; class Loader extends window.HTMLElement { constructor() { super(); this.timeout = window.setTimeout(() => { this.innerHTML = this.render({ inline: this.hasAttribute("inlined"), }); }, parseInt(this.getAttribute("delay") || "0")); } disconnectedCallback() { window.clearTimeout(this.timeout); } render({ inline }) { const fixedCss = ` position: fixed; left: 0; right: 0; top: calc(50% - 200px);`; return `
`; } } customElements.define("component-loader", Loader); export default createElement(""); export function toggle($node, show = false) { if (show === true) return rxjs.tap(() => $node.appendChild(createElement(""))); else return rxjs.tap(() => $node.querySelector("component-loader")?.remove()); }