dreamstack/examples/todomvc.ds
enzotar cbd6dfc7a6 feat: dynamic lists (push/remove/pop) + TodoMVC demo
- MethodCall AST node: obj.method(args) parsing
- Array push: items.push(x) → immutable spread+append
- Array remove: items.remove(idx) → filter by index
- Array pop: items.pop() → slice(0, -1)
- Fix: loop vars (todo, _idx) emitted without .value via is_local_var()
- Fix: _idx added to each loop scope for index-based event handlers
- New: examples/todomvc.ds — add, remove, clear all, fully reactive
2026-02-26 16:46:06 -08:00

38 lines
1 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- DreamStack TodoMVC
-- Dynamic list with add, remove, and reactive count
import { Card } from "../registry/components/card"
import { Badge } from "../registry/components/badge"
let todos = ["Learn DreamStack", "Build something amazing", "Ship it"]
let newTodo = ""
let completedCount = 0
view main = column [
text "📝 DreamStack Todos" { variant: "title" }
text "Add, remove, and manage your tasks" { variant: "subtitle" }
-- Add new todo
Card { title: "New Todo", subtitle: "type and press Add" } [
row [
input { bind: newTodo, placeholder: "What needs to be done?" }
button "Add" { click: todos.push(newTodo), variant: "primary" }
]
]
-- Todo list
Card { title: "Todo List", subtitle: "click × to remove" } [
each todo in todos ->
row [
text "•"
text todo
button "×" { click: todos.remove(_idx), variant: "ghost" }
]
]
-- Footer
row [
Badge { label: "ITEMS", variant: "info" }
button "Clear All" { click: todos = [], variant: "ghost" }
]
]