From 1ebc55c72a1a17293bbf4ad86e0177a10a794750 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 17 Sep 2023 12:23:47 +0200 Subject: Make app packageable --- library/client/view/components/modal.ts | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 library/client/view/components/modal.ts (limited to 'library/client/view/components/modal.ts') diff --git a/library/client/view/components/modal.ts b/library/client/view/components/modal.ts new file mode 100644 index 0000000..5e845e1 --- /dev/null +++ b/library/client/view/components/modal.ts @@ -0,0 +1,38 @@ +import { h, Html } from 'lib/rx' + +interface Params { + header: Html + body: Html + onClose: () => void + onmount?: (element: Element) => void + onunmount?: (element: Element) => void +} + +export function view({ header, body, onClose, onmount, onunmount }: Params): Html { + return h('div', + { className: 'g-Modal', + onclick: () => onClose(), + onmount: (element: Element) => onmount && onmount(element), + onunmount: (element: Element) => onunmount && onunmount(element) + }, + h('div', + { className: 'g-Modal__Content', + onclick: (e: Event) => e.stopPropagation() + }, + h('div', + { className: 'g-Modal__Header' }, + header, + h('button', + { className: 'g-Modal__Close', + onclick: () => onClose() + }, + '✕' + ) + ), + h('div', + { className: 'g-Modal__Body' }, + body + ) + ) + ) +} -- cgit v1.2.3