This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var html = require('bel') | |
var morphdom = require('morphdom') | |
var saved | |
function child () { | |
saved = saved || html`<h1 onload=${() => console.log('child on')} onunload=${() => console.log('child off')}>child</h1>` | |
return saved | |
} | |
function parent () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const choo = require('choo') | |
const html = require('choo/html') | |
const app = choo() | |
app.model({ | |
state: { | |
convos: { | |
'2151234567': generateItems(50), | |
'9891239876': generateItems(50), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var list = document.querySelector('#filter-list ul') | |
var listItems = Array.from(list.children) | |
var depts = listItems.map((li) => { | |
var link = li.querySelector('.content-department') | |
return link.innerText + "\t" + link.getAttribute('href') | |
}) | |
copy(depts.join("\n")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const choo = require('choo') | |
const html = require('choo/html') | |
const http = require('choo/http') | |
const app = choo() | |
app.model({ | |
effects: { | |
fetch: (data, state, send, done) => { | |
send('sub', (err) => { | |
if (err) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const yo = require('yo-yo') | |
function parent (title) { | |
return yo`<div>${child(title)}</div>` | |
} | |
function child (title) { | |
const el = yo`<h1>${title}</h1>` | |
window.setTimeout(() => { | |
// silly example, but really referring to L.map() or other init() libraries |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getFormData = require('get-form-data') | |
const html = require('choo/html') | |
module.exports = function formComponent (opts) { | |
return ` | |
<form> | |
<input name="woof" type="text" placeholder="type here" | |
value=${opts.values.woof} oninput=${onInput}> | |
<input type="submit" onsubmit=${onSubmit}> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatDate (iso) { | |
const [year, month, day] = iso.split('T')[0].split('-') | |
return `${+month}/${+day}/${year}` | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const choo = require('choo') | |
const html = require('choo/html') | |
const app = choo() | |
app.model({ | |
state: { | |
title: 'Hello' | |
}, | |
reducers: { | |
update: (data, state) => ({ title: data }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var onload = require('on-load') | |
var yo = require('yo-yo') | |
function page1 () { | |
var tree = yo`<div>page1</div>` | |
onload(tree, function () { | |
console.log('page1 on') | |
}, function () { | |
console.log('page1 off') | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.router((route) => [ | |
route('/', layouts.root(views.connect)), | |
route('/tables', layouts.root(layouts.database()), [ | |
route('/:name', layouts.root(layouts.database(views.tableRows, 'rows')), [ | |
route('/schema', layouts.root(layouts.database(views.tableSchema, 'schema'))), | |
route('/options', layouts.root(layouts.database(views.tableOptions, 'options'))) | |
]) | |
]) | |
]) |