Last active
February 2, 2019 21:59
-
-
Save HenriqueLimas/dc75ac3595c44ef1b330f18d2cd0dc56 to your computer and use it in GitHub Desktop.
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
import { define } from "osagai"; | |
import { on } from "osagai/events"; | |
import { update } from "osagai/dom"; | |
function Todos({ element, query }) { | |
on("click", query(".btn"), () => { | |
update(element, (items = []) => { | |
items.push({ | |
name: `Item nr ${items.length + 1}` | |
}); | |
return items; | |
}); | |
}); | |
return (items = []) => | |
`<div> | |
<button class="btn">Add item</button> | |
${` | |
<ul class="list"> | |
${items.map(item => `<li>${item.name}</li>`).join("")} | |
</ul>`} | |
</div>`; | |
} | |
define("todo-list", Todos); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment