Skip to main content

Migrating from the Web Component

If your website still uses the <diva-framework> Web Component, replace it with the widgets described in this section. The widgets cover the same use cases with a single script and HTML attributes. Your configuration page URL, your backend and the DIVA API stay the same.

What changes​

Web ComponentWidget
React, ReactDOM, diva-core and module bundles with a VERSIONOne widget script, no version: https://<your-diva-api-host>/integration/api/widget/<YOUR_ORGANIZATION_ID>
diva.organizationIdPart of the widget script URL
diva.languagedata-lang attribute on the widget element or lang attribute of your page, see Language
type: 'DIVA_WEBPLANNER', parameters: { productId }, opened by a click handlerdiva-configurator-button with data-diva-param-productid, see Start a New Configuration
type: 'DIVA_WEBPLANNER', parameters: { divaNr }, opened on page loaddiva-configurator-direct, reads the divaNr from the URL of the page, see Reopen a Saved Configuration
type: 'PRODUCTDETAILPAGE', parameters: { id }diva-product-detail-page with data-diva-param-productid, see Product Detail Page
closeComponentInFullscreen listener with diva.remove()Not needed. Optionally data-diva-event-onwebplanerclose="<function>" on the widget element
absoluteFullscreenStyle (padding, background)CSS variables on the widget element, see Style the fullscreen overlay
diva.addEventListener('onAddToBasket', …)data-diva-event-onaddtobasket="<function>" on the widget element, see Add to Cart
Updating the version in the script URLsNot needed

Example​

Before – Web Component
<button id="openDivaBtn">Configure in DIVA</button>

<script crossorigin src="https://cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js"></script>
<script crossorigin src="https://cdn.jsdelivr.net/npm/@crystaldesign/diva-core@VERSION/build/umd/diva-core.umd.min.js"></script>
<script crossorigin src="https://cdn.jsdelivr.net/npm/@crystaldesign/diva-web-planner-react@VERSION/build/umd/diva-web-planner-react.umd.min.js"></script>
<script crossorigin src="https://cdn.jsdelivr.net/npm/@crystaldesign/real-time-viewer@VERSION/build/umd/real-time-viewer.umd.min.js"></script>

<script>
document.getElementById('openDivaBtn').addEventListener('click', function () {
if (document.querySelector('diva-framework')) return;

const diva = document.createElement('diva-framework');
diva.organizationId = '<YOUR_ORGANIZATION_ID>';
diva.language = 'de';
diva.identifier = 'COMPONENT';
diva.currentComponent = {
type: 'DIVA_WEBPLANNER',
parameters: { productId: '<PRODUCT_ID>' },
openInFullscreen: true,
absoluteFullscreen: true,
};
diva.addEventListener('closeComponentInFullscreen', () => diva.remove());

document.body.appendChild(diva);
});
</script>
After – Widget
<div data-diva-widget-type="diva-configurator-button" data-diva-param-productid="<PRODUCT_ID>">
Configure in DIVA
</div>

<script src="https://<your-diva-api-host>/integration/api/widget/<YOUR_ORGANIZATION_ID>?lang=de"></script>

Checklist​

  1. Remove the React, ReactDOM and DIVA bundle scripts and all <diva-framework> code.
  2. Replace each place that opened DIVA with the matching widget element from the table above.
  3. Add the widget script once per page, after the widget elements.
  4. Name your event handlers in data-diva-event-* attributes on the widget element, see Configurator Events. The function receives the same data that event.detail contained before.
  5. Test the whole lifecycle: start a new configuration, save it, reopen it from the link in the PDF and, if used, add it to the cart.
info

If your current integration renders the Configurator inside a container on your page instead of fullscreen, use the Direct widget with data-diva-fullscreen="false", see Direct, inside your page.