ant-design/components/notification/index.jsx

59 lines
1.7 KiB
React
Raw Normal View History

2015-07-28 15:40:28 +08:00
import Notification from 'rc-notification';
2015-07-29 20:08:16 +08:00
function close(key, customCallback) {
2015-07-28 15:40:28 +08:00
Notification.notification.removeNotice(key);
2015-07-29 20:08:16 +08:00
if (customCallback) {
customCallback();
2015-07-28 15:40:28 +08:00
}
}
Notification.show = function (args) {
if (args.icon) {
let prefixCls = 'ant-notification-notice-content-icon-';
Notification.notification.notice({
content: <div>
<i className={'anticon anticon-question-circle-o ' + prefixCls + 'icon'}></i>
<p className={prefixCls + 'message'}>{args.message}</p>
2015-07-29 20:08:16 +08:00
<p className={prefixCls + 'description'}>{args.description}</p>
2015-07-28 15:40:28 +08:00
</div>,
duration: null,
closable: true,
2015-07-29 20:08:16 +08:00
onClose: args.defaultClose,
2015-07-28 15:40:28 +08:00
style: {}
});
} else {
if (!args.btn) {
let prefixCls = 'ant-notification-notice-content-';
Notification.notification.notice({
content: <div>
<p className={prefixCls + 'message'}>{args.message}</p>
2015-07-29 20:08:16 +08:00
<p className={prefixCls + 'description'}>{args.description}</p>
2015-07-28 15:40:28 +08:00
</div>,
duration: null,
closable: true,
2015-07-29 20:08:16 +08:00
onClose: args.defaultClose,
2015-07-28 15:40:28 +08:00
style: {}
});
} else {
let prefixCls = 'ant-notification-notice-content-';
let key = 'manual' + new Date().getTime();
Notification.notification.notice({
content: <div>
<p className={prefixCls + 'message'}>{args.message}</p>
2015-07-29 20:08:16 +08:00
<p className={prefixCls + 'description'}>{args.description}</p>
<span onClick={close.bind(null, key, args.customClose)} className={prefixCls + 'btn'}>
{args.btn}
</span>
2015-07-28 15:40:28 +08:00
</div>,
duration: null,
closable: true,
2015-07-29 20:08:16 +08:00
onClose: args.defaultClose,
2015-07-28 15:40:28 +08:00
key: key,
style: {}
});
}
}
};
export default Notification;