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/alert/index.jsx

72 lines
2.4 KiB
React

10 years ago
import React from 'react';
export default React.createClass({
getDefaultProps() {
return {prefixCls: 'ant-alert'};
},
getInitialState () {
return {display: 'block'};
},
handleClose () {
10 years ago
if (this.props.onClose) {
this.props.onClose();
10 years ago
}
this.setState({
display: 'none'
});
},
render () {
var iconClass = this.props.description ? 'ant-alert-with-description-icon anticon-' : 'ant-alert-icon anticon-';
10 years ago
switch (this.props.type) {
10 years ago
case 'success':
iconClass += 'check-circle';
break;
case 'info':
iconClass += 'question-circle';
break;
case 'error':
case 'warn':
iconClass += 'info-circle';
break;
default:
iconClass += 'default';
}
if (this.props.description) {
let close = this.props.closable === 'true' ?
<a onClick={this.handleClose} className={'ant-alert-with-description-close-icon'}><span
className='ant-alert-with-description-close-icon-x'></span></a> : '';
10 years ago
return (
<div style={{display: this.state.display}}
className={'ant-alert-with-description ant-alert-with-description-' + this.props.type}>
10 years ago
<i className={'anticon ' + iconClass}></i>
<p className={'ant-alert-with-description-message'}>{this.props.message}</p>
<span className={'ant-alert-with-description-description'}>{this.props.description}</span>
{close}
10 years ago
</div>
);
} else {
10 years ago
if (this.props.closeText) {
10 years ago
return (
10 years ago
<div style={{display: this.state.display}} className={'ant-alert ant-alert-' + this.props.type}>
10 years ago
<i className={'anticon ' + iconClass}></i>
<span className={'ant-alert-description'}>{this.props.message}</span>
10 years ago
<span onClick={this.handleClose} className={'ant-alert-close-text'}>{this.props.closeText}</span>
10 years ago
</div>
);
} else {
let close = this.props.closable === 'true' ?
<a onClick={this.handleClose} className={'ant-alert-close-icon'}>
<span className='ant-alert-close-icon-x'></span>
</a> : '';
10 years ago
return (
10 years ago
<div style={{display: this.state.display}} className={'ant-alert ant-alert-' + this.props.type}>
10 years ago
<i className={'anticon ' + iconClass}></i>
<span className={'ant-alert-description'}>{this.props.message}</span>
{close}
10 years ago
</div>
);
}
}
}
});