Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ The notification object has the following properties:
|------------ |--------------- |--------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| title | string | null | Title of the notification |
| message | string | null | Message of the notification |
| getContentComponent | function | null | Return a React component to display in the notification (override other settings) |
| level | string | null | Level of the notification. Available: **success**, **error**, **warning** and **info** |
| position | string | tr | Position of the notification. Available: **tr (top right)**, **tl (top left)**, **tc (top center)**, **br (bottom right)**, **bl (bottom left)**, **bc (bottom center)** |
| autoDismiss | integer | 5 | Delay in seconds for the notification go away. Set this to **0** to not auto-dismiss the notification |
Expand Down
18 changes: 14 additions & 4 deletions src/NotificationItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ var NotificationItem = React.createClass({
var actionButton = null;
var title = null;
var message = null;
var content;
var getContentComponent = notification.getContentComponent;

if (this.state.visible) {
className = className + ' notification-visible';
Expand Down Expand Up @@ -304,12 +306,20 @@ var NotificationItem = React.createClass({
);
}

if (getContentComponent) {
content = getContentComponent(notification.uid);
} else {
content = [
title,
message,
dismiss,
actionButton
];
}

return (
<div className={ className } onClick={ this._dismiss } onMouseEnter={ this._handleMouseEnter } onMouseLeave={ this._handleMouseLeave } style={ notificationStyle }>
{ title }
{ message }
{ dismiss }
{ actionButton }
{ content }
</div>
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ var CONSTANTS = {
position: 'tr',
autoDismiss: 5,
dismissible: true,
action: null
action: null,
getContentComponent: null
}
};

Expand Down