Created
September 24, 2023 05:56
-
-
Save texastoland/c96bea76df20ee8b839fbb259364e3b7 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 'util/styles' | |
def log do console.log $1 and $1 | |
class Todo | |
@observable text\string | |
@observable done\boolean | |
tag todos | |
@observable todos\Todo[] = [] | |
new-todo\string | |
def add-todo | |
todos.push new Todo | |
text: new-todo | |
done: no | |
new-todo = "" | |
@computed get remaining | |
log "recalculating" | |
(todos.filter do !$1.done).length | |
<self> | |
<input | |
placeholder="Add todo" | |
bind=new-todo | |
@keydown.enter.if(new-todo)=add-todo> | |
for todo in todos | |
<%todo-container> | |
<input type="checkbox" bind=todo.done> | |
<input bind=todo.text> | |
<p> `{remaining} remaining` | |
imba.mount <todos> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment