Contact us

Applies to: Customer's Canvas On-Premises; Customer's Canvas Hub cloud; UI Framework 4.0 - 4.47

Skip to main content

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 with width and height.
  • state: the state information, an object with id (a private state ID) and the optional surfacesCount. If you pass surfacesCount, the widget does not request design information.
  • mockups: mockup descriptions from pim-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 }}"
}
}
}
}
Was this page helpful?