Butchering the UI framework

This commit is contained in:
Pieter Vander Vennet 2021-06-10 01:36:20 +02:00
parent 8d404b1ba9
commit 6415e195d1
90 changed files with 1012 additions and 3101 deletions

View file

@ -1,16 +1,35 @@
import {UIElement} from "../UIElement";
import {UIEventSource} from "../../Logic/UIEventSource";
import BaseUIElement from "../BaseUIElement";
export class VariableUiElement extends UIElement {
private _html: UIEventSource<string>;
export class VariableUiElement extends BaseUIElement {
constructor(html: UIEventSource<string>) {
super(html);
this._html = html;
private _element : HTMLElement;
constructor(contents: UIEventSource<string | BaseUIElement>) {
super();
this._element = document.createElement("span")
const el = this._element
contents.addCallbackAndRun(contents => {
while(el.firstChild){
el.removeChild(
el.lastChild
)
}
if(contents === undefined){
return
}
if(typeof contents === "string"){
el.innerHTML = contents
}else{
el.appendChild(contents.ConstructElement())
}
})
}
InnerRender(): string {
return this._html.data;
protected InnerConstructElement(): HTMLElement {
return this._element;
}
}