Nova · Layouts
Conditional
An if node draws its then when the path holds something and its else when it does not. Without an else, it draws nothing.
{
id: 'conditional',
data: { signedIn: true, basket: [] },
layout: {
component: 'Stack',
children: [
{
if: '$.signedIn',
then: { component: 'Text', children: 'Welcome back.' },
else: { component: 'Text', children: 'Sign in to go on.' },
},
{
if: '$.basket.0',
then: {
component: 'Text',
children: 'There is something in your basket.',
},
else: { component: 'Text', children: 'Your basket is empty.' },
},
{
if: '$.basket.0',
then: { component: 'Text', children: 'Go to the till.' },
},
],
},
}Welcome back.
Your basket is empty.
Nothing. It is only drawn.
{ signedIn: true, basket: [] }Welcome back. Your basket is empty.
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.