import './demo5.css'; import React from 'react'; import ReactDOM from 'react-dom'; import Step from '..'; import { Button, Icon, Select } from '../..'; const StepItem = Step.Item, ButtonGroup = Button.Group; const renders = { 1: function itemRender1(index) { return
{index + 1}
; }, 2: function itemRender2(index, status) { return
{status === 'finish' ? : {index + 1}}
; }, }; const contents = [ 'Description1', 'Description2 --- Very Looooooooooooooooooooooog content', 'Description3', ]; type StepType = 'circle' | 'arrow' | 'dot'; type LabelPlacement = 'ver' | 'hoz'; interface IState { currentStep: number; stepType: StepType; stepAnimation: boolean; labelPlacement: LabelPlacement; itemRender?: (index: number) => React.ReactNode; content?: string; } class Component extends React.Component<{}, IState> { constructor(props) { super(props); this.state = { currentStep: 1, stepType: 'circle', stepAnimation: true, labelPlacement: 'ver', }; } next() { const s = this.state.currentStep + 1; this.setState({ currentStep: s > 6 ? 6 : s, }); } prev() { const s = this.state.currentStep - 1; this.setState({ currentStep: s < 0 ? 0 : s, }); } onClick = currentStep => { console.log(currentStep); this.setState({ currentStep, }); }; onStepTypeChange(value) { this.setState({ stepType: value }); } onStepAnimation(value) { this.setState({ stepAnimation: value }); } onLabelPlacementChange(value) { this.setState({ labelPlacement: value }); } onItemRenderChange(value) { this.setState({ itemRender: renders[value], content: contents[value] }); } render() { const { currentStep } = this.state; return (
{contents[currentStep]}


); } } ReactDOM.render(, document.getElementById('step-demo-5'));