diff --git a/.babelrc b/.babelrc
new file mode 100644
index 0000000000..4687bc4f44
--- /dev/null
+++ b/.babelrc
@@ -0,0 +1,3 @@
+{
+ "presets": ["es2015", "react", "stage-0"]
+}
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000000..3c85116424
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,56 @@
+'use strict';
+
+const eslintrc = {
+ extends: ['eslint-config-airbnb'],
+ env: {
+ browser: true,
+ node: true,
+ mocha: true,
+ jest: true,
+ es6: true,
+ },
+ parser: 'babel-eslint',
+ parserOptions: {
+ ecmaVersion: 6,
+ ecmaFeatures: {
+ jsx: true,
+ experimentalObjectRestSpread: true,
+ },
+ },
+ plugins: [
+ 'markdown',
+ 'react',
+ 'babel',
+ ],
+ rules: {
+ 'func-names': 0,
+ 'arrow-body-style': 0,
+ 'react/sort-comp': 0,
+ 'react/prop-types': 0,
+ 'react/jsx-first-prop-new-line': 0,
+ 'import/no-unresolved': 0,
+ 'no-param-reassign': 0,
+ 'no-return-assign': 0,
+ 'max-len': 0,
+ 'consistent-return': 0,
+ 'no-redeclare': 0,
+ }
+};
+
+if (process.env.RUN_ENV === 'DEMO') {
+ eslintrc.globals = {
+ React: true,
+ ReactDOM: true,
+ mountNode: true,
+ };
+
+ Object.assign(eslintrc.rules, {
+ 'no-console': 0,
+ 'eol-last': 0,
+ 'prefer-rest-params': 0,
+ 'react/no-multi-comp': 0,
+ 'react/prefer-es6-class': 0,
+ });
+}
+
+module.exports = eslintrc;
diff --git a/.eslintrc.json b/.eslintrc.json
deleted file mode 100644
index 20e3bc4c84..0000000000
--- a/.eslintrc.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "extends": ["eslint-config-airbnb"],
- "env": {
- "browser": true,
- "node": true,
- "mocha": true,
- "jest": true,
- "es6": true
- },
- "parserOptions": {
- "ecmaVersion": 6,
- "ecmaFeatures": {
- "jsx": true,
- "experimentalObjectRestSpread": true
- }
- },
- "plugins": [
- "markdown",
- "react",
- "babel"
- ],
- "rules": {
- "comma-dangle": 0,
- "func-names": 0,
- "prefer-const": 0,
- "arrow-body-style": 0,
- "react/sort-comp": 0,
- "react/no-multi-comp": 0,
- "react/prop-types": 0,
- "react/prefer-es6-class": 0,
- "react/prefer-stateless-function": 0,
- "react/jsx-closing-bracket-location": 0,
- "react/jsx-no-bind": 0,
- "no-param-reassign": 0,
- "no-return-assign": 0,
- "max-len": 0,
- "consistent-return": 0
- }
-}
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index c35dd85b40..c8a17cbf92 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -13,7 +13,7 @@ The following guidelines are about *How to avoid Homework Questions*.
### 1. Read the documentation.
-It sad but true that someone just glance(not read) [Ant Design's documentation](http://ant.design/). Please read the documentation closely. What's more, you can modify and run our demo with [CodePen](http://codepen.io/anon/pen/pgdXYp?editors=001). It's helpful to understand our documentation.
+It sad but true that someone just glance(not read) [Ant Design's documentation](http://ant.design/). Please read the documentation closely. What's more, you can modify and run our demo with [CodePen](http://codepen.io/anon/pen/wGOWGW?editors=001). It's helpful to understand our documentation.
Tips: choose the corresponding documentation with versions selector which in the bottom-right corner.
@@ -36,7 +36,7 @@ It is a good habit which will save maintainers' time. Thank you!
## Providing a demo while reporting a bug
-It would be helpful to provide a demo which can re-produce the bug 100%. Please fork this [CodePen](http://codepen.io/anon/pen/pgdXYp?editors=001) and re-produce the bug you met. Then, create an issue. The most important thing is: double check before claiming that you have found a bug.
+It would be helpful to provide a demo which can re-produce the bug 100%. Please fork this [CodePen](http://codepen.io/anon/pen/wGOWGW?editors=001) and re-produce the bug you met. Then, create an issue. The most important thing is: double check before claiming that you have found a bug.
## Tips about Feature Request
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 198e2c64af..df4acf956e 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -1,25 +1,27 @@
-If you want to ask a question, please read [some tips](https://github.com/ant-design/ant-design/blob/master/.github/CONTRIBUTING.md#do-your-homework-before-asking-a-question) first :-)
+
-If you are going to report a bug, please answer the following questions, thank you!
+
-## What you did
+#### 本地环境
-(e.g. I ate a hamburger)
+
-## What you would like to happen
+- antd 版本:
+- 操作系统及其版本:
+- 浏览器及其版本:
-(e.g. I should be full)
+#### 你做了什么?
-## What actually happened
+
-(e.g. But I am still hungry now T_T)
+#### 你期待的结果是:
-## Online demo
+
-(e.g. http://codepen.io/anon/pen/pgdXYp?editors=001)
+#### 实际上的结果:
-## Environment Information
+
-- The version of antd(e.g. 0.12.0):
-- Your operating system and it's version(e.g. OSX 10.11.0):
-- Your browser and it's version(e.g. Chrome 48.0.0.0(64-bit)):
+#### 可重现的在线演示
+
+
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index f9760a3504..01e6ca426d 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -2,6 +2,7 @@ First of all, thanks for your contribution! :-)
Please makes sure these boxes are checked before submitting your PR, thank you!
-[ ] Run `npm run lint` and fix those errors before submitting in order to keep consistent code style.
-[ ] Rebase before creating a PR to keep commit history clear.
-[ ] Add some descriptions and refer relative issues for you PR.
+* [ ] Make sure you follow antd's [code convention](https://github.com/ant-design/ant-design/wiki/Code-convention-for-antd).
+* [ ] Run `npm run lint` and fix those errors before submitting in order to keep consistent code style.
+* [ ] Rebase before creating a PR to keep commit history clear.
+* [ ] Add some descriptions and refer relative issues for you PR.
diff --git a/.gitignore b/.gitignore
index 16d51bb2c5..86665f9ab8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,7 +21,11 @@ node_modules/
npm-debug.log
nohup.out
_site
+_data
dist
-lib
+/lib
elasticsearch-*
-config/base.yaml
\ No newline at end of file
+config/base.yaml
+typings
+components/**/*.js
+components/**/*.jsx
diff --git a/.lesshintrc b/.lesshintrc
index 3aeecaf82e..d798ace465 100644
--- a/.lesshintrc
+++ b/.lesshintrc
@@ -8,5 +8,12 @@
"qualifyingElement": false,
"duplicateProperty": false,
"importPath": false,
- "finalNewline": false
+ "finalNewline": false,
+ "excludedFiles": [
+ "components/layout/style/mixin.less",
+ "components/style/core/base.less",
+ "components/style/core/iconfont.less",
+ "components/style/core/normalize.less",
+ "components/style/mixins/compatibility.less"
+ ]
}
diff --git a/.travis.yml b/.travis.yml
index ac4e4ca10b..517c87fa04 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,5 +3,4 @@ sudo: false
language: node_js
node_js:
- - "4"
- "5"
diff --git a/404.html b/404.html
deleted file mode 100644
index 3dad29c419..0000000000
--- a/404.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
+, mountNode);
+````
diff --git a/components/back-top/demo/custom.md b/components/back-top/demo/custom.md
new file mode 100644
index 0000000000..168db769ab
--- /dev/null
+++ b/components/back-top/demo/custom.md
@@ -0,0 +1,39 @@
+---
+order: 1
+title:
+ zh-CN: 自定义样式
+ en-US: Custom style
+---
+
+## zh-CN
+
+可以自定义回到顶部按钮的样式,限制宽高:`40px * 40px`。
+
+## en-US
+
+You can customize the style of the button, just note the size limit: no more than `40px * 40px`.
+
+
+````jsx
+import { BackTop } from 'antd';
+
+const style = {
+ height: 40,
+ width: 40,
+ lineHeight: '40px',
+ borderRadius: 4,
+ backgroundColor: '#57c5f7',
+ color: '#fff',
+ textAlign: 'center',
+ fontSize: 20,
+};
+
+ReactDOM.render(
+
+
+
UP
+
+ 向下滚动后,见右下角蓝色按钮
+
+, mountNode);
+````
diff --git a/components/back-top/index.en-US.md b/components/back-top/index.en-US.md
new file mode 100644
index 0000000000..91a54eea1b
--- /dev/null
+++ b/components/back-top/index.en-US.md
@@ -0,0 +1,25 @@
+---
+category: Components
+type: Other
+title: BackTop
+---
+
+`BackTop` makes it easy to go back to the top of the page.
+
+## When To Use
+
+- When the page content is very long.
+- When you need to go back to the top very frequently in order to view the contents.
+
+## API
+
+> The distance to the bottom is set to `50px` by default, which is overridable.
+
+> If you decide to use custom styles, please note the size limit: no more than `40px * 40px`.
+
+
+Property | Description | Type | Default
+-----|-----|-----|------
+visibilityHeight | the `BackTop` button will not show until the scroll height reaches this value | Number | 400
+onClick | a callback function, which can be executed when you click the button | Function | -
+
diff --git a/components/back-top/index.tsx b/components/back-top/index.tsx
new file mode 100644
index 0000000000..111de53212
--- /dev/null
+++ b/components/back-top/index.tsx
@@ -0,0 +1,110 @@
+import * as React from 'react';
+import Animate from 'rc-animate';
+import Icon from '../icon';
+import addEventListener from 'rc-util/lib/Dom/addEventListener';
+import classNames from 'classnames';
+import omit from 'object.omit';
+
+function getScroll(w, top) {
+ let ret = w[`page${top ? 'Y' : 'X'}Offset`];
+ const method = `scroll${top ? 'Top' : 'Left'}`;
+ if (typeof ret !== 'number') {
+ const d = w.document;
+ // ie6,7,8 standard mode
+ ret = d.documentElement[method];
+ if (typeof ret !== 'number') {
+ // quirks mode
+ ret = d.body[method];
+ }
+ }
+ return ret;
+}
+
+interface BackTopProps {
+ visibilityHeight?: number;
+ onClick?: (event) => void;
+ prefixCls?: string;
+ className?: string;
+}
+
+export default class BackTop extends React.Component {
+ static defaultProps = {
+ onClick() {},
+ visibilityHeight: 400,
+ prefixCls: 'ant-back-top',
+ };
+
+ scrollEvent: any;
+
+ constructor(props) {
+ super(props);
+ const scrollTop = getScroll(window, true);
+ this.state = {
+ visible: scrollTop > this.props.visibilityHeight,
+ };
+ }
+
+ scrollToTop = (e) => {
+ if (e) {
+ e.preventDefault();
+ }
+ this.setScrollTop(0);
+ this.props.onClick(e);
+ }
+
+ setScrollTop(value) {
+ document.body.scrollTop = value;
+ document.documentElement.scrollTop = value;
+ }
+
+ handleScroll = () => {
+ const scrollTop = getScroll(window, true);
+ this.setState({
+ visible: scrollTop > this.props.visibilityHeight,
+ });
+ }
+
+ componentDidMount() {
+ this.scrollEvent = addEventListener(window, 'scroll', this.handleScroll);
+ }
+
+ componentWillUnmount() {
+ if (this.scrollEvent) {
+ this.scrollEvent.remove();
+ }
+ }
+
+ render() {
+ const { prefixCls, className, children } = this.props;
+ const classString = classNames({
+ [prefixCls]: true,
+ [className]: !!className,
+ });
+
+ const defaultElement = (
+
,
+ mountNode
+);
````
-
-
diff --git a/components/button/demo/button-group.md b/components/button/demo/button-group.md
index 4a6ce76c8a..5c146e4377 100644
--- a/components/button/demo/button-group.md
+++ b/components/button/demo/button-group.md
@@ -1,85 +1,75 @@
-# 按钮组合
+---
+order: 5
+title:
+ zh-CN: 按钮组合
+ en-US: Button Group
+---
-- order: 5
+## zh-CN
可以将多个 `Button` 放入 `Button.Group` 的容器中。
通过设置 `size` 为 `large` `small` 分别把按钮组合设为大、小尺寸。若不设置 `size`,则尺寸为中。
----
+## en-US
+
+Buttons can be grouped by placing multiple `Button` components into a `Button.Group`.
+
+The `size` can be set to `large`, `small` or left unset resulting in a default size.
````jsx
import { Button, Icon } from 'antd';
const ButtonGroup = Button.Group;
-ReactDOM.render(
-
基本组合
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ReactDOM.render(
+
+
Basic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
带图标按钮组合
-
-
-
-
-
-
-
-
+
With Icon
+
+
+
+
+
+
+
+
-
多个组合
-
-
-
-
-
-
-
-
-
尺寸
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-, mountNode);
+
Size
+
+
+
+
+
+
+
+
+
+
+
+
+
,
+ mountNode
+);
````
diff --git a/components/button/demo/disabled.md b/components/button/demo/disabled.md
index c082af428a..f91903e592 100644
--- a/components/button/demo/disabled.md
+++ b/components/button/demo/disabled.md
@@ -1,33 +1,35 @@
-# 不可用
+---
+order: 3
+title:
+ zh-CN: 不可用状态
+ en-US: Disabled
+---
-- order: 3
+## zh-CN
添加 `disabled` 属性即可让按钮处于不可用状态,同时按钮样式也会改变。
----
+## en-US
+
+To mark a button as disabled, add the `disabled` property to the `Button`.
````jsx
import { Button } from 'antd';
-ReactDOM.render(
-
-
-
-
-
-
-
-
-
-
-
-
-, mountNode);
+ReactDOM.render(
+
+
+
+
+
+
+
+
+
+
+
+
+
,
+ mountNode
+);
````
-
-
diff --git a/components/button/demo/icon.md b/components/button/demo/icon.md
index 877040a541..1c3c2322f3 100644
--- a/components/button/demo/icon.md
+++ b/components/button/demo/icon.md
@@ -1,57 +1,33 @@
-# 图标按钮
-
-- order: 6
-
-`Button` 内可以嵌套图标,图标可以放在文字前、后,也可以单独存在。
-
+---
+order: 1
+title:
+ zh-CN: 图标按钮
+ en-US: Icon
---
+## zh-CN
+
+当需要在 `Button` 内嵌入 `Icon` 时,可以设置 `icon` 属性,或者直接在 `Button` 内使用 `Icon` 组件。
+
+如果想控制 `Icon` 具体的位置,只能直接使用 `Icon` 组件,而非 `icon` 属性。
+
+## en-US
+
+`Button` components can contain an `Icon`. This is done by setting the `icon` property or placing an `Icon` component within the `Button`
+
+If you want specific control over the positioning and placement of the `Icon`, then that should be done by placing the `Icon` component within the `Button` rather than using the `icon` property.
+
````jsx
-import { Button, Icon } from 'antd';
+import { Button } from 'antd';
-ReactDOM.render(
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
,
-mountNode);
+ReactDOM.render(
+
+
+
+
+
+
+
,
+ mountNode
+);
````
-
-
diff --git a/components/button/demo/loading.md b/components/button/demo/loading.md
index e0e7e7e0a9..1ecbb1cc96 100644
--- a/components/button/demo/loading.md
+++ b/components/button/demo/loading.md
@@ -1,13 +1,20 @@
-# 加载中
+---
+order: 4
+title:
+ zh-CN: 加载中状态
+ en-US: Loading
+---
-- order: 4
+## zh-CN
添加 `loading` 属性即可让按钮处于加载状态,最后两个按钮演示点击后进入加载状态。
----
+## en-US
+
+A loading indicator can be added to a button by setting the `loading` property on the `Button`.
````jsx
-import { Button, Icon } from 'antd';
+import { Button } from 'antd';
const App = React.createClass({
getInitialState() {
@@ -25,33 +32,23 @@ const App = React.createClass({
render() {
return (
-, mountNode);
-````
-
-
diff --git a/components/button/demo/size.md b/components/button/demo/size.md
index eb083c7419..087c7ffadf 100644
--- a/components/button/demo/size.md
+++ b/components/button/demo/size.md
@@ -1,26 +1,28 @@
-# 按钮尺寸
+---
+order: 2
+title:
+ zh-CN: 按钮尺寸
+ en-US: Size
+---
-- order: 2
+## zh-CN
按钮有大、中、小三种尺寸。
通过设置 `size` 为 `large` `small` 分别把按钮设为大、小尺寸。若不设置 `size`,则尺寸为中。
----
+## en-US
+
+Ant Design supports a default button size as well as a large and small size.
+
+If a large or small button is desired, set the `size` property to either `large` or `small` respectively. Omit the `size` property for a button with the default size.
````jsx
import { Button } from 'antd';
ReactDOM.render(
);
- }
+ },
});
Demo = createForm()(Demo);
diff --git a/components/form/demo/validate-other.md b/components/form/demo/validate-other.md
index 68c0240720..a063d0c2bf 100644
--- a/components/form/demo/validate-other.md
+++ b/components/form/demo/validate-other.md
@@ -1,13 +1,20 @@
-# 校验其他组件
+---
+order: 12
+title:
+ zh-CN: 校验其他组件
+ en-US: Others components related to validation
+---
-- order: 12
+## zh-CN
提供以下组件表单域的校验:`Select` `Radio` `DatePicker` `InputNumber` `Cascader`。在 submit 时使用 `validateFieldsAndScroll`,进行校验,可以自动把不在可见范围内的校验不通过的菜单域滚动进可见范围。
----
+## en-US
+
+Provide validation for fllowing input filed: `Select` `Radio` `DatePicker` `InputNumber` `Cascader`. To use `validateFieldsAndScroll` with form validation, it will scroll the form to the failed input field which is not in visible area.
````jsx
-import { Select, Radio, Checkbox, Button, DatePicker, InputNumber, Form, Cascader } from 'antd';
+import { Select, Radio, Checkbox, Button, DatePicker, TimePicker, InputNumber, Form, Cascader, Icon } from 'antd';
const Option = Select.Option;
const RadioGroup = Radio.Group;
const createForm = Form.create;
@@ -41,7 +48,7 @@ let Demo = React.createClass({
checkBirthday(rule, value, callback) {
if (value && value.getTime() >= Date.now()) {
- callback(new Error('你不可能在未来出生吧!'));
+ callback(new Error("You can't be born in the future!"));
} else {
callback();
}
@@ -49,7 +56,7 @@ let Demo = React.createClass({
checkPrime(rule, value, callback) {
if (value !== 11) {
- callback(new Error('8~12之间的质数明明是11啊!'));
+ callback(new Error('The prime number between 8 to 12 is obiviously 11!'));
} else {
callback();
}
@@ -58,38 +65,44 @@ let Demo = React.createClass({
render() {
const address = [{
value: 'zhejiang',
- label: '浙江',
+ label: 'Zhe Jiang',
children: [{
value: 'hangzhou',
- label: '杭州',
+ label: 'Hang Zhou',
}],
}];
const { getFieldProps } = this.props.form;
const selectProps = getFieldProps('select', {
rules: [
- { required: true, message: '请选择您的国籍' }
+ { required: true, message: 'Please select your country' },
],
});
const multiSelectProps = getFieldProps('multiSelect', {
rules: [
- { required: true, message: '请选择您喜欢的颜色', type: 'array' },
- ]
+ { required: true, message: 'Please select your favourite colors', type: 'array' },
+ ],
});
const radioProps = getFieldProps('radio', {
rules: [
- { required: true, message: '请选择您的性别' }
- ]
+ { required: true, message: 'Please select your gender' },
+ ],
});
const birthdayProps = getFieldProps('birthday', {
rules: [
{
required: true,
type: 'date',
- message: '你的生日是什么呢?',
+ message: 'When is your birthday?',
}, {
validator: this.checkBirthday,
- }
- ]
+ },
+ ],
+ });
+ const timeProps = getFieldProps('time', {
+ getValueFromEvent: (value, timeString) => timeString,
+ rules: [
+ { required: true, message: 'Please select the time' },
+ ],
});
const primeNumberProps = getFieldProps('primeNumber', {
rules: [{ validator: this.checkPrime }],
@@ -105,74 +118,90 @@ let Demo = React.createClass({
);
diff --git a/components/form/demo/validate-static.md b/components/form/demo/validate-static.md
index c586ddf348..c5f4002fc2 100644
--- a/components/form/demo/validate-static.md
+++ b/components/form/demo/validate-static.md
@@ -1,16 +1,29 @@
-# 校验提示
+---
+order: 6
+title:
+ zh-CN: 校验提示
+ en-US: Validation message
+---
-- order: 6
+## zh-CN
我们为表单控件定义了三种校验状态,为 `` 定义 `validateStatus` 属性即可。
-validateStatus: ['success', 'warning', 'error', 'validating']。
+validateStatus: 'success', 'warning', 'error', 'validating'。
另外为输入框添加反馈图标,设置 `` 的 `hasFeedback` 属性值为 `true` 即可。
**注意**: 反馈图标只对 `` 有效。
----
+## en-US
+
+We provide three kinds of validation status for form. You can use it just define `validateStatus` property on ``.
+
+validateStatus: 'success', 'warning', 'error', 'validating'。
+
+To set `hasFeedback` property to `true` enable to display feed icon of input control.
+
+**PS**: Feed icon is just available for ``.
````jsx
import { Form, Input, DatePicker, Col } from 'antd';
@@ -19,66 +32,73 @@ const FormItem = Form.Item;
ReactDOM.render(
, mountNode);
````
diff --git a/components/form/index.en-US.md b/components/form/index.en-US.md
new file mode 100644
index 0000000000..d5b68f2f16
--- /dev/null
+++ b/components/form/index.en-US.md
@@ -0,0 +1,122 @@
+---
+category: Components
+type: Form Controls
+cols: 1
+english: Form
+---
+
+Forms are used to collect, validate, and submit the user input. They contain one or more form items.
+There are many types of form items including checkbox, radio, input, select, and more.
+
+## Form
+
+You can align the controls of a `form` using one of the following attributes:
+
+- `horizontal`:to horizontally align the `label`s and controls of the fields.
+- `inline`:to render the labels and controls of the fields in one line (by setting the display property of form controls to `inline-block`).
+
+## Form fields
+
+A form consists of one or more form fields whose type includes input, textarea, checkbox, radio, select, tag, and more.
+A form field is defined using ``.
+
+```jsx
+
+ {children}
+
+```
+
+> PS:By default, large size controls are used within a form.
+
+## API
+
+### Form
+
+**more example [rc-form](http://react-component.github.io/form/)**。
+
+| Property | Description | Type | Default Value |
+|-----------|------------------------------------------|------------|---------|
+| form | Decorated by `Form.create()` will be automatically set `this.props.form` property, so just pass to form, you don't need to set it by yourself after 1.7.0. | object | n/a
+| vertical | Use vertical layout. | boolean | false |
+| horizontal | Use horizontal layout. | boolean | false |
+| inline | Use inline alignment. | boolean | false |
+| onSubmit | Defines a function will be called if form data validation is successful. | Function(e:Event) | |
+| prefixCls | Set the CSS class name of form component (optional). | string | 'ant-form' |
+
+### Form.create(options)
+
+How to use:
+
+```jsx
+class CustomizedForm extends React.Component {}
+
+CustomizedForm = Form.create({})(CustomizedForm);
+```
+
+The following `options` are available:
+
+| Property | Description | Type |
+|-----------|------------------------------------------|------------|
+| onFieldsChange | Specify a function that will be called when the value a `Form.Item` gets changed. Usage example: saving the field's value to Redux store. | Function(props, fields) |
+| mapPropsToFields | Convert props to corresponding field value. Usage example: reading the values from Redux store. | Function(props): Object{ fieldName: Object{ value } } |
+
+If the form has been decorated by `Form.create` then it has `this.props.form` property. `this.props.form` provides some APIs as follows:
+
+| Property | Description | Type |
+|-----------|------------------------------------------|------------|
+| getFieldsValue | Get the specified fields' values. If you don't specify a parameter, you will get all fields' values. | Function([fieldNames: string[]]) |
+| getFieldValue | Get the value of a field. | Function(fieldName: string) |
+| setFieldsValue | Set the value of a field. | Function(obj: object) |
+| setFields | Set the value and error of a field. | Function(obj: object) |
+| validateFields | Validate the specified fields and get theirs values and errors. | Function([fieldNames: string[]], [options: object], callback: Function(errors, values)) |
+| validateFieldsAndScroll | This function is similar to `validateFields`, but after validation, if the target field is not in visible area of form, form will be automatically scrolled to the target field area. | same as `validateFields` |
+| getFieldError | Get the error of a field. | Function(name) |
+| isFieldValidating | Check if the specified field is being validated. | Function(name) |
+| resetFields | Reset the specified fields' value and status. If you don't specify a parameter, all the fields will be reset. | Function([names: string[]]) |
+| getFieldProps | Two-way binding for form, please read below for details. | |
+
+### this.props.form.getFieldProps(id, options)
+
+#### Special attention
+
+If you use `react@<15.3.0`, then, you can't use `getFieldProps` in functional components: https://github.com/facebook/react/pull/6534
+
+The return value of `getFieldProps` contains `id`、`value`(or any other props `valuePropName` that you specified),`ref`,`onChange`(or any other `trigger` `validateTrigger` that you specified), **shouldn't set same property again** in order to avoid conflict. If you concerntate on the details on return value, you can print them to console by `console.log`.
+
+> Don't use `defaultValue` in form, please use `initialValue` instead of it.
+
+#### getFieldProps options
+
+| Property | Description | Type | Default Value |
+|-----------|-----------------------------------------|-----|--------|
+| options.id | The unique identifier is required. | string | |
+| options.valuePropName | Props of children node, for exmaple, the prop of Switch is 'checked'. | string | 'value' |
+| options.initialValue | You can specify initial value, type, optional value of children node. | | n/a |
+| options.trigger | When to collect the value of children node | string | 'onChange' |
+| options.getValueFromEvent | To convert parameters of onChange to the value of control, for example, set value of DatePicker: `(date, dateString) => dateString` | function(..args) | [reference](https://github.com/react-component/form#optiongetvaluefromevent) |
+| options.validateTrigger | When to validate the value of children node. | string | 'onChange' |
+| options.rules | Includes validation rules. Please refer to [async-validator](https://github.com/yiminghe/async-validator) for details. | array | n/a |
+| options.onXXX | Because `getFieldProps` will replace events like `onChange`, `trigger`, `validateTrigger`, if you still want to bind these events, you may set them in `options` | function | n/a |
+| options.exclusive | Whether it is exclusive with other controls, particularly for Radio. | boolean | false |
+
+### Form.Item
+
+> If Form.Item has multiple children, `help`, `required`, and `validateStatus` can't be generated automatically.
+
+| Property | Description | Type | Optional | Default Value |
+|-----------|------------------------------------------|-----------|-------|--------|
+| label | Label text | string | | |
+| labelCol | The layout of label. You can set `span` `offset` to something like `{span: 3, offset: 12}` same as with `
+
+In most business situations,Ant Design need solve a lot of information storage problems within the design area,so based on 12 Grids System,we divided the design area into 24 aliquots.
+
+We name the divided area as 'box'.We suggest that four boxes horizontal arrangement at most, one at least.Box on the proportion of the entire screen as above picture.To ensure that the level of visual comfort,we custom typography inside of the box based on the box unit.
+
+## Outline
+
+In the grid system, we define the frame outside the information area based on row and colum,to ensure that every area can steady arrangement.
+
+Following is a brief look at how it works:
+
+* To establish a set of `column` in the horizontal direction by` row` (abbreviated col)
+* Direct your content elements should be placed in the `col`, and only` col` as the `row`
+* The column grid system is a value of 1-24 to represent its range spans.For example, three columns of equal width can be created by `.col-8`.
+* If a `row` sum of` col` more than 24, then the extra `col` as a whole will start a new line arrangement.
+
+## Flex layout
+
+Our grid systems support Flex layout to allow the child elements within the parent horizontal alignment - Left, center, right of abode, and other wide arrangement, decentralized arrangement. Between sub-elements and sub-elements, support the top of the aligned vertically centered, bottom-aligned manner. At the same time, you can define the order of elements by using 'order'.
+
+Flex layout is based on a grid 24 to define each "box" in width, but not rigidly adhere to the grid layout.
+
+## API
+
+Ant Design layout component if it can not meet your needs, you can use the excellent layout of the components of the community:
+
+- [react-flexbox-grid](http://roylee0704.github.io/react-flexbox-grid/)
+- [react-blocks](http://whoisandie.github.io/react-blocks/)
+
+### Row
+
+| Member | Explanation | Type | Default |
+|------------|-----------------|--------------------|-------------|
+| gutter | grid spacing | number | 0 |
+| type | layout mode, the optional `flex`, effective modern browser | string | |
+| align | the vertical alignment of the layout of flex: `top`` middle` `bottom` | string | `top` |
+| justify | horizontal arrangement of the layout of flex: `start`` end` `center`` space-around` `space-between` | string | `start` |
+
+### Col
+
+| Member | Explanation | Type | Default |
+|------------|-----------------|--------------------|-------------|
+| span | raster occupying the number of cells,0 corresponds to `display: none` | number | none |
+| order | raster order, under `flex` effective layout mode | number | 0 |
+| offset | the number of cells to the left of the grid spacing, no cell in grid spaceing | number | 0 |
+| push | the number of cells that raster move to the right | number | 0 |
+| pull | the number of cells that raster move to the left | number | 0 |
diff --git a/components/layout/index.md b/components/layout/index.md
deleted file mode 100644
index 2101e4a732..0000000000
--- a/components/layout/index.md
+++ /dev/null
@@ -1,140 +0,0 @@
-# Layout
-
-- category: Components
-- chinese: 布局
-- type: 基本
-- cols: 1
-
----
-
-24 栅格系统。
-
-## 设计理念
-
-
);
- }
+ },
});
function confirm() {
@@ -49,7 +57,7 @@ function confirm() {
title: 'Confirm',
content: 'Bla bla ...',
okText: 'OK',
- cancelText: 'Cancel'
+ cancelText: 'Cancel',
});
}
diff --git a/components/modal/demo/manual.md b/components/modal/demo/manual.md
new file mode 100644
index 0000000000..3d680d3b7c
--- /dev/null
+++ b/components/modal/demo/manual.md
@@ -0,0 +1,31 @@
+---
+order: 7
+title:
+ zh-CN: 手动移除
+ en-US: Manual to destroy
+---
+
+## zh-CN
+
+手动关闭modal。
+
+## en-US
+
+Manually destroying a modal.
+
+````jsx
+import { Modal, Button } from 'antd';
+
+function success() {
+ const modal = Modal.success({
+ title: 'This is a notification message',
+ content: 'This modal will be destroyed after 1 second',
+ });
+ setTimeout(() => modal.destroy(), 1000);
+}
+
+
+ReactDOM.render(
+ Success
+
, mountNode);
+````
diff --git a/components/modal/demo/position.md b/components/modal/demo/position.md
new file mode 100644
index 0000000000..fb15f62494
--- /dev/null
+++ b/components/modal/demo/position.md
@@ -0,0 +1,80 @@
+---
+order: 7
+title:
+ zh-CN: 自定义位置
+ en-US: To customize the position of modal
+---
+
+## zh-CN
+
+`1.0` 之后,Modal 的 `align` 属性被移除,您可以直接使用 `style.top` 或配合其他样式来设置对话框位置。
+
+## en-US
+
+After release `1.0`, Modal's `align` prop was removed. You can use `style.top` or other styles to
+set position of modal dialog.
+
+````jsx
+import { Modal, Button } from 'antd';
+
+const App = React.createClass({
+ getInitialState() {
+ return {
+ modal1Visible: false,
+ modal2Visible: false,
+ };
+ },
+ setModal1Visible(modal1Visible) {
+ this.setState({ modal1Visible });
+ },
+ setModal2Visible(modal2Visible) {
+ this.setState({ modal2Visible });
+ },
+ render() {
+ return (
+
+ this.setModal1Visible(true)}>Display a modal dialog at 20px to Top
+ this.setModal1Visible(false)}
+ onCancel={() => this.setModal1Visible(false)}
+ >
+
+ );
+ },
+});
+
+ReactDOM.render(, mountNode);
+````
+
+````css
+/* use css to set position of modal */
+.vertical-center-modal {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.vertical-center-modal .ant-modal {
+ top: 0;
+}
+````
diff --git a/components/modal/index.en-US.md b/components/modal/index.en-US.md
new file mode 100644
index 0000000000..8b802b454a
--- /dev/null
+++ b/components/modal/index.en-US.md
@@ -0,0 +1,66 @@
+---
+type: Views
+category: Components
+english: Modal
+---
+
+Modal dialogs.
+
+## When to use
+
+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 currtent page for user
+getting feedback or information purposes.
+Additionaly, if you need show a simple confirmation dialog, you can use `ant.Modal.confirm()`,
+and so on.
+
+
+
+## API
+
+
+| Property | Description | Type | Default |
+|------------|----------------|------------------|--------------|
+| visible | Determine whether a modal dialog is visible or not | Boolean | no |
+| confirmLoading | Determine whether to apply loading visual effect for OK button or not | Boolean | no |
+| title | The modal dialog's title | React.Element | no |
+| closable | Determine whether a close (x) button is visible on top right of the modal dialog or not | Boolean | true |
+| onOk | Specify a function that will be called when a user clicked OK button | function | no |
+| onCancel | Specify a function that will be called when a user clicked mask, close button on top right or cancel button | function(e) | no |
+| width | Width of a modal dialog | String or Number | 520 |
+| footer | Footer content | React.Element | OK and cancel button |
+| okText | Text of the OK button | String | OK |
+| cancelText | Text of the Cancel button | String | Cancel |
+| maskClosable | Determine whether to close the modal dialog when clicked mask of it. | Boolean | true |
+| style | Style of floating layer, typically used at least for adjusting the position. | Object | - |
+| wrapClassName | The class name of the container of the modal dialog | String | - |
+
+### Modal.xxx()
+
+There are five ways to display the information based on the content's nature:
+
+- `Modal.info`
+- `Modal.success`
+- `Modal.error`
+- `Modal.warning`
+- `Modal.confirm`
+
+The item listd above are all functions, expecting a settings object as parameter.
+The propeties of the object are follows:
+
+| Property | Description | Type | Default |
+|------------|----------------|------------------|---------------|
+| title | Title | React.Element or String | no |
+| content | Content | React.Element or String | no |
+| onOk | Specify a function that will be called when a user clicked OK button. The parameter of this function is a function whose execution should include closing the dialog. You can also just return a promise and when the promise is resolved, the modal dialog will also be closed | function | no |
+| onCancel | Specify a function that will be called when a user clicked Cancel button. The parameter of this function is a function whose execution should include closing the dialog. You can also just return a promise and when the promise is resolved, the modal dialog will also be closed | function | no |
+| width | Width of dialog | String or Number | 416 |
+| iconType | Type of Icon component | String | question-circle |
+| okText | Text of OK button | String | OK |
+| cancelText | Text of cancel button | String | Cancel |
+
+
diff --git a/components/modal/index.jsx b/components/modal/index.jsx
deleted file mode 100644
index c8ad51a0ac..0000000000
--- a/components/modal/index.jsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import AntModal from './Modal';
-import confirm from './confirm';
-import objectAssign from 'object-assign';
-
-AntModal.info = function (props) {
- const config = objectAssign({}, props, {
- iconClassName: 'info-circle',
- okCancel: false,
- });
- return confirm(config);
-};
-
-AntModal.success = function (props) {
- const config = objectAssign({}, props, {
- iconClassName: 'check-circle',
- okCancel: false,
- });
- return confirm(config);
-};
-
-AntModal.error = function (props) {
- const config = objectAssign({}, props, {
- iconClassName: 'exclamation-circle',
- okCancel: false,
- });
- return confirm(config);
-};
-
-AntModal.confirm = function (props) {
- const config = objectAssign({}, props, {
- okCancel: true,
- });
- return confirm(config);
-};
-
-export default AntModal;
diff --git a/components/modal/index.tsx b/components/modal/index.tsx
new file mode 100644
index 0000000000..15c355862c
--- /dev/null
+++ b/components/modal/index.tsx
@@ -0,0 +1,61 @@
+import * as React from 'react';
+import Modal from './Modal';
+import confirm from './confirm';
+import assign from 'object-assign';
+
+export interface ModalFuncProps {
+ visible?: boolean;
+ title?: React.ReactNode;
+ content?: React.ReactNode;
+ onOk?: (func: Function) => any;
+ onCancel?: (func: Function) => any;
+ width?: string | number;
+ iconClassName?: string;
+ okText?: string;
+ cancelText?: string;
+}
+Modal.info = function (props: ModalFuncProps) {
+ const config = assign({}, {
+ type: 'info',
+ iconType: 'info-circle',
+ okCancel: false,
+ }, props);
+ return confirm(config);
+};
+
+Modal.success = function (props: ModalFuncProps) {
+ const config = assign({}, {
+ type: 'success',
+ iconType: 'check-circle',
+ okCancel: false,
+ }, props);
+ return confirm(config);
+};
+
+Modal.error = function (props: ModalFuncProps) {
+ const config = assign({}, {
+ type: 'error',
+ iconType: 'cross-circle',
+ okCancel: false,
+ }, props);
+ return confirm(config);
+};
+
+Modal.warning = Modal.warn = function (props: ModalFuncProps) {
+ const config = assign({}, {
+ type: 'warning',
+ iconType: 'exclamation-circle',
+ okCancel: false,
+ }, props);
+ return confirm(config);
+};
+
+Modal.confirm = function (props: ModalFuncProps) {
+ const config = assign({}, {
+ type: 'confirm',
+ okCancel: true,
+ }, props);
+ return confirm(config);
+};
+
+export default Modal;
diff --git a/components/modal/index.md b/components/modal/index.zh-CN.md
similarity index 80%
rename from components/modal/index.md
rename to components/modal/index.zh-CN.md
index c8b39b68d3..8d970fa05a 100644
--- a/components/modal/index.md
+++ b/components/modal/index.zh-CN.md
@@ -1,9 +1,8 @@
-# Modal
-
-- type: 展示
-- category: Components
-- chinese: 对话框
-
+---
+type: Views
+category: Components
+chinese: 对话框
+english: Modal
---
模态对话框。
@@ -30,7 +29,9 @@
| footer | 底部内容 | React.Element | 确定取消按钮 |
| okText | 确认按钮文字 | String | 确定 |
| cancelText | 取消按钮文字 | String | 取消 |
-| maskClosable | 点击蒙层是否允许关闭 | Boolean | true |
+| maskClosable | 点击蒙层是否允许关闭 | Boolean | true |
+| style | 可用于设置浮层的样式,调整浮层位置等 | Object | - |
+| wrapClassName | 对话框外层容器的类名 | String | - |
### Modal.xxx()
@@ -39,6 +40,7 @@
- `Modal.info`
- `Modal.success`
- `Modal.error`
+- `Modal.warning`
- `Modal.confirm`
以上均为一个函数,参数为 object,具体属性如下:
@@ -46,10 +48,11 @@
| 参数 | 说明 | 类型 | 默认值 |
|------------|----------------|------------------|--------------|
| title | 标题 | React.Element or String | 无 |
+| content | 内容 | React.Element or String | 无 |
| onOk | 点击确定回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function | 无 |
-| onCancel | 取消回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function | 无 |
+| onCancel | 取消回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function | 无 |
| width | 宽度 | String or Number | 416 |
-| iconClassName | 图标 Icon 类型 | String | question-circle |
+| iconType | 图标 Icon 类型 | String | question-circle |
| okText | 确认按钮文字 | String | 确定 |
| cancelText | 取消按钮文字 | String | 取消 |
diff --git a/components/modal/locale.tsx b/components/modal/locale.tsx
new file mode 100644
index 0000000000..a4043d745b
--- /dev/null
+++ b/components/modal/locale.tsx
@@ -0,0 +1,21 @@
+import assign from 'object-assign';
+
+const defaultLocale = {
+ okText: '确定',
+ cancelText: '取消',
+ justOkText: '知道了',
+};
+
+let runtimeLocale = assign({}, defaultLocale);
+
+export function changeConfirmLocale(newLocale?: Object) {
+ if (newLocale) {
+ runtimeLocale = assign({}, runtimeLocale, newLocale);
+ } else {
+ runtimeLocale = assign({}, defaultLocale);
+ }
+}
+
+export function getConfirmLocale() {
+ return runtimeLocale;
+}
diff --git a/style/components/confirm.less b/components/modal/style/confirm.less
similarity index 67%
rename from style/components/confirm.less
rename to components/modal/style/confirm.less
index 19164b0378..f4773aae57 100644
--- a/style/components/confirm.less
+++ b/components/modal/style/confirm.less
@@ -1,7 +1,6 @@
@confirm-prefix-cls: ant-confirm;
.@{confirm-prefix-cls} {
-
.ant-modal-header {
display: none;
}
@@ -10,7 +9,7 @@
padding: 30px 40px;
}
- .@{confirm-prefix-cls}-body {
+ &-body {
.@{confirm-prefix-cls}-title {
color: @text-color;
font-weight: bold;
@@ -21,31 +20,16 @@
margin-left: 37px;
font-size: @font-size-base;
color: @text-color;
+ margin-top: 8px;
}
- .anticon {
+ > .anticon {
font-size: 24px;
margin-right: 10px;
padding: 0 1px;
position: relative;
top: 5px;
}
-
- .anticon-exclamation-circle {
- color: @error-color;
- }
-
- .anticon-question-circle {
- color: @warning-color;
- }
-
- .anticon-check-circle {
- color: @success-color;
- }
-
- .anticon-info-circle {
- color: @primary-color;
- }
}
.@{confirm-prefix-cls}-btns {
@@ -57,4 +41,21 @@
margin-bottom: 0;
}
}
+
+ &-error &-body > .anticon {
+ color: @error-color;
+ }
+
+ &-warning &-body > .anticon,
+ &-confirm &-body > .anticon {
+ color: @warning-color;
+ }
+
+ &-info &-body > .anticon {
+ color: @primary-color;
+ }
+
+ &-success &-body > .anticon {
+ color: @success-color;
+ }
}
diff --git a/components/modal/style/index.less b/components/modal/style/index.less
new file mode 100644
index 0000000000..17d29353d4
--- /dev/null
+++ b/components/modal/style/index.less
@@ -0,0 +1,3 @@
+@import "../../style/themes/default";
+@import "./modal";
+@import "./confirm";
diff --git a/components/modal/style/index.tsx b/components/modal/style/index.tsx
new file mode 100644
index 0000000000..416ec0177e
--- /dev/null
+++ b/components/modal/style/index.tsx
@@ -0,0 +1,5 @@
+import '../../style/index.less';
+import './index.less';
+
+// style dependencies
+import '../../button/style';
diff --git a/components/modal/style/modal.less b/components/modal/style/modal.less
new file mode 100644
index 0000000000..5f3244cda4
--- /dev/null
+++ b/components/modal/style/modal.less
@@ -0,0 +1,143 @@
+@dialog-prefix-cls: ant-modal;
+
+.@{dialog-prefix-cls} {
+ position: relative;
+ width: auto;
+ margin: 0 auto;
+ top: 100px;
+ padding-bottom: 24px;
+
+ &-wrap {
+ position: fixed;
+ overflow: auto;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ z-index: @zindex-modal;
+ -webkit-overflow-scrolling: touch;
+ outline: 0;
+ }
+
+ &-title {
+ margin: 0;
+ font-size: 14px;
+ line-height: 21px;
+ font-weight: bold;
+ }
+
+ &-content {
+ position: relative;
+ background-color: #fff;
+ border: 0;
+ border-radius: @border-radius-base;
+ background-clip: padding-box;
+ }
+
+ &-close {
+ cursor: pointer;
+ border: 0;
+ background: transparent;
+ position: absolute;
+ right: 18px;
+ top: 16px;
+ z-index: 10;
+ font-weight: 700;
+ line-height: 1;
+ text-decoration: none;
+ transition: color .3s ease;
+ color: #999;
+ outline: 0;
+
+ &-x {
+ display: block;
+ font-style: normal;
+ vertical-align: baseline;
+ text-align: center;
+ text-transform: none;
+ text-rendering: auto;
+ width: 14px;
+ height: 14px;
+ font-size: 14px;
+ line-height: 1;
+
+ &:before {
+ content: "\e62d";
+ display: block;
+ font-family: "anticon" !important;
+ }
+ }
+
+ &:focus,
+ &:hover {
+ color: #444;
+ text-decoration: none;
+ }
+ }
+
+ &-header {
+ padding: 14px 16px;
+ border-radius: @border-radius-base @border-radius-base 0 0;
+ background: #fff;
+ color: #666;
+ border-bottom: 1px solid @border-color-split;
+ }
+
+ &-body {
+ padding: 16px;
+ font-size: 12px;
+ line-height: 1.5;
+ }
+
+ &-footer {
+ border-top: 1px solid @border-color-split;
+ padding: 10px 18px 10px 10px;
+ text-align: right;
+ border-radius: 0 0 @border-radius-base @border-radius-base;
+ button + button {
+ margin-left: 8px;
+ margin-bottom: 0;
+ }
+ }
+
+ &.zoom-enter,
+ &.zoom-appear {
+ animation-duration: .3s;
+ transform: none; // reset scale avoid mousePosition bug
+ opacity: 0;
+ }
+
+ &-mask {
+ position: fixed;
+ top: 0;
+ right: 0;
+ left: 0;
+ bottom: 0;
+ background-color: #373737;
+ background-color: rgba(55, 55, 55, 0.6);
+ height: 100%;
+ z-index: @zindex-modal-mask;
+ filter: ~"alpha(opacity=50)";
+
+ &-hidden {
+ display: none;
+ }
+ }
+
+ &-open {
+ overflow: hidden;
+ }
+}
+
+
+@media (max-width: 768px) {
+ .@{dialog-prefix-cls} {
+ width: auto !important;
+ margin: 10px;
+ }
+ .vertical-center-modal {
+ .@{dialog-prefix-cls} {
+ flex: 1;
+ }
+ }
+}
diff --git a/components/notification/demo/basic.md b/components/notification/demo/basic.md
index 90ed7fb78f..12adc6c994 100644
--- a/components/notification/demo/basic.md
+++ b/components/notification/demo/basic.md
@@ -1,22 +1,29 @@
-# 基本
-
-- order: 0
-
-最简单的用法,五秒后自动关闭。
-
---
+order: 0
+title:
+ zh-CN: 基本
+ en-US: Basic
+---
+
+## zh-CN
+
+最简单的用法,4.5 秒后自动关闭。
+
+## en-US
+
+The simplest usage that close the notification box after 4.5s.
````jsx
import { Button, notification } from 'antd';
const openNotification = function () {
notification.open({
- message: '这是标题',
- description: '这是提示框的文案这是提示框的文案这是提示框的文案这是提示框的文案这是提示框的文案这是提示框的文案这是提示框的文案'
+ message: 'This is the title',
+ description: 'This is the content of the notification.This is the content of the notification.This is the content of the notification.',
});
};
ReactDOM.render(
- 打开通知提醒框
+ Open the notification box
, mountNode);
````
diff --git a/components/notification/demo/duration.md b/components/notification/demo/duration.md
index 6c999a4ddf..b8a2dc5e50 100644
--- a/components/notification/demo/duration.md
+++ b/components/notification/demo/duration.md
@@ -1,24 +1,33 @@
-# 自动关闭的延时
+---
+order: 1
+title:
+ zh-CN: 自动关闭的延时
+ en-US: Duration after which the notification box is closed
+---
-- order: 1
+## zh-CN
自定义通知框自动关闭的延时,默认`4.5s`,取消自动关闭只要将该值设为 `0` 即可。
----
+## en-US
+
+`Duration` can be used to specify how long the notification stays open. After the duration time elapses,
+the notification closes automatically. If not specified, default value is 4.5 seconds. If you set the value to 0,
+the notification box will never close automatically.
````jsx
import { Button, notification } from 'antd';
const openNotification = function () {
const args = {
- message: '这是标题',
- description: '我不会自动关闭,我不会自动关闭,我不会自动关闭,我不会自动关闭,我不会自动关闭,我不会自动关闭,我不会自动关闭',
- duration: 0
+ message: 'This is the title',
+ description: 'I will never close automatically.I will be close automatically.I will never close automatically.',
+ duration: 0,
};
notification.open(args);
};
ReactDOM.render(
- 打开通知提醒框
+ Open the notification box
, mountNode);
````
diff --git a/components/notification/demo/with-btn.md b/components/notification/demo/with-btn.md
index 1b453aa226..f5fc774f75 100644
--- a/components/notification/demo/with-btn.md
+++ b/components/notification/demo/with-btn.md
@@ -1,41 +1,48 @@
-# 自定义
+---
+order: 4
+title:
+ zh-CN: 自定义
+ en-US: Custom clase button and handler
+---
-- order: 4
+## zh-CN
自定义关闭按钮的样式和文字。
----
+## en-US
+
+To customize the style or font of the close button.
````jsx
import { Button, notification } from 'antd';
const close = function () {
- console.log('我被默认的关闭按钮关闭了!');
+ console.log('Notification was closed. Either the close button was clicked or duration time elapsed.');
};
const openNotification = function () {
const key = `open${Date.now()}`;
const btnClick = function () {
- // 隐藏提醒框
+ // to hide notification box
notification.close(key);
};
const btn = (
- 自定义关闭按钮并触发回调函数
+ To speicify a function that will be called after clicking the Close button
);
notification.open({
- message: '这是标题',
- description: '这是提示框的文案这是提示框示框的文案这是提示是提示框的文案这是提示框的文案',
+ message: 'This is the title',
+ description: 'A function will be be called after the notification is closed(automatically after the "duration" time of manually).',
btn,
key,
- onClose: close
+ onClose: close,
});
};
ReactDOM.render(
- 打开通知提醒框
+ Open the notification box
,
mountNode);
````
diff --git a/components/notification/demo/with-icon.md b/components/notification/demo/with-icon.md
index 812848aee8..454f86155b 100644
--- a/components/notification/demo/with-icon.md
+++ b/components/notification/demo/with-icon.md
@@ -1,10 +1,17 @@
-# 带有Icon的通知提醒框
+---
+order: 2
+title:
+ zh-CN: 带有Icon的通知提醒框
+ en-US: A notification box with a icon
+---
-- order: 2
+## zh-CN
通知提醒框左侧有图标。
----
+## en-US
+
+A notification box with a icon at the left side.
````jsx
import { Button, notification } from 'antd';
@@ -12,18 +19,18 @@ import { Button, notification } from 'antd';
const openNotificationWithIcon = function (type) {
return function () {
notification[type]({
- message: '这是标题',
- description: '这是提示框的文案这是提示框示框的文案这是提示是提示框的文案这是提示框的文案'
+ message: 'This is the title',
+ description: 'This is the content of the notification.This is the content of the notification.This is the content of the notification.',
});
};
};
ReactDOM.render(
, mountNode);
````
diff --git a/components/notification/index.en-US.md b/components/notification/index.en-US.md
new file mode 100644
index 0000000000..7efabf7010
--- /dev/null
+++ b/components/notification/index.en-US.md
@@ -0,0 +1,56 @@
+---
+category: Components
+type: Views
+noinstant: true
+english: Notification
+---
+
+To display a notification message globally.
+
+## When to use
+To display a notification message at the top right of the view port. Typically it can be
+used in the following cases:
+
+- A notification with complex content.
+- A notification providing a feedback based on the user interaction. Or it may show some details
+about upcoming steps the user may have to follow.
+- A notification that is pushed by the application.
+
+## API
+
+- `notification.success(config)`
+- `notification.error(config)`
+- `notification.info(config)`
+- `notification.warning(config)`
+- `notification.warn(config)`
+- `notification.close(key: String)`
+- `notification.destroy()`
+
+The properties of config are as follows:
+
+| Property | Description | Type | Default |
+|----------- |--------------------------------------------- | ----------- |--------|
+| message | The title of notification box (required) | React.Element or String | No |
+| description | The content of notification box (required) | React.Element or String | No |
+| btn | Custom close button | React.Element | No |
+| key | The unique identifer of current notification | String | No |
+| onClose | Specify a function that will be called after clicking the default close button | Function | No |
+| duration | A notification box is closed after 4.5s by default. When specifying `duration` to null or 0, it will never be closed automatically | Number | 4.5 |
+
+
+`Notification` also provide a global `config()` method that can be used for specifying the default options. Once this method is used, all the notification boxes
+will take into account these globally defined options before displaying.
+
+- `notification.config(options)`
+
+```js
+notification.config({
+ top: 100,
+ duration: 3,
+});
+```
+
+| Property | Description | Type | Default |
+|------------|--------------------|----------------------------|--------------|
+| top | Offset to top of message | Number | 24px |
+| duration | A duration to close notification automatically by default (unit: second) | Number | 4.5 |
diff --git a/components/notification/index.jsx b/components/notification/index.jsx
deleted file mode 100644
index 83ae2f6283..0000000000
--- a/components/notification/index.jsx
+++ /dev/null
@@ -1,129 +0,0 @@
-import React from 'react';
-import Notification from 'rc-notification';
-import assign from 'object-assign';
-import Icon from '../icon';
-
-let top = 24;
-let notificationInstance;
-
-function getNotificationInstance() {
- if (notificationInstance) {
- return notificationInstance;
- }
- notificationInstance = Notification.newInstance({
- prefixCls: 'ant-notification',
- style: {
- top,
- right: 0
- }
- });
- return notificationInstance;
-}
-
-function notice(args) {
- let duration;
- if (args.duration === undefined) {
- duration = 4.5;
- } else {
- duration = args.duration;
- }
-
- if (args.icon) {
- let prefixCls = ' ant-notification-notice-content-icon-';
- let iconType = '';
- switch (args.icon) {
- case 'success':
- iconType = 'check-circle-o';
- break;
- case 'info':
- iconType = 'info-circle-o';
- break;
- case 'error':
- iconType = 'exclamation-circle-o';
- break;
- case 'warn':
- iconType = 'question-circle-o';
- break;
- default:
- iconType = 'info-circle';
- }
-
- getNotificationInstance().notice({
- content:
, mountNode);
````
diff --git a/components/progress/index.en-US.md b/components/progress/index.en-US.md
new file mode 100644
index 0000000000..50d111b27d
--- /dev/null
+++ b/components/progress/index.en-US.md
@@ -0,0 +1,28 @@
+---
+category: Components
+type: Views
+title: Progress
+---
+
+To display the current progress of an operation flow.
+
+## When to use
+
+If it will take a long time to complete the operation, you can use `Progress` to show the current progress and status.
+
+- When an operation will interrupt the current interface, or it needs to run in the background for more than 2 seconds.
+- When you need to display the completion percentage of an operation.
+
+## API
+
+Property | Description | Type | Default
+-----|-----|-----|------
+type | to set the type, options: `line` `circle` | String | line
+percent | to set the completion percentage | Number | 0
+format | template function of the content | function(percent) | `percent => percent + '%'`
+status | to set the status of the progress, options: `success` `exception` `active` | String | -
+showInfo | determine whether to display the progress value and the status icon | Boolean | true
+strokeWidth `(type=line)` | to set the width of the progress bar, unit: `px` | Number | 10
+strokeWidth `(type=circle)` | to set the width of the circular progress bar, unit: percentage of the canvas width | Number | 6
+width `(type=circle)` | to set the canvas width of the circular progress bar, unit: `px` | Number | 132
+
diff --git a/components/progress/index.jsx b/components/progress/index.jsx
deleted file mode 100644
index ba5245e450..0000000000
--- a/components/progress/index.jsx
+++ /dev/null
@@ -1,181 +0,0 @@
-import { Circle as Progresscircle } from 'rc-progress';
-import React from 'react';
-import assign from 'object-assign';
-import warning from 'warning';
-import Icon from '../icon';
-
-const prefixCls = 'ant-progress';
-
-const statusColorMap = {
- normal: '#2db7f5',
- exception: '#ff5500',
- success: '#87d068'
-};
-
-let Line = React.createClass({
- propTypes: {
- status: React.PropTypes.oneOf(['normal', 'exception', 'active', 'success']),
- showInfo: React.PropTypes.bool,
- percent: React.PropTypes.number,
- strokeWidth: React.PropTypes.number,
- trailColor: React.PropTypes.string,
- format: React.PropTypes.oneOfType([
- React.PropTypes.node,
- React.PropTypes.string,
- React.PropTypes.func,
- ]),
- },
- getDefaultProps() {
- return {
- percent: 0,
- strokeWidth: 10,
- status: 'normal', // exception active
- showInfo: true,
- trailColor: '#f3f3f3'
- };
- },
- render() {
- let props = assign({}, this.props);
-
- if (parseInt(props.percent, 10) === 100) {
- props.status = 'success';
- }
-
- let progressInfo;
- let fullCls = '';
-
- if (props.format) {
- warning(typeof props.format === 'function',
- 'antd.Progress props.format type is function, change format={xxx} to format={() => xxx}');
- }
-
- let text = props.format || `${props.percent}%`;
- if (typeof props.format === 'string') {
- // 向下兼容原来的字符串替换方式
- text = props.format.replace('${percent}', props.percent);
- } else if (typeof props.format === 'function') {
- text = props.format(props.percent);
- }
-
- if (props.showInfo === true) {
- if (props.status === 'exception') {
- progressInfo = (
-
- {props.format ? text : }
-
- );
- } else if (props.status === 'success') {
- progressInfo = (
-
- {props.format ? text : }
-
- );
- } else {
- progressInfo = (
- {text}
- );
- }
- } else {
- fullCls = ` ${prefixCls}-line-wrap-full`;
- }
- let percentStyle = {
- width: `${props.percent}%`,
- height: props.strokeWidth
- };
-
- return (
-