- 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
38 lines
1 KiB
Text
38 lines
1 KiB
Text
-- 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" }
|
||
]
|
||
]
|