derby-ui-toast

Notification messages for Derby

npm install derby-ui-toast
4 downloads in the last month

derby-ui-toast

Notification messages (toasts)) for Derby.

toast

Requirements

Installation

Using npm

npm install derby-ui-toast

In app.js:

var app;
app = require('derby').createApp(module)
    .use(require('derby-ui-toast'));

Usage

In templates

<derby-ui-toast:toast>

Adding messages

model.toast(type, message, options);

type : string, the default possibilities are:

  • 'info'
  • 'success'
  • 'warning'
  • 'error'

message: string

options: object

options

  • sticky
    default: false
  • timeout
    default: 5000
  • click
    default: none

Examples:

model.toast('info', 'Everything is ok!');
model.toast('success', 'It worked!');
model.toast('warning', 'Beware!');
model.toast('error', 'An error happened!', { sticky: true });
model.toast('error', 'An error happened again!', { timeout: 1000 });
model.toast('error', 'And again!', { click: myFunction });

Removing messages

Messages will disappear in 5 seconds by default. They can also be removed by clicking the message dialog box.

Beware

The namespace derby-ui-toast will be changed later to ui.

npm loves you