vdom-list

Show lists of things with a virtual dom

Usage no npm install needed!

<script type="module">
  import vdomList from 'https://cdn.skypack.dev/vdom-list';
</script>

README

vdom list

Show lists of things with a virtual dom

install

$ npm install vdom-list

example

var vdom = require('virtual-dom');
var h = vdom.h;
var List = require('../List.js');

function Link(url, words) {
  return h('a', {href: url}, [words]);
}

var state = List({
  items: [
    {
      name: 'location',
      children: ['seattle', 'olympia', 'tangier']
    },
    {
      name: 'meats',
      children: [
        Link('ham', 'ham'),
        Link('fish', 'some kinds of fish'),
        Link('hot-dogs', 'hot dogs')
      ]
    }
  ]
});

var loop = require('main-loop')( state(), List.render.bind(null, h), vdom );
state(loop.update);
document.getElementById('content').appendChild(loop.target);