Skip to content

Commit d166437

Browse files
committed
New addOnTop prop
1 parent e2c4a14 commit d166437

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ Using this method you have to take care of **every style**, from containers posi
218218

219219
See [#74](https://github.com/igorprado/react-notification-system/issues/74) for more details.
220220

221+
### Appending/Prepending notifications
222+
223+
You can control where should new notification appear (on the top or bottom of current notifications, defaults to bottom) by setting `newOnTop` boolean prop on `<NotificationSystem />` component:
224+
225+
```js
226+
<NotificationSystem ref="notificationSystem" newOnTop={true} />
227+
```
228+
229+
This will render new notifications on top of current ones
230+
221231
## Roadmap
222232

223233
* Improve tests and coverage

src/NotificationSystem.jsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,16 @@ var NotificationSystem = createReactClass({
9494
PropTypes.object
9595
]),
9696
noAnimation: PropTypes.bool,
97-
allowHTML: PropTypes.bool
97+
allowHTML: PropTypes.bool,
98+
newOnTop: PropTypes.bool
9899
},
99100

100101
getDefaultProps: function() {
101102
return {
102103
style: {},
103104
noAnimation: false,
104-
allowHTML: false
105+
allowHTML: false,
106+
newOnTop: false
105107
};
106108
},
107109

@@ -143,7 +145,12 @@ var NotificationSystem = createReactClass({
143145
}
144146
}
145147

146-
notifications.push(_notification);
148+
if (this.props.newOnTop) {
149+
notifications.unshift(_notification);
150+
} else {
151+
notifications.push(_notification);
152+
}
153+
147154

148155
if (typeof _notification.onAdd === 'function') {
149156
notification.onAdd(_notification);

0 commit comments

Comments
 (0)