add loader section component
Signed-off-by: Tobias Erbshäußer <tobias@tesoft.dev>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<template id="tesoft-loader-section-template">
|
||||
<style>
|
||||
@import "/src/styles/default.css";
|
||||
|
||||
:host {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
:host > div {
|
||||
align-items: center;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: 1fr;
|
||||
justify-items: center;
|
||||
}
|
||||
|
||||
:host([loaded]) > div {
|
||||
align-self: start;
|
||||
}
|
||||
|
||||
:host(:not([loaded])) slot {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:host([loaded]) tesoft-loader {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<tesoft-loader></tesoft-loader>
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script src="/src/components/loader-section.ts" type="module"></script>
|
||||
{% includeOnce 'components/loader.njk' %}
|
||||
@@ -0,0 +1,23 @@
|
||||
import {TesoftComponent} from "../scripts/main.ts";
|
||||
|
||||
export class TesoftLoaderSection extends TesoftComponent {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
const template = document.getElementById("tesoft-loader-section-template") as HTMLTemplateElement;
|
||||
const templateContent = template.content;
|
||||
|
||||
const shadowRoot = this.attachShadow({mode: "open"});
|
||||
shadowRoot.appendChild(templateContent.cloneNode(true));
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.removeAttribute("loaded");
|
||||
}
|
||||
|
||||
finish() {
|
||||
this.setAttribute("loaded", "");
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("tesoft-loader-section", TesoftLoaderSection);
|
||||
Reference in New Issue
Block a user