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, render } = require('nanohtml') | |
var { Component, memo, onupdate } = require('nanohtml/component') | |
// This example illustrates how memo can be used to maintain form state. | |
// On first render, getInitialValues is called and read values either | |
// from the fields argument or from local storage. | |
// Whenever a field changes its value is persisted to local storage. | |
var Form = Component(function (fields, values = memo(getInitialValues)) { | |
var update = onupdate(function (fields, values) { |
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 Choo = require('choo') | |
var html = require('choo/html') | |
var LazyColor = require('./lazy-color') | |
var app = new Choo() | |
app.use(store) | |
app.route('/', view) | |
app.mount('body') |
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('nanohtml') | |
var Hypercomponent = require('hypercomponent') | |
class Greeting extends Hypercomponent { | |
update (strings, ...args) { | |
return true | |
} | |
Foo (attrs, children) { | |
if (attrs.bold) children = html`<strong>${children}</strong>` |
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 fetch = require('node-fetch') | |
var html = require('choo/html') | |
var choo = require('choo') | |
var app = choo() | |
app.route('/', main) | |
app.use(store) | |
function main (state, emit) { | |
if (!state.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 html = require('bel') | |
var assert = require('assert') | |
var morph = require('nanomorph') | |
var Nanocomponent = require('nanocomponent') | |
function Component (name) { | |
Nanocomponent.call(this, name) | |
} | |
Component.prototype = Object.create(Nanocomponent.prototype) |
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 assert = require('assert') | |
var morph = require('nanomorph') | |
var Nanocomponent = require('nanocomponent') | |
function Component (name) { | |
Nanocomponent.call(this, name) | |
} | |
Component.prototype = Object.create(Nanocomponent.prototype) |
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 assert = require('assert') | |
var morph = require('nanomorph') | |
var Nanocomponent = require('nanocomponent') | |
function Component (name) { | |
Nanocomponent.call(this, name) | |
} | |
Component.prototype = Object.create(Nanocomponent.prototype) |
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 assert = require('assert') | |
var Nanocomponent = require('nanocomponent') | |
function Component (name) { | |
Nanocomponent.call(this, name) | |
this.cache = {} | |
} | |
Component.prototype = Object.create(Nanocomponent.prototype) |
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 html = require('bel'); | |
const string = require('pelo'); | |
document.body.innerHTML = string` | |
<input disabled=${ false } placeholder="Wut, I'm disabled?" /> | |
`; | |
document.body.appendChild(html` | |
<input disabled=${ false } placeholder="I'm not disabled!" /> | |
`); |
NewerOlder