feat: added lots of ui

This commit is contained in:
Daniel Ledda
2021-08-29 22:53:15 +02:00
parent a5f5169e62
commit cdf6ef754d
22 changed files with 384 additions and 49 deletions

View File

@@ -12,8 +12,21 @@ type IRenderAttributes<
export default abstract class UINode {
protected node: HTMLElement | null = null;
protected parent: HTMLElement | null = null;
constructor(options: UINodeOptions) {
constructor(options: UINodeOptions) {}
render(): void {
const oldNode = this.node;
this.node = this.rebuild();
if (oldNode) {
if (!this.parent) {
this.parent = oldNode.parentElement;
}
this.parent!.replaceChild(this.node, oldNode);
} else {
this.parent!.appendChild(this.node);
}
}
abstract rebuild(): HTMLElement;