Skip to content
Closed
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
1 change: 1 addition & 0 deletions examples/start.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
placeholder
24 changes: 24 additions & 0 deletions examples/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'rc-steps/assets/index.less';
import 'rc-steps/assets/iconfont.less';
import React from 'react';
import ReactDOM from 'react-dom';
import Steps, { Step } from 'rc-steps';

const container = document.getElementById('__react-content');

ReactDOM.render(
<div>
<Steps current={4}>
<Step title="已完成" />
<Step title="已完成" />
<Step title="已完成" />
<Step title="已完成" />
</Steps>
<Steps current={1} start={5} style={{ marginTop: 40 }}>
<Step title="已完成" />
<Step title="进行中" />
<Step title="待运行" />
<Step title="待运行" />
</Steps>
</div>
, container);
6 changes: 4 additions & 2 deletions src/Steps.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class Steps extends Component {
]),
style: PropTypes.object,
current: PropTypes.number,
start: PropTypes.number,
};
static defaultProps = {
prefixCls: 'rc-steps',
Expand All @@ -32,6 +33,7 @@ export default class Steps extends Component {
status: 'process',
size: '',
progressDot: false,
start: 1,
};
constructor(props) {
super(props);
Expand Down Expand Up @@ -86,7 +88,7 @@ export default class Steps extends Component {
const {
prefixCls, style = {}, className, children, direction,
labelPlacement, iconPrefix, status, size, current, progressDot,
...restProps,
start, ...restProps,
} = this.props;
const { lastStepOffsetWidth, flexSupported } = this.state;
const filteredChildren = React.Children.toArray(children).filter(c => !!c);
Expand All @@ -106,7 +108,7 @@ export default class Steps extends Component {
return null;
}
const childProps = {
stepNumber: `${index + 1}`,
stepNumber: `${start + index}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding the propstart only to stepNumber, does not work prop status of component Step.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current is still an index but not a step number.

prefixCls,
iconPrefix,
wrapperStyle: style,
Expand Down
115 changes: 115 additions & 0 deletions tests/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1370,3 +1370,118 @@ exports[`Steps render renders with fasly children 1`] = `
</div>
</div>
`;

exports[`Steps render renders step with specified starting number 1`] = `
<div
class="rc-steps rc-steps-horizontal rc-steps-label-horizontal"
>
<div
class="rc-steps-item rc-steps-item-process"
>
<div
class="rc-steps-item-tail"
>

</div>
<div
class="rc-steps-item-icon"
>
<span
class="rc-steps-icon"
>
4
</span>
</div>
<div
class="rc-steps-item-content"
>
<div
class="rc-steps-item-title"
>
已完成
</div>
</div>
</div>
<div
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
>

</div>
<div
class="rc-steps-item-icon"
>
<span
class="rc-steps-icon"
>
5
</span>
</div>
<div
class="rc-steps-item-content"
>
<div
class="rc-steps-item-title"
>
进行中
</div>
</div>
</div>
<div
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
>

</div>
<div
class="rc-steps-item-icon"
>
<span
class="rc-steps-icon"
>
6
</span>
</div>
<div
class="rc-steps-item-content"
>
<div
class="rc-steps-item-title"
>
待运行
</div>
</div>
</div>
<div
class="rc-steps-item rc-steps-item-wait"
>
<div
class="rc-steps-item-tail"
>

</div>
<div
class="rc-steps-item-icon"
>
<span
class="rc-steps-icon"
>
7
</span>
</div>
<div
class="rc-steps-item-content"
>
<div
class="rc-steps-item-title"
>
待运行
</div>
</div>
</div>
</div>
`;
5 changes: 5 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,10 @@ describe('Steps', () => {
);
expect(wrapper).toMatchSnapshot();
});

it('renders step with specified starting number', () => {
const wrapper = render(React.cloneElement(steps, { start: 4 }));
expect(wrapper).toMatchSnapshot();
});
});
});