Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step #26

Closed
wants to merge 9 commits into from
Closed

Step #26

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions components/step/index.md

This file was deleted.

42 changes: 42 additions & 0 deletions components/steps/demo/custom-icon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Steps 自定义图标步进条

- order: 2

通过设置`Steps.Step`的`icon`属性,可以启用自定义图标。

---

````css
.my-step-icon {
width: 35px;
height: 35px;
font-size: 35px;
line-height: 1;
position: relative;
top: -9px;
}

.my-step-icon > img {
width: 45px;
height: 45px;
}
````

````jsx
'use strict';

var Steps = antd.Steps;

var container = document.getElementById('components-steps-demo-custom-icon');

var imgIcon = <div className='my-step-icon'><img src='https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg'/></div>


React.render(
<Steps>
<Steps.Step status='finish' title='步骤1' icon={<div className='my-step-icon'><span className='anticon anticon-cloud'></span></div>}></Steps.Step>
<Steps.Step status='process' title='步骤2' icon={imgIcon}></Steps.Step>
<Steps.Step status='wait' title='步骤3' icon={<div className='my-step-icon'><span className='anticon anticon-github'></span></div>}></Steps.Step>
</Steps>, container);

````
46 changes: 46 additions & 0 deletions components/steps/demo/simple.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Steps 基本用法

- order: 0

简单的步进条

---

````jsx
'use strict';

var Steps = antd.Steps;

var container = document.getElementById('components-steps-demo-simple');


var steps = [{
status: 'finish',
title: '已完成',
description: '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶'
}, {
status: 'process',
title: '进行中',
description: '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶'
}, {
status: 'wait',
title: '待运行',
description: '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶'
}, {
status: 'wait',
title: '待运行',
description: '这里是多信息的描述啊描述啊描述啊描述啊哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶哦耶'
}].map(function(s, i) {
return (<Steps.Step
key={i}
status={s.status}
title={s.title}
description={s.description}></Steps.Step>
);
});

React.render(
<Steps>
{steps}
</Steps>, container);
````
42 changes: 42 additions & 0 deletions components/steps/demo/small-size.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Steps 迷你版步进条

- order: 1

迷你版的步进条,通过设置`<Steps size='small'>`启用.

---

````jsx
'use strict';

var Steps = antd.Steps;

var container = document.getElementById('components-steps-demo-small-size');


var steps = [{
status: 'finish',
title: '已完成'
}, {
status: 'process',
title: '进行中'
}, {
status: 'wait',
title: '待运行'
}, {
status: 'wait',
title: '待运行'
}].map(function(s, i) {
return (<Steps.Step
key={i}
status={s.status}
title={s.title}
></Steps.Step>
);
});

React.render(
<Steps size="small">
{steps}
</Steps>, container);
````
71 changes: 71 additions & 0 deletions components/steps/demo/step-next.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Steps 如何控制切换到下一步

- order: 3

---

````css
.my-step-form {
width: 100%;
}
.my-step-form > div {
margin-bottom: 20px;
}
.my-step-container {
width: 100%;
}
````

````jsx
var container = document.getElementById('components-steps-demo-step-next');
var steps = (function generateRandomSteps() {
var n = Math.floor(Math.random() * 3) + 3;
var arr = [];
for (var i = 0; i < n; i++ ) {
arr.push({
title: '步骤' + (i+1)
});
}
return arr;
})();

var MyForm = React.createClass({
getInitialState() {
return {
currentStep: Math.floor(Math.random() * steps.length)
}
},
nextStep() {
var s = this.state.currentStep + 1;
if (s === steps.length) {
s = 0;
}
this.setState({
currentStep: s
});
},
render() {
var cs = this.state.currentStep;
return (<form className='my-step-form'>
<div>这个demo随机生成3~6个步骤,初始随机进行到其中一个步骤</div>
<div>当前正在执行第{cs + 1}步</div>
<div className='my-step-container'><Steps>
{steps.map(function(s, i) {
return <Steps.Step
key={i}
status={cs === i ? 'process' : (cs > i ? 'finish' : 'wait')}
title={s.title}
></Steps.Step>
})}
</Steps></div>
<div>表单输入A:<input /></div>
<div>表单输入B:<input /></div>
<div>表单输入C:<input /></div>
<div><span className='ant-btn' onClick={this.nextStep}>下一步</span></div>
</form>)
}
});

React.render(<MyForm></MyForm>, container);

````
3 changes: 3 additions & 0 deletions components/steps/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('rc-steps');
39 changes: 39 additions & 0 deletions components/steps/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Steps

- category: Components
- chinese: 步进条
- order: 8
- cols: 1

---

脚踏实地一步步走

## 何时使用

当需要对表单输入进行分步骤的录入数据时

## API

### Steps

步进条的整体

| 参数 | 说明 | 类型 | 可选值 |默认值 |
|-----------|------------------------------------------|------------|-------|--------|
| size | 可选参数,指定大小(目前只支持普通和迷你两种大小) | string | small, default | default |

### Steps.Step

步进条的每一个步

| 参数 | 说明 | 类型 | 可选值 |默认值 |
|-----------|------------------------------------------|------------|-------|--------|
| status | 必要参数,指定状态 | string | wait, process, finish | 无 |
| title | 必要参数,标题 | string/jsx | 无 | 无 |
| description | 可选参数,步骤的详情描述 | string/jsx | 无 | 空 |
| icon | 可选参数,步骤的Icon。如果不指定,则使用默认的样式。 | string/jsx | 无 | 空 |

## Todo

* 竖状步进条
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var antd = {
Popover: require('./components/popover'),
Select: require('./components/select'),
Popconfirm: require('./components/popconfirm'),
confirm: require('./components/modal/confirm')
confirm: require('./components/modal/confirm'),
Steps: require('./components/steps')
};

module.exports = window.antd = antd;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"rc-progress": "~1.0.0",
"rc-select": "~4.0.0",
"rc-tabs": "~5.1.0",
"rc-tooltip": "~2.1.1"
"rc-tooltip": "~2.1.1",
"rc-steps": "~1.0.2"
},
"devDependencies": {
"babel-core": "~5.4.7",
Expand Down
1 change: 1 addition & 0 deletions style/components/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
@import "form";
@import "loading";
@import "progress";
@import "steps";