Convert to component based architecture
This commit is contained in:
parent
eb2075aec5
commit
cdaa423b8a
70 changed files with 1942 additions and 484 deletions
7
src/framework/element-factory.ts
Normal file
7
src/framework/element-factory.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { html } from "../model/misc";
|
||||
|
||||
export const createElement = (from: html): HTMLElement => {
|
||||
const element: HTMLElement = document.createElement("div");
|
||||
element.innerHTML = from;
|
||||
return element.firstElementChild as HTMLElement;
|
||||
};
|
||||
2
src/framework/helpers.ts
Normal file
2
src/framework/helpers.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export const show = (e: HTMLElement) => (e.style.display = "block");
|
||||
export const hide = (e: HTMLElement) => (e.style.display = "none");
|
||||
16
src/framework/page-element.ts
Normal file
16
src/framework/page-element.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
export abstract class PageElement {
|
||||
// Getter and setter accessors would have to agree in visibility
|
||||
public getElement(): HTMLElement {
|
||||
return this._element;
|
||||
}
|
||||
private _element: HTMLElement;
|
||||
protected setElement(value: HTMLElement) {
|
||||
this._element = value;
|
||||
}
|
||||
|
||||
protected constructor(private children: Array<PageElement> = []) {}
|
||||
|
||||
public onAfterLoad(parent: HTMLElement) {
|
||||
this.children.forEach(c => c.onAfterLoad(this.getElement()));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue