/ui/elements/toast
Exports the toast element method as mapp.ui.elements.toast()
- Source
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.
Name | Type | Description |
---|---|---|
params | Object | Params for the toast element. |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
params.actions | array | <optional> | An array of action objects to generate toast element buttons. | |
params.data_id | string | <optional> | 'ui-elements-toast' | The data-id attribute value for the element. |
params.logo | string | <optional> | A src string for a logo element. | |
params.timeout | string | <optional> | 3000 | A toast with out action elements will disappear after the timeout in ms. |
params.close | boolean | <optional> | An optional button to close the toast will be added to the toast element. | |
params.accept | string | <optional> | Shorthand for accept button. String value will be used for the label. | |
params.cancel | string | <optional> | Shorthand for cancel button. String value will be used for the label. | |
params.classlist | string | <optional> | list of classes to apply on the button, optional. Example: "raised bold accept". | |
params.content | HTMLElement | <optional> | HTML to display in the toast container. Can be text with links etc. Defaults to generic text. |
- Source
The promise will resolve to the value of the button element.
- Type:
- Promise