From 9ce3a1ea35363416e60b83619e019602ca15bf61 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Tue, 16 May 2017 10:43:12 +0800 Subject: [PATCH] docs: update docs details for Modal, close: #6121 --- components/modal/demo/async.md | 15 ++++++----- components/modal/demo/basic.md | 10 +++---- components/modal/demo/confirm-promise.md | 4 +-- components/modal/demo/confirm.md | 6 ++--- components/modal/demo/footer.md | 7 ++--- components/modal/demo/info.md | 15 ++++++----- components/modal/demo/locale.md | 34 +++++++++++------------- components/modal/demo/manual.md | 7 ++--- components/modal/index.en-US.md | 13 ++++++--- components/modal/index.zh-CN.md | 13 ++++++--- 10 files changed, 71 insertions(+), 53 deletions(-) diff --git a/components/modal/demo/async.md b/components/modal/demo/async.md index 4e9abb6b57..41f0f07efc 100644 --- a/components/modal/demo/async.md +++ b/components/modal/demo/async.md @@ -19,7 +19,7 @@ import { Modal, Button } from 'antd'; class App extends React.Component { state = { - ModalText: 'Content of the modal dialog', + ModalText: 'Content of the modal', visible: false, } showModal = () => { @@ -29,7 +29,7 @@ class App extends React.Component { } handleOk = () => { this.setState({ - ModalText: 'The modal dialog will be closed after two seconds', + ModalText: 'The modal will be closed after two seconds', confirmLoading: true, }); setTimeout(() => { @@ -46,16 +46,17 @@ class App extends React.Component { }); } render() { + const { visible, confirmLoading, ModalText } = this.state; return (
- - Open + -

{this.state.ModalText}

+

{ModalText}

); diff --git a/components/modal/demo/basic.md b/components/modal/demo/basic.md index 8961782a38..95dd835a66 100644 --- a/components/modal/demo/basic.md +++ b/components/modal/demo/basic.md @@ -11,7 +11,7 @@ title: ## en-US -Basic modal dialog. +Basic modal. ````jsx import { Modal, Button } from 'antd'; @@ -38,16 +38,16 @@ class App extends React.Component { render() { return (
- + -

some contents...

-

some contents...

-

some contents...

+

Some contents...

+

Some contents...

+

Some contents...

); diff --git a/components/modal/demo/confirm-promise.md b/components/modal/demo/confirm-promise.md index e923790af7..008672d8be 100644 --- a/components/modal/demo/confirm-promise.md +++ b/components/modal/demo/confirm-promise.md @@ -20,7 +20,7 @@ const confirm = Modal.confirm; function showConfirm() { confirm({ - title: 'Want to delete these items?', + title: 'Do you want to delete these items?', content: 'When clicked the OK button, this dialog will be closed after 1 second', onOk() { return new Promise((resolve, reject) => { @@ -33,7 +33,7 @@ function showConfirm() { ReactDOM.render( , mountNode); ```` diff --git a/components/modal/demo/confirm.md b/components/modal/demo/confirm.md index d2482ecb12..88d0a468f2 100644 --- a/components/modal/demo/confirm.md +++ b/components/modal/demo/confirm.md @@ -19,8 +19,8 @@ const confirm = Modal.confirm; function showConfirm() { confirm({ - title: 'Want to delete these items?', - content: 'some descriptions', + title: 'Do you Want to delete these items?', + content: 'Some descriptions', onOk() { console.log('OK'); }, @@ -32,7 +32,7 @@ function showConfirm() { ReactDOM.render( , mountNode); ```` diff --git a/components/modal/demo/footer.md b/components/modal/demo/footer.md index 7a474c837f..274568fd50 100644 --- a/components/modal/demo/footer.md +++ b/components/modal/demo/footer.md @@ -42,19 +42,20 @@ class App extends React.Component { this.setState({ visible: false }); } render() { + const { visible, loading } = this.state; return (
Return, - , ]} diff --git a/components/modal/demo/info.md b/components/modal/demo/info.md index 6b6719ffa1..7de3a79a8d 100644 --- a/components/modal/demo/info.md +++ b/components/modal/demo/info.md @@ -50,10 +50,13 @@ function warning() { }); } -ReactDOM.render(
- - - - -
, mountNode); +ReactDOM.render( +
+ + + + +
, + mountNode +); ```` diff --git a/components/modal/demo/locale.md b/components/modal/demo/locale.md index a38006bfa1..6e734f40d2 100644 --- a/components/modal/demo/locale.md +++ b/components/modal/demo/locale.md @@ -23,12 +23,7 @@ class LocalizedModal extends React.Component { visible: true, }); } - handleOk = () => { - this.setState({ - visible: false, - }); - } - handleCancel = () => { + hideModal = () => { this.setState({ visible: false, }); @@ -36,14 +31,14 @@ class LocalizedModal extends React.Component { render() { return (
- +

Bla bla ...

Bla bla ...

@@ -58,14 +53,17 @@ function confirm() { Modal.confirm({ title: 'Confirm', content: 'Bla bla ...', - okText: 'OK', - cancelText: 'Cancel', + okText: '确认', + cancelText: '取消', }); } -ReactDOM.render(
- -
- -
, mountNode); +ReactDOM.render( +
+ +
+ +
, + mountNode +); ```` diff --git a/components/modal/demo/manual.md b/components/modal/demo/manual.md index 3f09e47861..52466d0c78 100644 --- a/components/modal/demo/manual.md +++ b/components/modal/demo/manual.md @@ -26,7 +26,8 @@ function success() { } -ReactDOM.render(
- -
, mountNode); +ReactDOM.render( + , + mountNode +); ```` diff --git a/components/modal/index.en-US.md b/components/modal/index.en-US.md index 8360afc114..47a765fd18 100644 --- a/components/modal/index.en-US.md +++ b/components/modal/index.en-US.md @@ -11,7 +11,7 @@ Modal dialogs. When requiring users to interact with application, but without jumping to a new page to interrupt the user's workflow, you can use `Modal` to create a new floating layer over the current page for user getting feedback or information purposes. -Additionally, if you need show a simple confirmation dialog, you can use `ant.Modal.confirm()`, +Additionally, if you need show a simple confirmation dialog, you can use `antd.Modal.confirm()`, and so on. ## API @@ -38,11 +38,11 @@ and so on. > The state of Modal will be preserved at it's component lifecircle. > If you wish to open it with brand new state everytime, you need to reset state manually. Or simply [give a new key](https://github.com/ant-design/ant-design/issues/4165) to Modal when visible is changed to `true`, React will treat it as a new component. -> ``` +> ```jsx > > ``` -### Modal.xxx() +### Modal.method() There are five ways to display the information based on the content's nature: @@ -67,6 +67,13 @@ The properties of the object are follows: | cancelText | Text of cancel button | string | Cancel | | maskClosable | Determine whether to close the modal dialog when clicked mask of it. | Boolean | `false` | +All the `Modal.method`s will return a reference, and then we can close the popup by the reference. + +```jsx +const ref = Modal.info(); +ref.destroy(); +``` +