ConditionalComponent
The object for defining conditional properties for a component, and when the conditional properties are in effect.
Declaration
object ConditionalComponentProperties
| Name | Type | Description |
|---|---|---|
conditions Required | (Condition | [Condition]) | An instance or array of conditions that, when met, cause the conditional component properties to take effect. |
anchor | Anchor | An object that defines vertical alignment with another component. |
animation | (ComponentAnimation | string("none")) | An object that defines an animation to apply to the component. To remove a previously set condition, use |
behavior | (Behavior | string("none")) | An object that defines behavior for a component, like Parallax or Springy. To remove a previously set condition, use |
hidden | boolean | A Boolean value that determines whether the component is hidden. |
layout | (ComponentLayout | string) | An inline If you don’t define the layout, Apple News bases the size and position on various factors, such as the device type, the length of the content, and the |
style | (ComponentStyle | string | string("none")) | An inline To remove a previously set condition, use |
Discussion
Use the ConditionalComponent object to define an array of conditional component properties and the conditions under which to apply them. When a condition is met, the value of a property in ConditionalComponent overrides the value of the same property if you define it in the parent component. See Component.
Example
{
"components": [
{
"role": "title",
"text": "Article Title",
"style": "red-background",
"textStyle": {
"textAlignment": "center"
},
"layout": "short-header",
"conditional": [
{
"style": "blue-background",
"textStyle": {
"textAlignment": "left"
},
"layout": "tall-header",
"conditions": [
{
"minViewportWidth": 415
}
]
}
]
}
],
"componentStyles": {
"red-background": {
"backgroundColor": "red"
},
"blue-background": {
"backgroundColor": "blue"
}
},
"componentLayouts": {
"short-header": {
"minimumHeight": 100
},
"tall-header": {
"minimumHeight": 200
}
}
}