How to use the mutant.when function in mutant

To help you get started, we’ve selected a few mutant examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blockades / patchbay-dark-crystal / views / component / secret.js View on Github external
function renderError () {
    return [
      h('h1', [ 'Error combining shards!!!' ]),
      h('pre', computed(error, e => (e || '').toString())),
      h('div.actions', [
        when(modalOpen, h('button -subtle', { 'ev-click': () => modalOpen.set(false) }, 'close'), [])
      ])
    ]
  }
}
github pietgeursen / patch-gatherings / gathering / html / description.js View on Github external
function description ({description, isEditing, onUpdate}) {
    const markdown = api.message.html.markdown
    const input = h('textarea', {'ev-input': e => onUpdate(e.target.value), value: description})

    return h('Description', [
      when(isEditing,
        input,
        computed(description, markdown)
      )
    ])
  }
}
github ticktackim / ticktack-workplan / message / html / compose.js View on Github external
function PreviewSetup (strings) {
      var showPreview = Value(false)
      var previewBtn = h('Button',
        {
          className: when(showPreview, '-strong', '-subtle'),
          'ev-click': () => showPreview.set(!showPreview())
        },
        when(showPreview, strings.blogNew.actions.edit, strings.blogNew.actions.preview)
      )
      return { previewBtn, showPreview }
    }
    var { previewBtn, showPreview } = PreviewSetup(strings)
github ticktackim / ticktack-workplan / message / html / likes.js View on Github external
return nest('message.html.likes', function likes(msg) {
    var id = api.keys.sync.id()
    var likes = api.message.obs.likes(msg.key)

    var iLike = computed(likes, likes => likes.includes(id))
    var count = computed(likes, likes => likes.length ? likes.length : '')

    return h('Likes', { 'ev-click': () => publishLike(msg, !iLike()) }, [
      h('i.fa', { className: when(iLike, 'fa-heart', 'fa-heart-o') }),
      h('div.count', count)
    ])
  })
github ticktackim / ticktack-workplan / app / html / lightbox.js View on Github external
return nest('app.html.lightbox', (content, isOpen) => {

    if (typeof isOpen !== 'function') isOpen = Value(false)

    const closeMe = () => isOpen.set(false)


    const lb = h('Lightbox', { className: when(isOpen, '-open', '-close'), 'ev-click': closeMe },
      h('div.content', {'ev-click': (ev) => ev.stopPropagation()},[
        content
      ]))

    lb.close = closeMe

    return lb
  })
}

mutant

Create observables and map them to DOM elements. Massively inspired by hyperscript and observ-*. No virtual dom, just direct observable bindings. Unnecessary garbage collection is avoided by using mutable objects instead of blasting immutable junk all ove

MIT
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis