git ssb

16+

Dominic / patchbay



Tree: 6aed4c72a3b36330eb67723b515b426ec7f5f06d

Files: 6aed4c72a3b36330eb67723b515b426ec7f5f06d / 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