ConditionalComponentLayout
The object for defining conditional properties for a component layout, and when the conditional properties are in effect.
Declaration
object ConditionalComponentLayoutProperties
| Name | Type | Description |
|---|---|---|
conditions Required | (Condition | [Condition]) | An instance or array of conditions that, when met, cause the conditional component layout properties to take effect. |
columnSpan | integer | A number that indicates how many columns the component spans, based on the number of columns in the document. Note that for the By default, the component spans the entire width of the document or the width of its container component. |
columnStart | integer | A number that indicates which column the component’s start position is in, based on the number of columns in the document or parent container. Note that for the By default, the component starts in the first column (note that the first column is |
horizontalContentAlignment | string | The alignment of the content within the component. This property applies only when the width of the content is less than the width of the component. The Image, Logo, and Divider components support this property. All other components ignore this property. |
ignoreDocumentGutter | (boolean | string("none" | "left" | "right" | "both")) | A value that indicates whether Apple News ignores the gutters (if any) to the left and right of the component. The gutter size is defined in the Use this option to position two components next to each other without a gutter between them. This property applies only when a gutter actually exists to the left or right of the component. The first column doesn’t have a left gutter, and the last column doesn’t have a right gutter. Valid values:
You can also set this property to |
ignoreDocumentMargin | (boolean | string("none" | "left" | "right" | "both")) | A value that indicates whether the parent container respects or ignores a document’s margins. Ignoring document margins positions the component at the edge of the display. This property affects the layout only if the component is in the first or last column. Valid values:
Instead of specifying margins, you can set this property to |
margin | (Margin | integer) | The margins for the top and bottom of the component, as a single integer that is applied to the top and bottom margins, or as an object containing separate properties for top and bottom. |
maximumContentWidth | (SupportedUnits | number) | The maximum width of the content within the component. Specify this value as a number in points, or use one of the available units of measure for components. See Specifying Measurements for Components. This property is supported for Image, Logo, and Divider components. All other components ignore this property. |
maximumWidth | (SupportedUnits | number) | The maximum width of the layout when you use it within a Container with HorizontalStackDisplay as the specified |
minimumHeight | (SupportedUnits | number) | The minimum height of the component. A component is taller than its defined |
minimumWidth | (SupportedUnits | number) | The minimum width of the layout when you use it within a container with HorizontalStackDisplay as the specified |
padding | (SupportedUnits | Padding | number) | The padding between the content of the component and the edges of the component. |
ignoreViewportPadding | (boolean | string("none" | "left" | "right" | "both")) | A value that indicates whether the component respects or ignores the viewport padding. Ignoring viewport padding positions the component at the edge of the display screen. This property affects the layout only if the component is in the first or last column. Valid values:
Instead of specifying padding, you can set this property to The layout of a parent component always constrains any child components. Setting If you set If you set By default, components don’t ignore the viewport padding, even if you previously specified |
Discussion
Use the ConditionalComponentLayout object to define an array of conditional component layout properties and the conditions under which to apply them. When a condition is met, the value of a property in ConditionalComponentLayout overrides the value of the same property if defined in the parent ComponentLayout object. See ComponentLayout.
Example
{
"components": [
{
"role": "photo",
"URL": "bundle://summer.jpg",
"layout": "exampleLayout",
"caption": "Thanks to the record drought, mountain lions have begun to descend from the peaks."
}
],
"componentLayouts": {
"exampleLayout": {
"ignoreDocumentMargin": true,
"conditional": [
{
"ignoreDocumentMargin": false,
"conditions": [
{
"minViewportWidth": 415
}
]
}
]
}
}
}