1.1.0 • Published 6 years ago
A library to show nice notifications in web application.
VIEW DEMO
Installation
// npm install
npm install @dacoto/notify.js
// yarn install
npm add @dacoto/notify.js
Usage
Include
import Notify from '@dacoto/notify.js';
CDN
<script src="//cdn.jsdelivr.net/npm/@dacoto/notify.js/dist/notify.min.js"></script>
Notification example
let options = {
title: 'Notification title',
message: 'Notification message',
icon: 'fas fa-home',
};
let type = 'primary';
var notification = new Notify(options, type);
notification.open();
notification.close();
Notification Params
Options
| Props | Default value | Description | Type | Required |
|---|
| title | | Notification title | string | X |
| message | | Notification message | string | X |
| icon | notify-icon notify-icon-primary | Class of notification icon, similar to this:<i class="notify-icon notify-icon-primary"></i> | string | |
| link | | Link at the end of the notification (see link table) | array | |
| width | 420 | Width in pixels of the notification | integer | |
| duration | 0 | The amount of time in milliseconds before closing the notification. 0 means never closed | integer | |
| autoOpen | true | Open the notification when instantiate it | boolean | |
| onOpen | | Callback for the open event | function | |
| onClose | | Callback for the hide event | function | |
Link
| Props | Note | Type | Required |
|---|
| linkHref | Link url | url | X |
| linkClass | Link class | string | X |
| linkText | Link text | string | X |
Type
| Prop | Color | Icon |
|---|
| primary | #4d9aff | |
| success | #59d9a4 | |
| warning | #ffc400 | |
| danger | #ff542e | |
Notification methods
| Name | Note |
|---|
| open() | Opens the notification |
| close() | Closes the notification |
License
MIT