/ui/elements/toast

Exports the toast element method as mapp.ui.elements.toast()

Methods

(inner) toast(params) → {Promise}

The toast method creates and appends a toast HTMLElement to the document body.

The method returns a promise which will resolve to the value of a button element defined in the actions array.

const toast = mapp.ui.elements.toast({
	logo: "https://geolytix.github.io/public/mapp_v4/emblem.svg",
	content: 'Hello from ui toast!',
	actions: [{
		label: 'Accept',
		value: 'true',
		classlist: 'bold raised accept',
		callback: (e, params) => console.log(e)
	  },
	  {
		label: 'Reject',
		classlist: 'bold raised reject',
		value: 'false',
		callback: (e, params) => console.log(e)
	  }]
});

Without any actions provided the toast element will disappear after a timeout params in ms.

Parameters:
NameTypeDescription
paramsObject

Params for the toast element.

Properties
NameTypeAttributesDefaultDescription
params.actionsarray<optional>

An array of action objects to generate toast element buttons.

params.data_idstring<optional>
'ui-elements-toast'

The data-id attribute value for the element.

params.logostring<optional>

A src string for a logo element.

params.timeoutstring<optional>
3000

A toast with out action elements will disappear after the timeout in ms.

params.closeboolean<optional>

An optional button to close the toast will be added to the toast element.

params.acceptstring<optional>

Shorthand for accept button. String value will be used for the label.

params.cancelstring<optional>

Shorthand for cancel button. String value will be used for the label.

params.classliststring<optional>

list of classes to apply on the button, optional. Example: "raised bold accept".

params.contentHTMLElement<optional>

HTML to display in the toast container. Can be text with links etc. Defaults to generic text.

Returns:

The promise will resolve to the value of the button element.

Type: 
Promise