2021-06-10 01:36:20 +02:00
|
|
|
import BaseUIElement from "./BaseUIElement";
|
2020-06-24 00:35:19 +02:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
export abstract class UIElement extends BaseUIElement {
|
2020-09-02 11:37:34 +02:00
|
|
|
|
2020-06-24 00:35:19 +02:00
|
|
|
|
2021-01-18 02:51:42 +01:00
|
|
|
/**
|
2021-06-10 01:36:20 +02:00
|
|
|
* Should be overridden for specific HTML functionality
|
2021-01-18 02:51:42 +01:00
|
|
|
*/
|
2021-06-10 01:36:20 +02:00
|
|
|
protected InnerConstructElement(): HTMLElement {
|
|
|
|
// Uses the old fashioned way to construct an element using 'InnerRender'
|
|
|
|
const innerRender = this.InnerRender();
|
|
|
|
if (innerRender === undefined || innerRender === "") {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
const el = document.createElement("span")
|
|
|
|
if (typeof innerRender === "string") {
|
|
|
|
el.innerHTML = innerRender
|
|
|
|
} else {
|
|
|
|
const subElement = innerRender.ConstructElement();
|
|
|
|
if (subElement === undefined) {
|
|
|
|
return undefined;
|
2021-01-18 02:51:42 +01:00
|
|
|
}
|
2021-06-10 01:36:20 +02:00
|
|
|
el.appendChild(subElement)
|
2020-10-01 01:23:45 +02:00
|
|
|
}
|
2021-06-10 01:36:20 +02:00
|
|
|
return el;
|
2020-10-01 01:23:45 +02:00
|
|
|
}
|
2021-09-09 00:05:51 +02:00
|
|
|
|
2021-06-10 01:36:20 +02:00
|
|
|
protected abstract InnerRender(): string | BaseUIElement;
|
|
|
|
|
2020-07-20 15:54:50 +02:00
|
|
|
}
|
|
|
|
|
2020-06-24 00:35:19 +02:00
|
|
|
|
2020-07-29 15:05:19 +02:00
|
|
|
|