Mockup Previews Ajax
This non-visual widget generates previews from the mockups of a PIM product. The resulting image URLs are available through the urls property and can be displayed with any widget that shows images, for example, slider. Use this widget with pim-ajax instead of writing custom ajax-based configurations. For product previews, it is a more flexible alternative to preview-mockup-slider.
{
"name": "mockup-previews",
"type": "mockup-previews-ajax",
"params": {...}
}
Params
size: the preview size, an object withwidthandheight.state: the state information, an object withid(a private state ID) and the optionalsurfacesCount. If you passsurfacesCount, the widget does not request design information.mockups: mockup descriptions frompim-ajax.
Properties
urls: an array of preview image URLs.
Examples
The following example generates previews for the state returned by Data-Driven Editor and the mockups returned by pim-ajax. Here, state.id is the state ID returned by Data-Driven Editor.
{
"name": "mockup-previews",
"type": "mockup-previews-ajax",
"params": {
"autoCompile": false,
"size": {
"width": 1200,
"height": 1200
},
"state": {
"id": "{{ $['dd-editor'].stateId }}"
},
"mockups": "{{ $['pim-ajax'].mockups }}"
}
}
To display the previews, pass the urls property to any widget that shows images. The following example uses the slider widget:
{
"name": "preview",
"type": "slider",
"params": {
"direction": "tile",
"rows": 1,
"columns": "{{ Math.min(2, $['mockup-previews'].urls.length) }}",
"containerColor": "#eee",
"images": {
"{{#each $['mockup-previews'].urls as imageUrl }}": {
"url": "{{ imageUrl }}"
}
}
}
}