diff --git a/components/_util/props-util.js b/components/_util/props-util.js index 465278457..a453b943d 100644 --- a/components/_util/props-util.js +++ b/components/_util/props-util.js @@ -79,7 +79,11 @@ const getComponentFromProp = (instance, prop) => { const componentOptions = instance.componentOptions || {}; (componentOptions.children || []).forEach((child) => { if (child.data && child.data.slot === prop) { - slotsProp.push(child) + if (child.tag === 'template') { + slotsProp.push(child.children) + } else { + slotsProp.push(child) + } } }) return slotsProp.length ? slotsProp : undefined diff --git a/components/steps/demo/customized-progress-dot.md b/components/steps/demo/customized-progress-dot.md new file mode 100644 index 000000000..e89ad0f96 --- /dev/null +++ b/components/steps/demo/customized-progress-dot.md @@ -0,0 +1,39 @@ + +#### 自定义点状步骤条 +为点状步骤条增加自定义展示。 + + + +#### Customized Dot Style +You can customize the display for Steps with progress dot style. + + +```html + + +``` diff --git a/components/steps/demo/error.md b/components/steps/demo/error.md new file mode 100644 index 000000000..c34a9d54d --- /dev/null +++ b/components/steps/demo/error.md @@ -0,0 +1,19 @@ + +#### 步骤运行错误 +使用 Steps 的 `status` 属性来指定当前步骤的状态。 + + + +#### Error status +By using `status` of `Steps`, you can specify the state for current step. + + +```html + +``` diff --git a/components/steps/demo/icon.md b/components/steps/demo/icon.md new file mode 100644 index 000000000..6a9baf6a4 --- /dev/null +++ b/components/steps/demo/icon.md @@ -0,0 +1,28 @@ + +#### 带图标的步骤条 +通过设置 `Steps.Step` 的 `icon` 属性,可以启用自定义图标。 + + + +#### With icon +You can use your own custom icons by setting the property `icon` for `Steps.Step`. + + +```html + +``` diff --git a/components/steps/demo/index.vue b/components/steps/demo/index.vue index af00b5ef1..170a6b7e4 100644 --- a/components/steps/demo/index.vue +++ b/components/steps/demo/index.vue @@ -1,18 +1,64 @@ - diff --git a/components/steps/demo/progress-dot.md b/components/steps/demo/progress-dot.md new file mode 100644 index 000000000..2b3713f53 --- /dev/null +++ b/components/steps/demo/progress-dot.md @@ -0,0 +1,19 @@ + +#### 点状步骤条 +包含步骤点的进度条。 + + + +#### Dot Style +Steps with progress dot style. + + +```html + +``` diff --git a/components/steps/demo/simple.md b/components/steps/demo/simple.md new file mode 100644 index 000000000..4fac59c4a --- /dev/null +++ b/components/steps/demo/simple.md @@ -0,0 +1,25 @@ + +#### 基本用法 +简单的步骤条。 + + + +#### Basic +The most basic step bar. + + +```html + +``` diff --git a/components/steps/demo/small-size.md b/components/steps/demo/small-size.md new file mode 100644 index 000000000..27ed8df67 --- /dev/null +++ b/components/steps/demo/small-size.md @@ -0,0 +1,19 @@ + +#### 迷你版 +迷你版的步骤条,通过设置 `` 启用。 + + + +#### Mini version +By setting like this: ``, you can get a mini version. + + +```html + +``` diff --git a/components/steps/demo/step-next.md b/components/steps/demo/step-next.md new file mode 100644 index 000000000..3c4ccec14 --- /dev/null +++ b/components/steps/demo/step-next.md @@ -0,0 +1,84 @@ + +#### 步骤切换 +通常配合内容及按钮使用,表示一个流程的处理进度。 + + + +#### Switch Step +Cooperate with the content and buttons, to represent the progress of a process. + + +```html + + + +``` diff --git a/components/steps/demo/vertical-small.md b/components/steps/demo/vertical-small.md new file mode 100644 index 000000000..db8945ae3 --- /dev/null +++ b/components/steps/demo/vertical-small.md @@ -0,0 +1,19 @@ + +#### 竖直方向的小型步骤条 +简单的竖直方向的小型步骤条。 + + + +#### Vertical mini version +A simple mini version step bar in the vertical direction. + + +```html + +``` diff --git a/components/steps/demo/vertical.md b/components/steps/demo/vertical.md new file mode 100644 index 000000000..a9f738837 --- /dev/null +++ b/components/steps/demo/vertical.md @@ -0,0 +1,19 @@ + +#### 竖直方向的步骤条 +简单的竖直方向的步骤条。 + + + +#### Vertical +A simple step bar in the vertical direction. + + +```html + +``` diff --git a/components/steps/index.en-US.md b/components/steps/index.en-US.md new file mode 100644 index 000000000..d694abc27 --- /dev/null +++ b/components/steps/index.en-US.md @@ -0,0 +1,22 @@ +### Steps + +The whole of the step bar. + +| Property | Description | Type | Default | +| -------- | ----------- | ---- | ------- | +| current | to set the current step, counting from 0. You can overwrite this state by using `status` of `Step` | number | 0 | +| direction | to specify the direction of the step bar, `horizontal` and `vertical` are currently supported | string | `horizontal` | +| progressDot | Steps with progress dot style, customize the progress dot by setting it to a function | Boolean or (iconDot, {index, status, title, description}) => ReactNode | false | +| size | to specify the size of the step bar, `default` and `small` are currently supported | string | `default` | +| status | to specify the status of current step, can be set to one of the following values: `wait` `process` `finish` `error` | string | `process` | + +### Steps.Step + +A single step in the step bar. + +| Property | Description | Type | Default | +| -------- | ----------- | ---- | ------- | +| description | description of the step, optional property | string\|slot | - | +| icon | icon of the step, optional property | string\|slot | - | +| status | to specify the status. It will be automatically set by `current` of `Steps` if not configured. Optional values are: `wait` `process` `finish` `error` | string | `wait` | +| title | title of the step | string\|slot | - | diff --git a/components/steps/index.zh-CN.md b/components/steps/index.zh-CN.md new file mode 100644 index 000000000..4b1b130e0 --- /dev/null +++ b/components/steps/index.zh-CN.md @@ -0,0 +1,23 @@ + +### Steps + +整体步骤条。 + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| current | 指定当前步骤,从 0 开始记数。在子 Step 元素中,可以通过 `status` 属性覆盖状态 | number | 0 | +| direction | 指定步骤条方向。目前支持水平(`horizontal`)和竖直(`vertical`)两种方向 | string | horizontal | +| progressDot | 点状步骤条,可以设置为一个 function | Boolean or (iconDot, {index, status, title, description}) => ReactNode | false | +| size | 指定大小,目前支持普通(`default`)和迷你(`small`) | string | default | +| status | 指定当前步骤的状态,可选 `wait` `process` `finish` `error` | string | process | + +### Steps.Step + +步骤条内的每一个步骤。 + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| description | 步骤的详情描述,可选 | string\|slot | - | +| icon | 步骤图标的类型,可选 | string\|slot | - | +| status | 指定状态。当不配置该属性时,会使用 Steps 的 `current` 来自动指定状态。可选:`wait` `process` `finish` `error` | string | wait | +| title | 标题 | string\|slot | - | diff --git a/components/style.js b/components/style.js index b6c29b7f6..9798e7ba9 100644 --- a/components/style.js +++ b/components/style.js @@ -30,4 +30,5 @@ import './back-top/style' import './modal/style' import './alert/style' import './time-picker/style' +import './steps/style' import './breadcrumb/style' diff --git a/components/vc-steps/Step.vue b/components/vc-steps/Step.vue index b920d04ca..6fb37528f 100644 --- a/components/vc-steps/Step.vue +++ b/components/vc-steps/Step.vue @@ -34,10 +34,12 @@ export default { methods: { renderIconNode () { const { - prefixCls, progressDot, stepNumber, status, title, description, + prefixCls, progressDot, stepNumber, status, iconPrefix, } = getOptionProps(this) - const icon = this.icon || this.$slots.default + const icon = this.icon || this.$slots.icon + const title = this.title || this.$slots.title + const description = this.description || this.$slots.description let iconNode const iconClassName = { [`${prefixCls}-icon`]: true, @@ -71,11 +73,13 @@ export default { render () { const { prefixCls, - status = 'wait', icon, - description, title, tailContent, + status = 'wait', icon, tailContent, ...restProps } = getOptionProps(this) + const title = this.title || this.$slots.title + const description = this.description || this.$slots.description + const classString = { [`${prefixCls}-item`]: true, [`${prefixCls}-item-${status}`]: true, diff --git a/components/vc-steps/Steps.vue b/components/vc-steps/Steps.vue index 3967aa4d9..003183abb 100644 --- a/components/vc-steps/Steps.vue +++ b/components/vc-steps/Steps.vue @@ -145,7 +145,13 @@ export default { class: className, style: stepStyle, } - return {getComponentFromProp(child, 'icon')} + return ( + + + + + + ) }) } diff --git a/examples/demo.js b/examples/demo.js index b0f3a7156..1a5d540a5 100644 --- a/examples/demo.js +++ b/examples/demo.js @@ -31,3 +31,4 @@ export { default as backTop } from 'antd/back-top/demo/index.vue' export { default as modal } from 'antd/modal/demo/index.vue' export { default as alert } from 'antd/alert/demo/index.vue' export { default as timePicker } from 'antd/time-picker/demo/index.vue' +export { default as steps } from 'antd/steps/demo/index.vue'