git ssb

16+

Dominic / patchbay



Tree: e4576b48ca8fe529727a6202eafef8fa951bfafe

Files: e4576b48ca8fe529727a6202eafef8fa951bfafe / app / html / modal.js

718 bytesRaw
1const nest = require('depnest')
2const { h, when, Value } = require('mutant')
3
4exports.gives = nest('app.html.modal')
5
6exports.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