xerdi:toast

v0.0.4Published last year

Meteor Toast

Admin-LTE Toasts for MeteorJS.

Installation

Add the package to your project:

meteor add xerdi:toast

Also see xerdi:admin-lte (requirement).

Usage

The toast will by default be placed in .toasts which is included in xerdi:admin-lte. To change that you can set Toast.containerSelector to your container.

To show a toast, you can do the following:

1const toast = new Toast({
2    title: 'My Title',
3    icon: 'fas fa-icons',
4    image: '/path/to/image',
5    defaultAction: '/myMessages',
6    createdAt: new Date(),
7    close: false,
8    body: 'Hi <b>there</b>!',
9    'class': 'bg-danger'
10});
11
12toast.show();
13toast.hide();

The toast will be destroyed when hidden.

There are also two short-hands for showing a success message or error message.

1Toast.success('A success message', {title: 'Title override'});
2try {
3    // ... faulty code
4} catch(e) {
5    Toast.error(e);
6    // or
7    Toast.error(e.reason)
8}

When using these short-hands, the toast will be shown in advance. The locale keys of the default titles are xerdi:toast.errorTitle and xerdi:toast.successTitle.