Hero Image

Components

Dialog

Dialog component act as a "3 in 1".

You can open a dialog with either a confirm message or an alert message. You also have the possibility to open a confirm as a toaster, meaning that the alert / confirm opens in the bottom of the screen. Consult your designer with documentation if you are uncertain of how to use this.

Dialog component also handles queuing. If you try to open a dialog where a toaster is visible, the toaster will convert to a popup and open first in queue.

Code

import { Dialog, DialogConfirm, DialogConstants } from 'trinidad-ui';

const _dialog = new DialogConfirm({
  icon: 'time-limit',
  branding: DialogConstants.branding.NEUTRAL,
  title: 'Du har varit inloggad i 60 minuter.',
  actions: [
    {
      title: 'OK',
      callback: function() {
        _dialog.close(function() {
        });
      }
    }
  ]
});

const dialog = new Dialog();
dialog.add(_dialog);

//-----------------------------
// For Trinidad users
//-----------------------------
// In the world of Trinidad you can't use import, so you need to add
// a dependency to 'dialog' in your controller.
// Replace all 'DialogConstants' with svs.ui.dialog.
// Replace new DialogConfirm with new svs.ui.dialog.Confirm({...
// Replace dialog.add(_dialog) with svs.ui.dialog.api.add(dialog);

Toaster

import { Dialog, DialogConfirm, DialogConstants } from 'trinidad-ui';

const _dialog = new DialogConfirm({
  icon: 'tips',
  branding: DialogConstants.branding.NEUTRAL,
  area: DialogConstants.area.TOASTER,
  title: 'Hi, nice to see you.',
  message: [
    {
      type: DialogConstants.message.TEXT,
      text:
        'Checkout different variants of dialogs and toasters here.'
    }
  ],
  actions: [
    {
      title: 'Roger that',
      callback: function() {
        _dialog.close();
      }
    }
  ]
});

const dialog = new Dialog();
dialog.add(_dialog);

//-----------------------------
// For Trinidad users
//-----------------------------
// In the world of Trinidad you can't use import, so you need to add
// a dependency to 'dialog' in your controller.
// Replace all 'DialogConstants' with svs.ui.dialog.
// Replace new DialogConfirm with new svs.ui.dialog.Confirm({...
// Replace dialog.add(_dialog) with svs.ui.dialog.api.add(dialog);

Contextual

import { Dialog, DialogContextual, DialogConstants } from 'trinidad-ui'; import {
  AnimateInView
} from '@components/animate-in-view';

const _contextual = new DialogContextual({
  area: DialogConstants.area.CONTEXTUAL,
  branding: DialogConstants.branding.SPORT,
  attachTo: document.querySelector('.js-contextual-example-1'),
  title: '',
  message: [
    {
      type: DialogConstants.message.TEXT,
      text:
        'Simple contextual has no buttons and closes on click.'
    }
  ]
  })

const dialog = new Dialog();
dialog.add(_contextual);

//-----------------------------
// For Trinidad users
//-----------------------------
// In the world of Trinidad you can't use import, so you need to add
// a dependency to 'dialog' in your controller.
// Replace all 'DialogConstants' with svs.ui.dialog.
// Replace new DialogContextual with new svs.ui.dialog.Contextual({...
// Replace dialog.add(_contextual) with svs.ui.dialog.api.add(_contextual);

Properties

PropertyDefault valueAvailable valuesDescription
brandingtur / sport / neutral(required) Branding must be defined.
titleTitle to be displayed.
priceUsed for payment dialog NOTE it can only be used combined with the product option
productUsed for payment dialog NOTE it can only be used combined with the price option
isTicketUsed in payment dialog for Skrapspel
isVoucherUsed in payment dialog for voucher
isGamingResponsibilityfalseUsed for gamingresponsibility messages
isBagUsed in payment dialog for Rubbet/Lördagsgodis
iconcheckmarkIcon to be displayed. If dialog type is error, the icon is predefined. You may pass in another component's HTML here, such as ui/bank, as rendered HTML.
areapopuppopup / toasterWhich area it will display in.
typedefaultdefault / errorSpecify which dialog type it is.
convertToPopuptrueIf a toaster cannot become a confirm, set this to false.
allowDimmerClicktruebooleanDefaults to: 1 button = allow dimmer click, unless it's an error message. 2 buttons = do not allow
autoClose02000Set the dialog to autoclose.
requireHandshakefalseA handshake prevents the dialog queue from continuing until resolveHandshake has been called.
handshakeTimeout10000A handshake will be cancelled after this time
messageMessage array to be displayed
- typetext, checkboxSelect what message type to use.
- (value)If it is a checkbox, specify value.
- (block)falseIf it is a checkbox, set to true to use block instead of inline-block for checkbox message row.
- (align)left / center / rightForce text row alignment
actionsArray of buttons. Supports one or two.
- titleTitle of button
- showLoaderDisplay a loader on click.
- callbackCallback that triggers when button is clicked.

Methods

MethodParametersDescription
addoptionsShows the dialog with options described above.
closeCloses and opens next dialog in queue, or hides the dialog if it's the last. You may pass a callback, when you want to route for example, to make sure the animation has ended before executing.

Events

MethodParametersDescription
blockingisBlocking: true/falseTrue if dialog is open and blocking page with the dimmer. False if no dialog or toaster is open.

Callbacks

If you have checkboxes in your dialog, these values will be included in the callback on button click alongside the event: function(e, forms) If your dialog has requireHandshake: true you must run dialog.resolveHandshake(); to re-enable the dialog-queue.

Accessibility

This component has been validated to meet the WCAG 2.1 AA accessibility guidelines.

Read more about WCAG 2.1 AA.