You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design/components/notification/index.jsx

62 lines
1.9 KiB
React

10 years ago
import Notification from 'rc-notification';
Notification.show = function (args) {
if (!Notification.notification) {
Notification.notification = Notification.newInstance({
prefixCls: 'ant-notification',
style: {
top: 0,
right: 0
}
});
10 years ago
}
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>
10 years ago
<p className={prefixCls + 'description'}>{args.description}</p>
10 years ago
</div>,
duration: null,
closable: true,
onClose: args.onClose,
10 years ago
style: {}
});
} else {
if (!args.btn) {
let prefixCls = 'ant-notification-notice-content-';
Notification.notification.notice({
content: <div>
<p className={prefixCls + 'message'}>{args.message}</p>
<p className={prefixCls + 'description'}>{args.description}</p>
</div>,
10 years ago
duration: null,
closable: true,
onClose: args.onClose,
10 years ago
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>
10 years ago
<p className={prefixCls + 'description'}>{args.description}</p>
<span onClick={args.customClose ? args.customClose.bind(null, key) : Notification.notification.removeNotice.bind(null, key)} className={prefixCls + 'btn'}>
10 years ago
{args.btn}
</span>
10 years ago
</div>,
duration: null,
closable: true,
onClose: args.onClose,
10 years ago
key: key,
style: {}
});
}
}
};
export default Notification;