Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ online example: http://react-component.github.io/steps/examples/
<td>0</td>
<td>index of current step</td>
</tr>
<tr>
<td>initial</td>
<td>number</td>
<td>0</td>
<td>index initial</td>
</tr>
<tr>
<td>size</td>
<td>string</td>
Expand Down
13 changes: 8 additions & 5 deletions src/Steps.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ export default class Steps extends Component {
PropTypes.func,
]),
style: PropTypes.object,
initial: PropTypes.number,
current: PropTypes.number,
};
static defaultProps = {
prefixCls: 'rc-steps',
iconPrefix: 'rc',
direction: 'horizontal',
labelPlacement: 'horizontal',
initial: 0,
current: 0,
status: 'process',
size: '',
Expand Down Expand Up @@ -75,7 +77,7 @@ export default class Steps extends Component {
const lastStepOffsetWidth = (domNode.lastChild.offsetWidth || 0) + 1;
// Reduce shake bug
if (this.state.lastStepOffsetWidth === lastStepOffsetWidth ||
Math.abs(this.state.lastStepOffsetWidth - lastStepOffsetWidth) <= 3) {
Math.abs(this.state.lastStepOffsetWidth - lastStepOffsetWidth) <= 3) {
return;
}
this.setState({ lastStepOffsetWidth });
Expand All @@ -85,7 +87,7 @@ export default class Steps extends Component {
render() {
const {
prefixCls, style = {}, className, children, direction,
labelPlacement, iconPrefix, status, size, current, progressDot,
labelPlacement, iconPrefix, status, size, current, progressDot, initial,
...restProps,
} = this.props;
const { lastStepOffsetWidth, flexSupported } = this.state;
Expand All @@ -105,8 +107,9 @@ export default class Steps extends Component {
if (!child) {
return null;
}
const stepNumber = initial ? initial + index : index + 1;
const childProps = {
stepNumber: `${index + 1}`,
stepNumber: `${stepNumber}`,
prefixCls,
iconPrefix,
wrapperStyle: style,
Expand All @@ -122,9 +125,9 @@ export default class Steps extends Component {
childProps.className = `${prefixCls}-next-error`;
}
if (!child.props.status) {
if (index === current) {
if (stepNumber === current) {
childProps.status = status;
} else if (index < current) {
} else if (stepNumber < current) {
childProps.status = 'finish';
} else {
childProps.status = 'wait';
Expand Down
32 changes: 16 additions & 16 deletions tests/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`Steps render renders correctly 1`] = `
class="rc-steps rc-steps-horizontal rc-steps-label-horizontal"
>
<div
class="rc-steps-item rc-steps-item-process"
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
Expand Down Expand Up @@ -147,7 +147,7 @@ exports[`Steps render renders current correctly 1`] = `
</div>
</div>
<div
class="rc-steps-item rc-steps-item-finish"
class="rc-steps-item rc-steps-item-process"
>
<div
class="rc-steps-item-tail"
Expand All @@ -158,9 +158,9 @@ exports[`Steps render renders current correctly 1`] = `
class="rc-steps-item-icon"
>
<span
class="rc-steps-icon rcicon rcicon-check"
class="rc-steps-icon"
>

2
</span>
</div>
<div
Expand All @@ -174,7 +174,7 @@ exports[`Steps render renders current correctly 1`] = `
</div>
</div>
<div
class="rc-steps-item rc-steps-item-process"
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
Expand Down Expand Up @@ -235,7 +235,7 @@ exports[`Steps render renders labelPlacement correctly 1`] = `
class="rc-steps rc-steps-horizontal rc-steps-label-vertical"
>
<div
class="rc-steps-item rc-steps-item-process"
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
Expand Down Expand Up @@ -350,7 +350,7 @@ exports[`Steps render renders progressDot correctly 1`] = `
class="rc-steps rc-steps-horizontal rc-steps-label-vertical rc-steps-dot"
>
<div
class="rc-steps-item rc-steps-item-process"
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
Expand Down Expand Up @@ -481,7 +481,7 @@ exports[`Steps render renders progressDot function correctly 1`] = `
class="rc-steps rc-steps-horizontal rc-steps-label-vertical rc-steps-dot"
>
<div
class="rc-steps-item rc-steps-item-process"
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
Expand Down Expand Up @@ -631,7 +631,7 @@ exports[`Steps render renders status correctly 1`] = `
</div>
</div>
<div
class="rc-steps-item rc-steps-item-finish rc-steps-next-error"
class="rc-steps-item rc-steps-item-error rc-steps-next-error"
>
<div
class="rc-steps-item-tail"
Expand All @@ -642,7 +642,7 @@ exports[`Steps render renders status correctly 1`] = `
class="rc-steps-item-icon"
>
<span
class="rc-steps-icon rcicon rcicon-check"
class="rc-steps-icon rcicon rcicon-cross"
>

</span>
Expand All @@ -658,7 +658,7 @@ exports[`Steps render renders status correctly 1`] = `
</div>
</div>
<div
class="rc-steps-item rc-steps-item-error"
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
Expand All @@ -669,9 +669,9 @@ exports[`Steps render renders status correctly 1`] = `
class="rc-steps-item-icon"
>
<span
class="rc-steps-icon rcicon rcicon-cross"
class="rc-steps-icon"
>

3
</span>
</div>
<div
Expand Down Expand Up @@ -719,7 +719,7 @@ exports[`Steps render renders step with description 1`] = `
class="rc-steps rc-steps-horizontal rc-steps-label-horizontal"
>
<div
class="rc-steps-item rc-steps-item-process"
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
Expand Down Expand Up @@ -989,7 +989,7 @@ exports[`Steps render renders step with tailContent 1`] = `
class="rc-steps rc-steps-horizontal rc-steps-label-horizontal"
>
<div
class="rc-steps-item rc-steps-item-process"
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
Expand Down Expand Up @@ -1126,7 +1126,7 @@ exports[`Steps render renders vertical correctly 1`] = `
class="rc-steps rc-steps-vertical"
>
<div
class="rc-steps-item rc-steps-item-process"
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
Expand Down