Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mlms13/simple-note
https://github.com/mlms13/simple-note
Last synced: 25 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mlms13/simple-note
- Owner: mlms13
- Created: 2015-01-26T01:43:29.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-28T05:53:49.000Z (over 9 years ago)
- Last Synced: 2024-04-15T12:13:24.480Z (7 months ago)
- Language: JavaScript
- Size: 160 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Super Duper Easy Notifications
Have you ever wanted to add a simple notification system to your web app? Of course you have. And you probably did, with very little code. But could your notification system handle queueing and replacing existing notifications? Well neither can this one.
### Installation
This module is intended to be installed with npm and bundled into your app with Browserify.
```js
npm install --save simple-note
```### Usage
Your notification system is made up of two parts: the notifier and the actual notes. Mostly, you'll interact with the notifier, passing it data that will create the individual notes.
Let's assume you've required the module thusly:
```js
var Notifier = require('simple-note');
```Create a new notification area:
```js
// all options passed to Notifier are optional
var notifications = new Notifier({
// element that notes will be appended to, defaults to document.body
container: document.querySelector('#my-notification-area'),// an array of initial notes to be shown, see below for note options
notes: [{/* note options */}]
});
```Once you've created a notification area, you can add notes, remove notes, and clear all notes.
```js
// add a new note to the notification area
var myFirstNote = notifications.addNote(/* note options */);// remove a single note
notifications.removeNote(myFirstNote);// or you could have cleared all notes
notifications.clear();
```Whenever you want to pass note options to the notification area, they should looks something like this:
```js
{
message: "This is your notification text.",
type: "info", // will be used in the class name
duration: 4000 // optional time in milliseconds before the note is auto-removed
}
```