simple notification widget.
npm install --save ldnotify
include ldnotify.js and ldnotify.css, then send a notification with:
ldnotify.send('success', 'message of your notification');
send takes an optional third argument to override options for that single
message:
ldnotify.send('danger', 'upload failed', {delay: 6000, dismissible: false});
Available per-message options:
- delay: how long this message is shown, in ms. defaults to the instance
delay. - dismissible: whether this message can be closed by clicking on it.
defaults to the instance
dismissible.
send returns the created message node.
By default there are following type of messages:
- success
- info
- warning
- danger
- light
- dark
create a ldnotify object to customize it:
ldn = new ldnotify({ ... options ... });
Following are the available options:
- className: default CSS class for message box.
- Should be array or space-separated string.
- Default
ldnotify-item.
- classIn: CSS class for transition-in animation.
- Should be array or space-separated string.
- Default
ldnotify-in.
- classOut: CSS class for transition-out animation.
- Should be array or space-separated string.
- Default
ldnotify-out.
- delay: how long a message is shown. default
3000( in ms ). - dismissible: if true, a message can be closed by clicking on it. default
true. - classDismissible: CSS class applied to dismissible messages.
- Should be array or space-separated string.
- Default
ldnotify-dismissible.
- class-by-type(type): type class generator function. should return a css class name corresponding to the input type.
- default
function(type) { return "ldnotify-" + type; }. - there is no limitation about the type you want to use, but you have to add the corresponding classes yourself.
- default
- root: container of messages. auto created if omitted.
sample icons are provided by feathericons.com.