Modal.confirm, iconClassName => iconType

pull/1411/head
afc163 9 years ago
parent db0c909ccd
commit 4c60da7316

@ -3,6 +3,7 @@ import ReactDOM from 'react-dom';
import Dialog from './Modal'; import Dialog from './Modal';
import Icon from '../icon'; import Icon from '../icon';
import Button from '../button'; import Button from '../button';
import classNames from 'classnames';
const defaultLocale = { const defaultLocale = {
okText: '确定', okText: '确定',
@ -26,9 +27,7 @@ export default function confirm(config) {
document.body.appendChild(div); document.body.appendChild(div);
let d; let d;
props.iconClassName = props.iconClassName || 'question-circle'; props.iconType = props.iconType || 'question-circle';
let iconClassType = props.iconClassName;
let width = props.width || 416; let width = props.width || 416;
@ -91,7 +90,7 @@ export default function confirm(config) {
let body = ( let body = (
<div className="ant-confirm-body"> <div className="ant-confirm-body">
<Icon type={iconClassType} /> <Icon type={props.iconType} />
<span className="ant-confirm-title">{props.title}</span> <span className="ant-confirm-title">{props.title}</span>
<div className="ant-confirm-content">{props.content}</div> <div className="ant-confirm-content">{props.content}</div>
</div> </div>
@ -119,9 +118,14 @@ export default function confirm(config) {
); );
} }
const classString = classNames({
'ant-confirm': true,
[`ant-confirm-${props.type}`]: true,
[props.className]: !!props.className,
});
ReactDOM.render(<Dialog ReactDOM.render(<Dialog
prefixCls="ant-modal" className={classString}
className="ant-confirm"
visible visible
closable={false} closable={false}
title="" title=""

@ -24,14 +24,14 @@ function info() {
function success() { function success() {
Modal.success({ Modal.success({
title: '这是一条通知信息', title: '这是一条通知信息',
content: '一些附加信息一些附加信息一些附加信息' content: '一些附加信息一些附加信息一些附加信息',
}); });
} }
function error() { function error() {
Modal.error({ Modal.error({
title: '这是一条通知信息', title: '这是一条通知信息',
content: '一些附加信息一些附加信息一些附加信息' content: '一些附加信息一些附加信息一些附加信息',
}); });
} }
@ -41,4 +41,3 @@ ReactDOM.render(<div>
<Button onClick={error}>失败提示</Button> <Button onClick={error}>失败提示</Button>
</div>, mountNode); </div>, mountNode);
```` ````

@ -3,35 +3,39 @@ import confirm from './confirm';
Modal.info = function (props) { Modal.info = function (props) {
const config = { const config = {
...props, type: 'info',
iconClassName: 'info-circle', iconType: 'info-circle',
okCancel: false, okCancel: false,
...props,
}; };
return confirm(config); return confirm(config);
}; };
Modal.success = function (props) { Modal.success = function (props) {
const config = { const config = {
...props, type: 'success',
iconClassName: 'check-circle', iconType: 'check-circle',
okCancel: false, okCancel: false,
...props,
}; };
return confirm(config); return confirm(config);
}; };
Modal.error = function (props) { Modal.error = function (props) {
const config = { const config = {
...props, type: 'error',
iconClassName: 'cross-circle', iconType: 'cross-circle',
okCancel: false, okCancel: false,
...props,
}; };
return confirm(config); return confirm(config);
}; };
Modal.confirm = function (props) { Modal.confirm = function (props) {
const config = { const config = {
...props, type: 'confirm',
okCancel: true, okCancel: true,
...props,
}; };
return confirm(config); return confirm(config);
}; };

@ -49,7 +49,7 @@ english: Modal
| onOk | 点击确定回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function | 无 | | onOk | 点击确定回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function | 无 |
| onCancel | 取消回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function | 无 | | onCancel | 取消回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function | 无 |
| width | 宽度 | String or Number | 416 | | width | 宽度 | String or Number | 416 |
| iconClassName | 图标 Icon 类型 | String | question-circle | | iconType | 图标 Icon 类型 | String | question-circle |
| okText | 确认按钮文字 | String | 确定 | | okText | 确认按钮文字 | String | 确定 |
| cancelText | 取消按钮文字 | String | 取消 | | cancelText | 取消按钮文字 | String | 取消 |

@ -1,7 +1,6 @@
@confirm-prefix-cls: ant-confirm; @confirm-prefix-cls: ant-confirm;
.@{confirm-prefix-cls} { .@{confirm-prefix-cls} {
.ant-modal-header { .ant-modal-header {
display: none; display: none;
} }
@ -31,23 +30,23 @@
position: relative; position: relative;
top: 5px; top: 5px;
} }
}
.anticon-exclamation-circle { &&-error .anticon {
color: @error-color; color: @error-color;
} }
.anticon-question-circle { &&-warning .anticon {
color: @warning-color; color: @warning-color;
} }
.anticon-check-circle { &&-success .anticon {
color: @success-color; color: @success-color;
} }
.anticon-info-circle { &&-info .anticon {
color: @primary-color; color: @primary-color;
} }
}
.@{confirm-prefix-cls}-btns { .@{confirm-prefix-cls}-btns {
margin-top: 30px; margin-top: 30px;

Loading…
Cancel
Save