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

show finish/error stepNumber optional #74

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ online example: http://react-component.github.io/steps/examples/
<td></td>
<td>spicify the default finish icon and error icon</td>
</tr>
<tr>
<td>showStepNum</td>
yoyo837 marked this conversation as resolved.
Show resolved Hide resolved
<td>boolean</td>
<td></td>
<td>display step number, It will be ignored if icons is provided</td>
</tr>
<tr>
<td>onChange</td>
<td>(current: number) => void</td>
Expand Down Expand Up @@ -131,6 +137,12 @@ online example: http://react-component.github.io/steps/examples/
<td></td>
<td>set icon of step item</td>
</tr>
<tr>
<td>showStepNum</td>
<td>boolean</td>
<td></td>
<td>display step number, It will be ignored if icon/icons is provided</td>
</tr>
<tr>
<td>status</td>
<td>string</td>
Expand Down
5 changes: 3 additions & 2 deletions src/Step.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class Step extends React.Component {
finish: PropTypes.node,
error: PropTypes.node,
}),
showStepNum: PropTypes.bool,
onClick: PropTypes.func,
onStepClick: PropTypes.func,
};
Expand All @@ -53,7 +54,7 @@ export default class Step extends React.Component {
renderIconNode() {
const {
prefixCls, progressDot, stepNumber, status, title, description, icon,
iconPrefix, icons,
iconPrefix, icons, showStepNum,
} = this.props;
let iconNode;
const iconClassName = classNames(`${prefixCls}-icon`, `${iconPrefix}icon`, {
Expand All @@ -80,7 +81,7 @@ export default class Step extends React.Component {
} else if (icons && icons.error && status === 'error') {
iconNode = <span className={`${prefixCls}-icon`}>{icons.error}</span>;
} else if (icon || status === 'finish' || status === 'error') {
iconNode = <span className={iconClassName} />;
iconNode = <span className={iconClassName}>{showStepNum ? stepNumber : ''}</span>;
} else {
iconNode = <span className={`${prefixCls}-icon`}>{stepNumber}</span>;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Steps.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class Steps extends Component {
finish: PropTypes.node,
error: PropTypes.node,
}),
showStepNum: PropTypes.bool,
onChange: PropTypes.func,
};
static defaultProps = {
Expand Down Expand Up @@ -101,7 +102,7 @@ export default class Steps extends Component {
const {
prefixCls, style = {}, className, children, direction,
labelPlacement, iconPrefix, status, size, current, progressDot, initial,
icons, onChange,
icons, onChange, showStepNum,
...restProps,
} = this.props;
const { lastStepOffsetWidth, flexSupported } = this.state;
Expand Down Expand Up @@ -131,6 +132,7 @@ export default class Steps extends Component {
wrapperStyle: style,
progressDot,
icons,
showStepNum,
onStepClick: onChange && this.onStepClick,
...child.props,
};
Expand Down