Nova · Composition
Reuse
One frame around many actions. Each action is opened with the same fragment, and the frame’s heading reads each action’s own label. Change the fragment and all of them change.
{
canvases: [
{
id: 'reuse.first',
initial: { action: 'reuse.sold', with: ['reuse.tile'] },
},
{
id: 'reuse.second',
initial: { action: 'reuse.free', with: ['reuse.tile'] },
},
],
actions: {
reuse.sold: {
id: 'reuse.sold',
data: { label: 'Sold', seats: 212 },
layout: { component: 'Text', children: '{{$.seats}} seats' },
},
reuse.free: {
id: 'reuse.free',
data: { label: 'Free', rows: ['C', 'F'] },
layout: {
component: 'Stack',
children: [
{
for: '$.rows',
as: 'row',
do: { component: 'Text', children: 'Row {{$row}}' },
},
],
},
},
},
fragments: {
reuse.tile: {
kind: 'fragment',
id: 'reuse.tile',
layout: {
component: 'Stack',
children: [
{ component: 'Text', children: '$.label' },
{ slot: 'body' },
],
},
},
},
}Sold
212 seats
Free
Row C
Row F
Nothing. It is only drawn.
{
reuse.first: ['reuse.sold'],
reuse.second: ['reuse.free'],
}Sold 212 seats Free Row C Row F
Left: the action as the package ships it. Right: the same action running in this page, rendered with this site’s components. Below: the action run as the example specifies, on the installed package.