Skip to content

Commit 2aba9cb

Browse files
committed
Merge branch 'release/0.2.3'
2 parents 3fe13f0 + 706911a commit 2aba9cb

File tree

6 files changed

+39
-24
lines changed

6 files changed

+39
-24
lines changed

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
# Change Log
1+
# CHANGELOG
2+
3+
## 0.2.3 - Oct 11, 2015
4+
5+
**Implemented enhancements:**
6+
7+
* Possibility to remove notification by uid.
8+
* Added onAdd property to notification object.
9+
* Improved styles
210

311
## 0.2.2 - Oct 10, 2015
412

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Returns the notification object to be used to programmatically dismiss a notific
8888

8989
### `removeNotification(notification)`
9090

91-
Remove programmatically a notification. This object must be returned by `addNotification()` method or contains the properties `position` and `uid` of the notification that you want to remove.
91+
Remove programmatically a notification. You can pass an object returned by `addNotification()` or by `onAdd()` callback. If passing an object, you need to make sure it must contain the `uid` property. You can pass only the `uid` too: `removeNotification(uid)`.
9292

9393
## Creating a notification
9494

@@ -103,7 +103,8 @@ The notification object has the following properties:
103103
| autoDismiss | integer | 5 | Delay in seconds for the notification go away. Set this to **0** to not auto-dismiss the notification |
104104
| dismissible | bool | true | Set if notification is dismissible by the user. [See more](#dismissible) |
105105
| action | object | null | Add a button with label and callback function. [See more](#action) |
106-
| onRemove | function | null | A callback function that will be called when the notification is about to be removed. The first argument is the original notification e.g. `function (notification) { console.log(notification.title + 'was removed'); }` |
106+
| onAdd | function | null | A callback function that will be called when the notification is successfully added. The first argument is the original notification e.g. `function (notification) { console.log(notification.title + 'was added'); }` |
107+
| onRemove | function | null | A callback function that will be called when the notification is about to be removed. The first argument is the original notification e.g. `function (notification) { console.log(notification.title + 'was removed'); }` |
107108
| uid | integer/string | null | Overrides the internal `uid`. Useful if you are managing your notifications id. Notifications with same `uid` won't be displayed. |
108109

109110

example/build/app.js

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-notification-system",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "A React Notification System fully customized",
55
"main": "dist/notification-system.js",
66
"scripts": {

src/notification-system.jsx

+14-8
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ var NotificationSystem = React.createClass({
141141

142142
notifications.push(_notification);
143143

144+
if (typeof _notification.onAdd === 'function') {
145+
notification.onAdd(_notification);
146+
}
147+
144148
this.setState({
145149
notifications: notifications
146150
});
@@ -150,15 +154,17 @@ var NotificationSystem = React.createClass({
150154
},
151155

152156
removeNotification: function(notification) {
153-
var container = this.refs['container-' + notification.position];
154-
var _notification;
155-
156-
if (container) {
157-
_notification = container.refs['notification-' + notification.uid];
158-
if (_notification) {
159-
_notification._hideNotification();
157+
var self = this;
158+
Object.keys(this.refs).forEach(function(container) {
159+
if (container.indexOf('container') > -1) {
160+
Object.keys(self.refs[container].refs).forEach(function(_notification) {
161+
var uid = notification.uid ? notification.uid : notification;
162+
if (_notification === 'notification-' + uid) {
163+
self.refs[container].refs[_notification]._hideNotification();
164+
}
165+
});
160166
}
161-
}
167+
});
162168
},
163169

164170
componentDidMount: function() {

src/styles.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var STYLES = {
8787
position: 'relative',
8888
width: '100%',
8989
cursor: 'pointer',
90-
borderRadius: '3px 3px 2px 2px',
90+
borderRadius: '2px',
9191
fontSize: '13px',
9292
margin: '10px 0 0',
9393
padding: '10px',
@@ -108,7 +108,7 @@ var STYLES = {
108108
},
109109

110110
success: {
111-
borderTop: '3px solid ' + defaultColors.success.hex,
111+
borderTop: '2px solid ' + defaultColors.success.hex,
112112
backgroundColor: '#f0f5ea',
113113
color: '#4b583a',
114114
WebkitBoxShadow: '0 0 1px rgba(' + defaultColors.success.rgb + ',' + defaultShadowOpacity + ')',
@@ -117,7 +117,7 @@ var STYLES = {
117117
},
118118

119119
error: {
120-
borderTop: '3px solid ' + defaultColors.error.hex,
120+
borderTop: '2px solid ' + defaultColors.error.hex,
121121
backgroundColor: '#f4e9e9',
122122
color: '#412f2f',
123123
WebkitBoxShadow: '0 0 1px rgba(' + defaultColors.error.rgb + ',' + defaultShadowOpacity + ')',
@@ -126,7 +126,7 @@ var STYLES = {
126126
},
127127

128128
warning: {
129-
borderTop: '3px solid ' + defaultColors.warning.hex,
129+
borderTop: '2px solid ' + defaultColors.warning.hex,
130130
backgroundColor: '#f9f6f0',
131131
color: '#5a5343',
132132
WebkitBoxShadow: '0 0 1px rgba(' + defaultColors.warning.rgb + ',' + defaultShadowOpacity + ')',
@@ -135,7 +135,7 @@ var STYLES = {
135135
},
136136

137137
info: {
138-
borderTop: '3px solid ' + defaultColors.info.hex,
138+
borderTop: '2px solid ' + defaultColors.info.hex,
139139
backgroundColor: '#e8f0f4',
140140
color: '#41555d',
141141
WebkitBoxShadow: '0 0 1px rgba(' + defaultColors.info.rgb + ',' + defaultShadowOpacity + ')',

0 commit comments

Comments
 (0)