Browse Source

fix: update modal

pull/802/head
wangxueliang 6 years ago
parent
commit
89de910478
  1. 2
      components/modal/ConfirmDialog.jsx
  2. 12
      components/modal/demo/confirm-router.md
  3. 17
      components/modal/index.js

2
components/modal/ConfirmDialog.jsx

@ -64,7 +64,7 @@ export default {
{cancelText} {cancelText}
</ActionButton> </ActionButton>
); );
const iconNode = typeof icon === 'string' ? <Icon type={icon} /> : icon; const iconNode = typeof icon === 'string' ? <Icon type={icon} /> : icon(h);
return ( return (
<Dialog <Dialog

12
components/modal/demo/confirm-router.md

@ -20,20 +20,20 @@ import Button from '../../button'
export default { export default {
methods: { methods: {
showConfirm() { showConfirm() {
const _self = this
for (let i = 0; i < 3; i += 1) { for (let i = 0; i < 3; i += 1) {
setTimeout(() => { setTimeout(() => {
this.$confirm({ this.$confirm({
content: ( content: 'destroy all',
<Button onClick={this.destroyAll}>
Click to destroy all
</Button>
),
onOk() { onOk() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
setTimeout(Math.random() > 0.5 ? resolve : reject, 1000); setTimeout(Math.random() > 0.5 ? resolve : reject, 1000);
}).catch(() => console.log('Oops errors!')); }).catch(() => console.log('Oops errors!'));
}, },
onCancel() {}, cancelText: 'Click to destroy all',
onCancel() {
_self.destroyAll()
},
}); });
}, i * 500); }, i * 500);
} }

17
components/modal/index.js

@ -1,5 +1,6 @@
import Modal, { destroyFns } from './Modal'; import Modal, { destroyFns } from './Modal';
import modalConfirm from './confirm'; import modalConfirm from './confirm';
import Icon from '../icon';
// export { ActionButtonProps } from './ActionButton' // export { ActionButtonProps } from './ActionButton'
// export { ModalProps, ModalFuncProps } from './Modal' // export { ModalProps, ModalFuncProps } from './Modal'
@ -7,7 +8,9 @@ import modalConfirm from './confirm';
const info = function(props) { const info = function(props) {
const config = { const config = {
type: 'info', type: 'info',
icon: <Icon type="info-circle" />, icon: (h) => {
return <Icon type="info-circle" />;
},
okCancel: false, okCancel: false,
...props, ...props,
}; };
@ -17,7 +20,9 @@ const info = function(props) {
const success = function(props) { const success = function(props) {
const config = { const config = {
type: 'success', type: 'success',
icon: <Icon type="check-circle" />, icon: (h) => {
return <Icon type="check-circle" />;
},
okCancel: false, okCancel: false,
...props, ...props,
}; };
@ -27,7 +32,9 @@ const success = function(props) {
const error = function(props) { const error = function(props) {
const config = { const config = {
type: 'error', type: 'error',
icon: <Icon type="close-circle" />, icon: (h) => {
return <Icon type="close-circle" />;
},
okCancel: false, okCancel: false,
...props, ...props,
}; };
@ -37,7 +44,9 @@ const error = function(props) {
const warning = function(props) { const warning = function(props) {
const config = { const config = {
type: 'warning', type: 'warning',
icon: <Icon type="exclamation-circle" />, icon: (h) => {
return <Icon type="exclamation-circle" />;
},
okCancel: false, okCancel: false,
...props, ...props,
}; };

Loading…
Cancel
Save