Files: 6ea2e0c78708bc5e28705209ad8cb1eeba3d6706 / app / html / modal.js
718 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, when, Value } = require('mutant') |
3 | |
4 | exports.gives = nest('app.html.modal') |
5 | |
6 | exports.create = (api) => { |
7 | return nest('app.html.modal', (content, { isOpen, onClose, className = '' } = {}) => { |
8 | if (typeof isOpen !== 'function') isOpen = Value(false) |
9 | |
10 | const openMe = () => isOpen.set(true) |
11 | const closeMe = () => { |
12 | isOpen.set(false) |
13 | if (typeof onClose === 'function') onClose() |
14 | } |
15 | |
16 | const lb = h('Modal', { classList: [when(isOpen, '-open', '-close'), className], 'ev-click': closeMe }, |
17 | h('div.content', {'ev-click': (ev) => ev.stopPropagation()}, [ |
18 | content |
19 | ])) |
20 | |
21 | lb.open = openMe |
22 | lb.close = closeMe |
23 | |
24 | return lb |
25 | }) |
26 | } |
27 |
Built with git-ssb-web