git ssb

16+

Dominic / patchbay



Tree: 920f29c78bb0076a529cda4bbc4f01b19cabd924

Files: 920f29c78bb0076a529cda4bbc4f01b19cabd924 / 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