Skip to main content

How To Create Custom UI

Customizing the UI of your product configurator enhances, not only the look, but also the user experience. Adding multiple tabs with multiple configurators and buttons that show different visualizations dynamically is some of the typical examples when customizing the UI.

Template​

In order to start creating your custom UI, it's best to do it from a configuration- and visualization model so the template gets everything in place automatically. For this:

  • get ready your configuration model and visualization model.
  • in Studio > Assemble & Publish > Layout, choose Custom User Interface.
  • click Create Custom User Interface and choose your configuration and visualization models, and optionally some action like creating a drawing exporter you already have in your product configurator.
  • then step into it by clicking Edit Custom User Interface and you will see an editor for the UI where you can change everything.

At the top, you will see that the editor consists of different tabs:

  • UI where the user interface is built.
  • STYLE where the look of the UI can be changed via CSS.
  • SELECTION reserved for click interaction functionalities.
  • HOTKEYS reserved for binding keyboard shortcuts to specific actions.
  • ACTIONS reserved for storing any functionalities (e.g. downloading drawing, centering camera, etc).
  • ADVANCED reserved for connecting everything besides customization options for the scene and more.

In UI you will see:

  • VisualizationWrapper as the component that handles the matching between the configuration and visualization models.
  • onInit(), where your custom UI is built with these parts:
    • creation of the configurator and its visualization, where the assembly happens:

      const configurator = ASSEMBLY.mainConfigurator() // "ASSEMBLY" is the package name with the configuration and visualization models.
      const component = new VisualizationWrapper()
      component.setProperties(configurator.getProperties())
      Studio.getComponentHandler().add(component)

      configurator.addCompletionCallback((valid, values) => {
      if (valid) {
      component.setProperties(values) // sends parameter values to component
      Studio.requestGeometryUpdate() // updates geometry
      }
      })
    • creation of downloading pdf button (as the action selected):

      const downloadPdfButton = new SKYUI.Button('Download PDF', async () => {
      const geometry = Studio.getComponentHandler().generateAllGeometry()
      const drawing = await QUOTE_DRAWING.quoteDrawing(geometry)
      const blob = await drawing.generatePdfFile()
      Studio.downloadFile('quoteDrawing.pdf', blob)
      })
    • creation of tabs (only 1 in template) with their content (i.e. configurator with download-pdf button):

      const tab1 = new SKYUI.Tab({
      title: 'Configure',
      icon: 'cog',
      onInit: () => {
      Studio.setTabContent([configurator, downloadPdfButton])
      Studio.requestGeometryUpdate().then(() => updateCamera()) // updates geometry, then camera
      },
      })
      Studio.setTabs([tab1])
    • (optional) update of camera settings:

      Studio.updateCameraSettings({
      mouseButtons: {
      left: 'selectAndRotate',
      middle: 'zoom',
      right: 'pan',
      },
      })

New Tab​

Let's take an example where all the exports are to be sent to a new tab called e.g. "Exports". For this:

  • simply add a new tab under tab1 and set them like Studio.setTabs([tab1, tab2]):
export function onInit() {
// ... configurator & VisualizationWrapper

// ... downloadPdfButton

const tab1 = new SKYUI.Tab({
title: 'Configure',
icon: 'cog',
onInit: () => {
Studio.setTabContent([configurator])
Studio.requestGeometryUpdate().then(() => updateCamera())
},
})

const tab2 = new SKYUI.Tab({
title: 'Exports',
icon: 'save-file',
onInit: () => {
Studio.setTabContent([downloadPdfButton])
updateCamera() // no need to update geometry, only camera is enough
},
})

Studio.setTabs([tab1, tab2])

// ... update camera settings

Actions​

It's good practice to move all the actions to a place so they can be reused easily within UI. As example, we will move the camera-update to a function that can be reused throughout the UI.

  • For the camera update:

    • copy updateCamera() at the bottom of UI.
    • go into ACTIONS, and add export so it can be used in UI.
    • since Studio doesn't exist in ACTIONS, replace it with manager.
    • you should end up having the following:
    ACTIONS
    export function updateCamera() {
    const cameraDirection = { x: 1, y: 1, z: -1 }
    manager.setCameraToFitBounds({
    direction: cameraDirection,
    })
    }
    • then in UI, replace eveerywhere updateCamera() is used with ACTIONS.updateCamera(),
    • and then remove the old updateCamera() in UI since it's not used anymore
    UI
    export function onInit() {
    // ... configurator & VisualizationWrapper

    // ... downloadPdfButton

    const tab1 = new SKYUI.Tab({
    title: 'Configure',
    icon: 'cog',
    onInit: () => {
    Studio.setTabContent([configurator])
    Studio.requestGeometryUpdate().then(() => ACTIONS.updateCamera())
    },
    })

    const tab2 = new SKYUI.Tab({
    title: 'Exports',
    icon: 'save-file',
    onInit: () => {
    Studio.setTabContent([downloadPdfButton])
    ACTIONS.updateCamera()
    },
    })

    Studio.setTabs([tab1, tab2])

    // ... update camera settings
    }