From 429dc2d5375abf8ca9c3861bdc4bdff52a31b0e4 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 10 Sep 2022 00:56:25 +0200 Subject: overlay rework + settings --- client-web/source/helper.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'client-web/source/helper.ts') 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 @@ /// + 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 + } +} + -- cgit v1.2.3-70-g09d2