aboutsummaryrefslogtreecommitdiff
path: root/src/lib/modal.ts
diff options
context:
space:
mode:
authorJoris2022-07-05 21:55:41 +0200
committerJoris2023-01-28 09:35:55 +0100
commit063d8ef9eaf874a941f4459e831057dd0a1b7ddd (patch)
treec4a8b27cb8fdb5d1dc26c560c7483c9593f40dac /src/lib/modal.ts
parent2936f06576997bffe7903ea840df563a408efc21 (diff)
downloadmap-main.tar.gz
map-main.tar.bz2
map-main.zip
Rewrite in TSmain
Diffstat (limited to 'src/lib/modal.ts')
-rw-r--r--src/lib/modal.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lib/modal.ts b/src/lib/modal.ts
new file mode 100644
index 0000000..8454e1c
--- /dev/null
+++ b/src/lib/modal.ts
@@ -0,0 +1,28 @@
+import { h } from 'lib/h'
+import * as Button from 'lib/button'
+
+export function show(content: Element) {
+ document.body.appendChild(h('div',
+ { id: 'g-Modal' },
+ h('div',
+ { className: 'g-Modal__Curtain',
+ onclick: () => hide()
+ }
+ ),
+ h('div',
+ { className: 'g-Modal__Window' },
+ Button.raw(
+ { className: 'g-Modal__Close',
+ onclick: () => hide()
+ },
+ 'x'
+ ),
+ content
+ )
+ ))
+}
+
+export function hide() {
+ const modal = document.querySelector('#g-Modal')
+ modal && document.body.removeChild(modal)
+}