- 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
24 lines
798 B
Text
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"
|
|
]
|
|
]
|