* add components * example: componentize header * fix choo SSR * example: componentize footer * example: fix footer * update component cache asserts * componentize todos * reorder example dir * fix example tests * fix dep check test * Add garbage collection of unused components * Apply args when calling identity * update to new component preview * update nanocomponent * fix cache err name * remove static methods from example * restore app.emit() function * public API tests * offset component cache iteration by 2 * whitelist contents of component folder (#643) * allow lru number arg * fix lint typo
33 lines
658 B
JavaScript
33 lines
658 B
JavaScript
var Component = require('../../component')
|
|
var html = require('bel')
|
|
|
|
module.exports = class Header extends Component {
|
|
constructor (name, state, emit) {
|
|
super(name)
|
|
this.state = state
|
|
this.emit = emit
|
|
}
|
|
|
|
update () {
|
|
return false
|
|
}
|
|
|
|
createElement () {
|
|
return html`<header class="header">
|
|
<h1>todos</h1>
|
|
<input class="new-todo"
|
|
autofocus
|
|
placeholder="What needs to be done?"
|
|
onkeydown=${this.createTodo.bind(this)} />
|
|
</header>`
|
|
}
|
|
|
|
createTodo (e) {
|
|
var value = e.target.value
|
|
if (e.keyCode === 13) {
|
|
e.target.value = ''
|
|
this.emit('todos:create', value)
|
|
}
|
|
}
|
|
}
|