dreamstack/examples/slot-demo.ds
enzotar 76bb1bb3a2 feat: slot/children composition for components
- AST: added Expr::Slot variant
- Parser: 'slot' keyword renders children, [...] bracket children after ComponentUse
- Codegen: DS_{name}(props, __children) factory pattern
- Type checker: Slot => Type::View
- Updated Card component with slot for children
- Added examples/slot-demo.ds
2026-02-26 16:14:35 -08:00

24 lines
798 B
Text

-- DreamStack Slot Composition Demo
-- Demonstrates component children/slot rendering
import { Card } from "../registry/components/card"
import { Button } from "../registry/components/button"
import { Badge } from "../registry/components/badge"
let count = 0
view main = column [
text "🧩 Slot Composition" { variant: "title" }
text "Components can now accept children!" { variant: "subtitle" }
Card { title: "Counter Card", subtitle: "with interactive children" } [
text "Count: {count}"
button "+1" { click: count += 1, variant: "primary" }
button "-1" { click: count -= 1, variant: "secondary" }
]
Card { title: "Nested Components", subtitle: "badge inside card" } [
Badge { label: "nested", variant: "success" }
text "Badge rendered inside Card slot"
]
]