Contact us

Applies to: Customer's Canvas Hub cloud; Product Information Management (PIM) cloud; UI Framework 4.47 - 4.47

Skip to main content

Mockup previews ajax

This non-visual widget generates previews from the mockups of a product configured in the PIM module. The resulting image URLs are available through the urls property and can be displayed with any widget that shows images, for example, slider.

Use mockup-previews-ajax with pim-ajax instead of writing custom ajax-based configurations. For product previews, it is a more flexible alternative to preview-mockup-slider. For release details, see Release notes.

{
"name": "mockup-previews",
"type": "mockup-previews-ajax",
"params": { ... }
}

Params​

  • size: The preview size, an object with width and height.
    • width: The preview width.
    • height: The preview height.
  • state: The state information, an object with id and the optional surfacesCount.
    • id: The ID of the private state.
    • surfacesCount: (Optional). The number of surfaces. If you specify it, the widget does not request design information.
  • mockups: Mockup descriptions from pim-ajax.

Properties​

  • urls: An array of preview image URLs.

Examples​

Generating previews​

The following example generates previews for the state returned by the Data-Driven Editor widget and for 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 }}"
}
}

Displaying previews​

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?