Skip to content

Commit

Permalink
fix gatherings (see github.com/mmckegg/mutant/issues/28)
Browse files Browse the repository at this point in the history
  • Loading branch information
mixmix committed Aug 5, 2019
1 parent c9c38e8 commit 475cf8a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 49 deletions.
24 changes: 13 additions & 11 deletions app/html/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { h, Value } = require('mutant')
exports.gives = nest('app.html.modal')

exports.create = (api) => {
return nest('app.html.modal', (content, { isOpen, onClose, className = '' } = {}) => {
return nest('app.html.modal', (content, { isOpen, onOpen, onClose, className = '' } = {}) => {
if (typeof isOpen !== 'function') isOpen = Value(false)

const openMe = () => {
Expand All @@ -15,7 +15,7 @@ exports.create = (api) => {
if (typeof onClose === 'function') onClose()
}

const lb = h('Modal -closed',
const modal = h('Modal -closed',
{
className,
'ev-click': closeMe,
Expand All @@ -33,27 +33,29 @@ exports.create = (api) => {

isOpen(state => {
if (state === true) {
lb.classList.remove('-closed')
lb.classList.add('-open')
modal.classList.remove('-closed')
modal.classList.add('-open')
} else {
lb.classList.remove('-open')
lb.classList.add('-closed')
modal.classList.remove('-open')
modal.classList.add('-closed')
return
}

if (typeof onOpen === 'function') onOpen()
focus()

function focus () {
if (!lb.isConnected) setTimeout(focus, 200)
if (!modal.isConnected) setTimeout(focus, 200)
else {
const target = lb.querySelector('input') || lb.querySelector('textarea')
const target = modal.querySelector('input') || modal.querySelector('textarea')
if (target) target.focus()
}
}
})

lb.open = openMe
lb.close = closeMe
modal.open = openMe
modal.close = closeMe

return lb
return modal
})
}
6 changes: 4 additions & 2 deletions app/html/modal.mcss
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ Modal {
}

-open {
display: grid
/* display: grid */
visibility: visible
}

-closed {
display: none
/* display: none */
visibility: hidden
}

-dark {
Expand Down
84 changes: 50 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"lodash": "^4.17.10",
"marama": "^1.2.2",
"micro-css": "^2.0.1",
"mutant": "^3.23.0",
"mutant": "~3.22.1",
"mutant-scroll": "^1.0.2",
"noto-color-emoji": "^1.0.0",
"open-dyslexic": "^1.0.3",
Expand All @@ -79,7 +79,7 @@
"patch-suggest": "^3.0.1",
"patchbay-book": "^2.0.4",
"patchbay-dark-crystal": "^2.0.0",
"patchbay-gatherings": "^3.2.14",
"patchbay-gatherings": "^3.2.19",
"patchbay-hacky-art": "^1.0.0",
"patchbay-poll": "^1.1.4",
"patchbay-scry": "^1.5.0",
Expand Down

0 comments on commit 475cf8a

Please sign in to comment.