module-notification
JS library for displaying Notifications inside specified html element containers (Modules). You can create multiple independent Modules which own separate set of Notifications.
You can check out the Demo
Change log
- v2.0.0 - Removed jQuery dependency, used Font Awesome for icons
- v3.0.0 - Optimized builds, removed third-party font providers, add more animations
Installation
npm install module-notificationyarn add module-notification
Referencing
requirejs
index.html (local)
index.html (CDN)
Usage
-
Create html element where notifications will be pushed
-
Specify styles
-
Create new module
let myNotificationsModule =container: '#notifications' // required{console} -
Create group (optional)
Groups used to operate with the subset of notifications. Group may have one or more elements. You can force the group to have only one element making field
greedy
equal totrue
. It is not necessary to create group, all notifications without specifyinggroupId
will be associated with group with iddefault
.myNotificationsModule -
Add notifications
// pushNotification - appends new notification (is added from the bottom)let myNotification1 = myMNModule// unshiftNotification - prepends new notification (is added from the top)let myNotification2 = myMNModule -
Remove notification
myNotification1 -
Remove all the notifications of the specified group
myModule -
Remove all the notifications of the module
myModule
Customization
To add customized notidfications you have to:
-
Specify function which will return custom template, e.g.
const customTemplate = {return `<div class='custom-notification'><span></span><span></span><span class='mn-close-btn custom-close-btn'>[x]</span></div>`}In order to make custom notification closable by user click assign class
.mn-close-btn
to the element which will trigger closing on click, e.g.[x] -
And assign this function to
template
option:customizedNotifsModule
Example
We prepared small but pretty awesome example of customized notifications, hope you will like it

For more examples see our demo