Skip to content

Instantly share code, notes, and snippets.

@texastoland
Created September 24, 2023 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save texastoland/c96bea76df20ee8b839fbb259364e3b7 to your computer and use it in GitHub Desktop.
Save texastoland/c96bea76df20ee8b839fbb259364e3b7 to your computer and use it in GitHub Desktop.
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