diff options
Diffstat (limited to 'client-web/source/helper.ts')
-rw-r--r-- | client-web/source/helper.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/client-web/source/helper.ts b/client-web/source/helper.ts index b4eb20e..1d75b60 100644 --- a/client-web/source/helper.ts +++ b/client-web/source/helper.ts @@ -1,6 +1,7 @@ /// <reference lib="dom" /> + const elem = (s: string) => document.createElement(s) interface Opts { class?: string[] | string, id?: string } @@ -37,3 +38,19 @@ export const ediv = elem_with_children("div") export const espan = elem_with_content("span") export const elabel = elem_with_content("label") +export const OVERLAYS = ediv({ class: "overlays" }) + + +export class OverlayUi { + _shown = false + constructor(public el: HTMLElement, initial = false) { + this.shown = initial + } + get shown() { return this._shown } + set shown(v: boolean) { + if (v && !this._shown) OVERLAYS.append(this.el) + if (!v && this._shown) OVERLAYS.removeChild(this.el) + this._shown = v + } +} + |