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/preferences/ui.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 client-web/source/preferences/ui.ts (limited to 'client-web/source/preferences/ui.ts') diff --git a/client-web/source/preferences/ui.ts b/client-web/source/preferences/ui.ts new file mode 100644 index 0000000..1aaaca0 --- /dev/null +++ b/client-web/source/preferences/ui.ts @@ -0,0 +1,27 @@ +import { ediv, elabel, espan, OverlayUi } from "../helper.ts"; +import { PREF_DECLS } from "./decl.ts"; +import { change_pref, PrefDecl, PREFS } from "./mod.ts"; + +export class PrefUi extends OverlayUi { + constructor() { + const elements = Object.entries(PREF_DECLS as Record>).map(([key_, decl]) => { + const key = key_ as keyof typeof PREF_DECLS + + if (typeof decl.type == "boolean") { + const id = `pref-check-${key}` + const checkbox = document.createElement("input") + checkbox.type = "checkbox" + checkbox.id = id + checkbox.checked = PREFS[key] as boolean + checkbox.onchange = () => { + change_pref(key, checkbox.checked) + } + const label = elabel(decl.description ?? `[${key}]`, { id }) + return ediv({ class: "pref" }, checkbox, label) + } + return espan(`(not implemented)`) + }) + super(ediv({ class: "prefs-overlay" }, ...elements)) + } + +} -- cgit v1.2.3-70-g09d2