From f63ff52e2aab721c4ae394cca9e8a4406e04b0af Mon Sep 17 00:00:00 2001 From: enzotar Date: Thu, 26 Feb 2026 16:57:08 -0800 Subject: [PATCH] feat: upgrade init starter app to showcase all DreamStack features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Imports Card, Badge, Button from components/ - Counter with callback props, Greeting with when/else - Mood match expression with Badge, Todo dynamic lists - Full init → build flow verified (51,401 bytes, 0 errors) --- compiler/ds-cli/src/main.rs | 72 ++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/compiler/ds-cli/src/main.rs b/compiler/ds-cli/src/main.rs index 7cd4a6c..4d35a89 100644 --- a/compiler/ds-cli/src/main.rs +++ b/compiler/ds-cli/src/main.rs @@ -1358,39 +1358,71 @@ fn cmd_init(name: Option) { // Write starter app.ds let app_source = r#"-- My DreamStack App +-- Showcases: imports, components, when/else, match, each, dynamic lists + +import { Card } from "./components/card" +import { Badge } from "./components/badge" +import { Button } from "./components/button" let count = 0 let name = "" +let darkMode = false +let mood = "happy" +let todos = ["Learn DreamStack", "Build something cool"] +let newTodo = "" view main = column [ -- Header - text "🚀 My App" { variant: "title" } - text "Built with DreamStack" { variant: "subtitle" } + text "🚀 My DreamStack App" { variant: "title" } + text "Built with DreamStack — edit app.ds and reload" { variant: "subtitle" } - -- Stats + -- Dashboard cards row [ - column [ - text "Users" { variant: "subtitle" } - text "1,247" { variant: "title" } - ] { variant: "card" } + Card { title: "Counter", subtitle: "reactive state" } [ + text "Count: {count}" { variant: "title" } + row [ + Button { label: "+1", onClick: count += 1, variant: "primary" } + Button { label: "-1", onClick: count -= 1, variant: "secondary" } + Button { label: "Reset", onClick: count = 0, variant: "ghost" } + ] + ] - column [ - text "Revenue" { variant: "subtitle" } - text "$8,420" { variant: "title" } - ] { variant: "card" } + Card { title: "Greeting", subtitle: "two-way binding" } [ + input { bind: name, placeholder: "Your name..." } + when name -> text "Hello, {name}! 👋" + else -> text "Type your name above" + ] ] - -- Input - text "Your name" { variant: "label" } - input { bind: name, placeholder: "Type here..." } - text "Hello, {name}!" - - -- Counter - row [ - button "Count: {count}" { click: count += 1, variant: "primary" } - button "Reset" { click: count = 0, variant: "ghost" } + -- Mood selector with match + Card { title: "Mood", subtitle: "match expressions" } [ + row [ + button "😊 Happy" { click: mood = "happy", variant: "primary" } + button "😢 Sad" { click: mood = "sad", variant: "secondary" } + button "🔥 Fired up" { click: mood = "fired", variant: "ghost" } + ] + match mood + "happy" -> Badge { label: "FEELING GREAT 🌟", variant: "success" } + "sad" -> Badge { label: "HANG IN THERE 💙", variant: "info" } + "fired" -> Badge { label: "LET'S GO 🔥", variant: "warning" } + _ -> Badge { label: "HOW ARE YOU?", variant: "info" } ] + + -- Todo list with dynamic arrays + Card { title: "Todos", subtitle: "dynamic lists" } [ + row [ + input { bind: newTodo, placeholder: "New task..." } + button "Add" { click: todos.push(newTodo), variant: "primary" } + ] + each todo in todos -> + row [ + text "→ {todo}" + button "×" { click: todos.remove(_idx), variant: "ghost" } + ] + button "Clear All" { click: todos = [], variant: "ghost" } + ] + ] "#; fs::write(project_dir.join("app.ds"), app_source).expect("Failed to write app.ds");