This file contains 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 Todo = (props, send)=> { | |
const todo = props.todo; | |
const index = props.index; | |
return html` | |
<li> | |
<input | |
type="checkbox" | |
${todo.completed ? 'checked' : ''} | |
onchange=${(e)=> onChange(e, index)} |
This file contains 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 array1 = new Array(3) | |
var array2 = [undefined, undefined, undefined] | |
console.log(array1) | |
//=> [undefined, undefined, undefined] | |
console.log(array2) | |
//=> [undefined, undefined, undefined] | |
console.log(array1.map((a, i) => i)) | |
//=> [undefined, undefined, undefined] | |
console.log(array2.map((a, i) => i)) |
This file contains 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
// $ budo counter-list.js | |
const choo = require('choo') | |
const html = require('choo/html') | |
const app = choo() | |
app.model({ | |
state: { | |
counts: [0,0,0] |
This file contains 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 view = (state, prev, send) => { | |
return html` | |
<div onload=${()=> send('getTodos')}> | |
<form onsubmit=${onSubmit}> | |
<input type="text" placeholder="New item" id="title"> | |
</form> | |
${ TodoList({ todos: state.todos }, send) } | |
</div>` |
This file contains 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 things = [{ | |
name: 'Nope' | |
}, { | |
name: 'Nope' | |
}]; | |
var selectedThings = new Set(); | |
function select(thing) { | |
selectedThings.add(thing); | |
} |
This file contains 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
{ | |
"results": [{ | |
"name": "Cyclops", | |
"thumbnail": "..." | |
},{ | |
"name": "Wolverine", | |
"thumbnail": "..." | |
}] | |
} |
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
</head> | |
<body> | |
<p>Hello</p> | |
</body> | |
</html> |
This file contains 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
# implicit returns, simpler than bullshitting around with return () | |
ThreadList = (props)-> | |
<ul id="threads"> | |
<ThreadListItem threads={props.threads} /> | |
</ul> | |
# everything as an expression FTW | |
# for loops more natural than map, no bullshitting around with binding this |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<style> | |
img { image-orientation: from-image } | |
</style> | |
</head> | |
<body> |