Currently Ripple support slots in the following way (code could be wrong)
component Card({ $children, $header, $footer }) {
<div>
<$header />
<$children />
<$footer />
</div>
}
export component App() {
<Card>
component $header() {
<div>{"card header"}</div>
}
<div>{"default content"}</div>
component $footer() {
<div>{"card footer"}</div>
}
</Card>
}
But it's to cumbersome in practice as you have to wrap your named slot with component slot_name() {} everywhere you use the component
In real world we'd hope consumer can use it as
<Card>
<CardHeader />
<CardContent />
<CardFooter />
</Card>
CardHeader/CardContent/CardFooter are all wrapped slots
Rough ideas
given the complexity of template compilation and static analyse in build phase, we can provide shorthand for named slots without slots props like
<Card>
slot $header {<CardHeader />}
<CardContent />
<CardFooter />
</Card>
or
<Card>
<$slot name='header'><CardHeader />}</$slot>
<CardContent />
<CardFooter />
</Card>
More context:
https://www.npmjs.com/package/create-slots
reactjs/rfcs#223
Currently Ripple support slots in the following way (code could be wrong)
But it's to cumbersome in practice as you have to wrap your named slot with
component slot_name() {}everywhere you use the componentIn real world we'd hope consumer can use it as
CardHeader/CardContent/CardFooterare all wrapped slotsRough ideas
given the complexity of template compilation and static analyse in build phase, we can provide shorthand for named slots without slots props like
or
More context:
https://www.npmjs.com/package/create-slots
reactjs/rfcs#223