diff --git a/components/step/index.md b/components/step/index.md deleted file mode 100644 index 83492fafcac9..000000000000 --- a/components/step/index.md +++ /dev/null @@ -1,6 +0,0 @@ -# Step - -- category: Components -- chinese: 步骤 - ---- diff --git a/components/steps/demo/custom-icon.md b/components/steps/demo/custom-icon.md new file mode 100644 index 000000000000..25ccb42af30d --- /dev/null +++ b/components/steps/demo/custom-icon.md @@ -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 =
+ + +React.render( + + }> + + }> + , container); + +```` diff --git a/components/steps/demo/simple.md b/components/steps/demo/simple.md new file mode 100644 index 000000000000..4b8404efa343 --- /dev/null +++ b/components/steps/demo/simple.md @@ -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 ( + ); + }); + +React.render( + + {steps} + , container); +```` \ No newline at end of file diff --git a/components/steps/demo/small-size.md b/components/steps/demo/small-size.md new file mode 100644 index 000000000000..781d17b94499 --- /dev/null +++ b/components/steps/demo/small-size.md @@ -0,0 +1,42 @@ +# Steps 迷你版步进条 + +- order: 1 + +迷你版的步进条,通过设置``启用. + +--- + +````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 ( + ); + }); + +React.render( + + {steps} + , container); +```` \ No newline at end of file diff --git a/components/steps/demo/step-next.md b/components/steps/demo/step-next.md new file mode 100644 index 000000000000..9d929253d7fc --- /dev/null +++ b/components/steps/demo/step-next.md @@ -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 (
+
这个demo随机生成3~6个步骤,初始随机进行到其中一个步骤
+
当前正在执行第{cs + 1}步
+
+ {steps.map(function(s, i) { + return i ? 'finish' : 'wait')} + title={s.title} + > + })} +
+
表单输入A:
+
表单输入B:
+
表单输入C:
+
下一步
+
) + } +}); + +React.render(, container); + +```` \ No newline at end of file diff --git a/components/steps/index.jsx b/components/steps/index.jsx new file mode 100644 index 000000000000..64361e183fee --- /dev/null +++ b/components/steps/index.jsx @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('rc-steps'); diff --git a/components/steps/index.md b/components/steps/index.md new file mode 100644 index 000000000000..d3b169ae1b1c --- /dev/null +++ b/components/steps/index.md @@ -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 + +* 竖状步进条 diff --git a/index.js b/index.js index dd5b60a2f7d5..c6869ef5d2cf 100644 --- a/index.js +++ b/index.js @@ -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; diff --git a/package.json b/package.json index 103d80a1a6c8..d2d6b14a7692 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/style/components/index.less b/style/components/index.less index d8328d3f0ae0..f92e210bc3a0 100644 --- a/style/components/index.less +++ b/style/components/index.less @@ -11,3 +11,4 @@ @import "form"; @import "loading"; @import "progress"; +@import "steps"; \ No newline at end of file diff --git a/style/components/steps.less b/style/components/steps.less new file mode 100644 index 000000000000..87a6c257a5b6 --- /dev/null +++ b/style/components/steps.less @@ -0,0 +1,167 @@ +@active-color: #3fc7fa; +@wait-color: #e9e9e9; + +.transition(@transition) { + -webkit-transition: @transition; + -o-transition: @transition; + transition: @transition; +} + +.rc-steps { + font-size: 0; + width: 100%; + line-height: 1.5; + + .rc-steps-item { + position: relative; + display: inline-block; + + &.rc-steps-status-wait { + .rc-steps-head { + border-color: @wait-color; + background-color: #fff; + + > .rc-steps-icon { + color: @wait-color; + } + } + } + &.rc-steps-status-process { + .rc-steps-head { + border-color: @active-color; + background-color: @active-color; + + > .rc-steps-icon { + color: #fff; + } + } + } + &.rc-steps-status-finish { + .rc-steps-head { + border-color: @active-color; + background-color: #fff; + > .rc-steps-icon { + color: @active-color; + } + } + } + + &.rc-steps-custom { + .rc-steps-head { + background: none; + border: 0; + } + &.rc-steps-status-process { + .rc-steps-title { + color: @active-color; + } + } + } + + } + + .rc-steps-head, .rc-steps-main, .rc-steps-tail { + display: inline-block; + vertical-align: top; + + } + .rc-steps-head { + border:2px solid @wait-color; + width: 24px; + height: 24px; + line-height: 24px; + text-align: center; + border-radius: 24px; + font-size: 13px; + margin-right: 12px; + .transition(background-color 0.1s ease); + .transition(border-color 0.1s ease); + + > .rc-steps-icon { + line-height: 1; + display: inline-block; + vertical-align: text-top; + color: #3fc7fa; + position: relative; + } + } + .rc-steps-main { + max-width: 75px; + margin-top: 3px; + } + .rc-steps-title { + font-size: 14px; + margin-bottom: 4px; + color: #666; + font-weight: bold; + } + .rc-steps-description { + font-size: 12px; + color: #999; + } + .rc-steps-tail { + width: 0; + position: relative; + top: 12px; + padding:0 10px; + > i { + display: inline-block; + background: @wait-color; + height: 2px; + border-radius: 1px; + width: 100%; + } + } + + &.rc-steps-small { + .rc-steps-head { + border:1px solid @wait-color; + width: 18px; + height: 18px; + line-height: 18px; + text-align: center; + border-radius: 18px; + font-size: 10px; + margin-right: 10px; + + } + .rc-steps-main { + max-width: 75px; + margin-top: 0; + } + .rc-steps-title { + font-size: 12px; + margin-bottom: 4px; + color: #666; + font-weight: bold; + } + .rc-steps-description { + font-size: 10px; + color: #999; + } + .rc-steps-tail { + top: 8px; + padding:0 8px; + > i { + height: 1px; + border-radius: 1px; + width: 100%; + } + } + } + + &.rc-steps-init, &.rc-steps-init.rc-steps-small { + .rc-steps-tail { + padding: 0; + } + } + + &.rc-steps-small .rc-steps-item.rc-steps-custom .rc-steps-head, .rc-steps-item.rc-steps-custom .rc-steps-head { + width: inherit; + height: inherit; + line-height: inherit; + border-radius: 0; + border: 0; + background: none; + } +} \ No newline at end of file