├── .gitignore ├── .npmignore ├── History.md ├── Makefile ├── Readme.md ├── component.json ├── index.js ├── notification.css ├── package.json ├── template.html ├── template.js └── test └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | test/*.js 3 | test/*.css 4 | components 5 | build 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 2 | 0.0.7 / 2015-07-21 3 | ================== 4 | 5 | * component: update "dom" to v1.0.8 6 | * docs: add note about optional ms for `hide()` 7 | 8 | 0.0.6 / 2015-03-11 9 | ================== 10 | 11 | * re-add the `package.json` file 12 | * component: update "dom" to v1.0.7 13 | * component: update "emitter" to v1.2.0 14 | * component: update "description" 15 | * component: Pin deps (#10) 16 | * More readable HTML entity for the close button 17 | 18 | 0.0.4 / 2014-03-17 19 | ================== 20 | 21 | * Use escaped "×" 22 | * switching over to component/dom (as per @ianstormtaylor's comment) 23 | * remove jquery dependency 24 | * add test command to Makefile 25 | * Update emitter to 1.0.1 26 | * add .license property to component.json 27 | * add private .classname option 28 | 29 | 0.0.3 / 2012-08-30 30 | ================== 31 | 32 | * add "close" event 33 | * add `.Notification` export 34 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | build: notification.css index.js template.js components 3 | @component build 4 | 5 | template.js: template.html 6 | @component convert $< 7 | 8 | components: 9 | @component install 10 | 11 | clean: 12 | @rm -fr build components 13 | 14 | test: build 15 | @open test/index.html 16 | 17 | .PHONY: clean test 18 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Notification 2 | 3 | Notification component with a clean slate to build off of, 4 | style and position them however you like. 5 | 6 | ![js growl component](http://f.cl.ly/items/143P3r3X1E1m0Y0a2E2l/Screen%20Shot%202012-07-26%20at%203.16.11%20PM.png) 7 | 8 | These don't _have_ to look like growl style notifications, use 9 | your trusty friend CSS. 10 | 11 | ## Installation 12 | 13 | ``` 14 | $ npm install notification-component 15 | ``` 16 | 17 | ## Features 18 | 19 | - events for composition 20 | - structural CSS letting you decide on style 21 | - transient notifications 22 | - transient closable notifications 23 | - sticky (implicitly closable) notifications 24 | - notification classes (info, warn, error) 25 | - fluent API 26 | 27 | ## Events 28 | 29 | - `close` the notification is closed via the X 30 | - `click` the notification is clicked 31 | 32 | ## API 33 | 34 | ### notify(msg) 35 | 36 | Notify with the given `msg` and no title. The 37 | notification will hide after 4 seconds by default. 38 | 39 | ### notify(title, msg) 40 | 41 | Notify with the given `msg` and `title`. The 42 | notification will hide after 4 seconds by default. 43 | 44 | ### notify.info(title, [msg]) 45 | 46 | Same as `notify()` 47 | 48 | ### notify.warn(title, [msg]) 49 | 50 | Same as `notify()` with a `warn` class for styling. 51 | 52 | ### notify.error(title, [msg]) 53 | 54 | Same as `notify()` with a `error` class for styling. 55 | 56 | ### Notification#sticky() 57 | 58 | Make the notification sticky, aka it will not close 59 | automatically, and it will automatically be `.closable()`. 60 | 61 | ### Notification#show() 62 | 63 | Show the notification. 64 | 65 | ### Notification#hide([ms]) 66 | 67 | Hide the notification immediately or wait ms. 68 | 69 | ### Notification#closable() 70 | 71 | Mark the notification as closable, adding an "X" so the user 72 | may explicitly close it. 73 | 74 | ### Notification#effect(name) 75 | 76 | One of the following effects, or define your own with class `name`: 77 | 78 | - `slide` 79 | - `fade` 80 | - `scale` 81 | 82 | ## License 83 | 84 | MIT 85 | -------------------------------------------------------------------------------- /component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "notification", 3 | "description": "Notification component for the client (growl-like)", 4 | "version": "0.0.7", 5 | "keywords": [ 6 | "notify", 7 | "notification", 8 | "ui", 9 | "growl" 10 | ], 11 | "dependencies": { 12 | "component/dom": "1.0.7", 13 | "component/emitter": "1.2.0", 14 | "segmentio/on-body": "0.0.1" 15 | }, 16 | "scripts": [ 17 | "index.js", 18 | "template.js" 19 | ], 20 | "styles": [ 21 | "notification.css" 22 | ], 23 | "license": "MIT" 24 | } 25 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var dom = require('dom'); 7 | var Emitter = require('emitter'); 8 | var onBody = require('on-body'); 9 | 10 | /** 11 | * Expose `notify`. 12 | */ 13 | 14 | exports = module.exports = notify; 15 | 16 | /** 17 | * Notification list. 18 | */ 19 | 20 | var list = dom('