1 |
|
2 | import { Con, Row, Col } from 'bee-layout';
|
3 | import { Panel } from 'bee-panel';
|
4 | import React, { Component } from 'react';
|
5 | import ReactDOM from 'react-dom';
|
6 | import Step from '../src';
|
7 | import Icon from 'bee-icon';
|
8 | import Message from 'bee-message';
|
9 | import Button from 'bee-button';
|
10 | const Steps = Step.Steps;
|
11 | const CARET = <i className="uf uf-arrow-down"></i>;
|
12 |
|
13 | const CARETUP = <i className="uf uf-arrow-up"></i>;
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | class Demo1 extends Component {
|
24 | render () {
|
25 | return (
|
26 | <div>
|
27 | <Step.Steps current={1}>
|
28 | <Step title="Finished" description="This is a description." />
|
29 | <Step title="In Progress" description="This is a description." />
|
30 | <Step title="Waiting" description="This is a description." />
|
31 | </Step.Steps>
|
32 | </div>
|
33 |
|
34 | )
|
35 | }
|
36 | }
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | class Demo2 extends Component {
|
45 | render () {
|
46 | return (
|
47 | <Step.Steps>
|
48 | <Step status="finish" title="Login" icon={<Icon type="uf-users-o" />} />
|
49 | <Step status="finish" title="Verification" icon={<Icon type="uf-personin-o" />} />
|
50 | <Step status="process" title="Pay" icon={<Icon type="uf-creditcard" />} />
|
51 | <Step status="wait" title="Done" icon={<Icon type="uf-correct-2" />} />
|
52 | </Step.Steps>
|
53 | )
|
54 | }
|
55 | }
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | const steps = [{
|
65 | title: 'First',
|
66 | content: 'First-content',
|
67 | }, {
|
68 | title: 'Second',
|
69 | content: 'Second-content',
|
70 | }, {
|
71 | title: 'Last',
|
72 | content: 'Last-content',
|
73 | }];
|
74 |
|
75 | class Demo3 extends Component {
|
76 | constructor(props) {
|
77 | super(props);
|
78 | this.state = {
|
79 | current: 0,
|
80 | };
|
81 | }
|
82 | next() {
|
83 | const current = this.state.current + 1;
|
84 | this.setState({ current });
|
85 | }
|
86 | prev() {
|
87 | const current = this.state.current - 1;
|
88 | this.setState({ current });
|
89 | }
|
90 |
|
91 | alertDone() {
|
92 | Message.create({content: 'done', color: 'info'});
|
93 | }
|
94 |
|
95 | render() {
|
96 | const { current } = this.state;
|
97 | return (
|
98 | <div>
|
99 | <Steps current={current}>
|
100 | {steps.map(item => <Step key={item.title} title={item.title} />)}
|
101 | </Steps>
|
102 | <div className="steps-content">{steps[this.state.current].content}</div>
|
103 | <div className="steps-action">
|
104 | {
|
105 | this.state.current < steps.length - 1
|
106 | &&
|
107 | <Button type="primary" onClick={() => this.next()}>Next</Button>
|
108 | }
|
109 | {
|
110 | this.state.current === steps.length - 1
|
111 | &&
|
112 | <Button type="primary" onClick={() => this.alertDone()}>Done</Button>
|
113 | }
|
114 | {
|
115 | this.state.current > 0
|
116 | &&
|
117 | <Button style={{ marginLeft: 8 }} onClick={() => this.prev()}>
|
118 | Previous
|
119 | </Button>
|
120 | }
|
121 | </div>
|
122 | </div>
|
123 | );
|
124 | }
|
125 | }
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 | class Demo4 extends Component {
|
133 | render () {
|
134 | return (
|
135 | <div>
|
136 | <Steps direction="vertical" size="small" current={1}>
|
137 | <Step title="Finished" description="This is a description." />
|
138 | <Step title="In Progress" description="This is a description." />
|
139 | <Step title="Waiting" description="This is a description." />
|
140 | </Steps>
|
141 | </div>
|
142 | )
|
143 | }
|
144 | } |
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | class Demo5 extends Component {
|
151 | render () {
|
152 | return (
|
153 | <div>
|
154 | <Steps current={1} status="error">
|
155 | <Step title="Finished" description="This is a description" />
|
156 | <Step title="In Process" description="This is a description" />
|
157 | <Step title="Waiting" description="This is a description" />
|
158 | </Steps>
|
159 | </div>
|
160 | )
|
161 | }
|
162 | }var DemoArray = [{"example":<Demo1 />,"title":" 常用基础 Step","code":"/**\n*\n* @title 常用基础 Step\n* @description current 标记当前机型哪一步\n*\n*/\n\nclass Demo1 extends Component {\n render () {\n return (\n <div>\n <Step.Steps current={1}>\n <Step title=\"Finished\" description=\"This is a description.\" />\n <Step title=\"In Progress\" description=\"This is a description.\" />\n <Step title=\"Waiting\" description=\"This is a description.\" />\n </Step.Steps>\n </div>\n \n )\n }\n}\n","desc":" current 标记当前机型哪一步"},{"example":<Demo2 />,"title":" 自定义icon Step","code":"/**\n*\n* @title 自定义icon Step\n* @description\n*\n*/\n\nclass Demo2 extends Component {\n render () {\n return (\n <Step.Steps>\n <Step status=\"finish\" title=\"Login\" icon={<Icon type=\"uf-users-o\" />} />\n <Step status=\"finish\" title=\"Verification\" icon={<Icon type=\"uf-personin-o\" />} />\n <Step status=\"process\" title=\"Pay\" icon={<Icon type=\"uf-creditcard\" />} />\n <Step status=\"wait\" title=\"Done\" icon={<Icon type=\"uf-correct-2\" />} />\n </Step.Steps>\n )\n }\n}\n","desc":""},{"example":<Demo3 />,"title":" 结合切换事件的 Step","code":"\n/**\n*\n* @title 结合切换事件的 Step\n* @description 点击next,Step的流程跟进\n*\n*/\n\nconst steps = [{\n title: 'First',\n content: 'First-content',\n}, {\n title: 'Second',\n content: 'Second-content',\n}, {\n title: 'Last',\n content: 'Last-content',\n}];\n\nclass Demo3 extends Component {\n constructor(props) {\n super(props);\n this.state = {\n current: 0,\n };\n }\n next() {\n const current = this.state.current + 1;\n this.setState({ current });\n }\n prev() {\n const current = this.state.current - 1;\n this.setState({ current });\n }\n\n alertDone() {\n Message.create({content: 'done', color: 'info'});\n }\n\n render() {\n const { current } = this.state;\n return (\n <div>\n <Steps current={current}>\n {steps.map(item => <Step key={item.title} title={item.title} />)}\n </Steps>\n <div className=\"steps-content\">{steps[this.state.current].content}</div>\n <div className=\"steps-action\">\n {\n this.state.current < steps.length - 1\n &&\n <Button type=\"primary\" onClick={() => this.next()}>Next</Button>\n }\n {\n this.state.current === steps.length - 1\n &&\n <Button type=\"primary\" onClick={() => this.alertDone()}>Done</Button>\n }\n {\n this.state.current > 0\n &&\n <Button style={{ marginLeft: 8 }} onClick={() => this.prev()}>\n Previous\n </Button>\n }\n </div>\n </div>\n );\n }\n}\n","desc":" 点击next,Step的流程跟进"},{"example":<Demo4 />,"title":" vertical Step","code":"/**\n*\n* @title vertical Step\n* @description \n*\n*/\nclass Demo4 extends Component {\n render () {\n return (\n <div>\n <Steps direction=\"vertical\" size=\"small\" current={1}>\n <Step title=\"Finished\" description=\"This is a description.\" />\n <Step title=\"In Progress\" description=\"This is a description.\" />\n <Step title=\"Waiting\" description=\"This is a description.\" />\n </Steps>\n </div>\n )\n }\n}","desc":" "},{"example":<Demo5 />,"title":" 指定状态的Step","code":"/**\n*\n* @title 指定状态的Step\n* @description 用step的status属性,指定当前step的状态\n*\n*/\nclass Demo5 extends Component {\n render () {\n return (\n <div>\n <Steps current={1} status=\"error\">\n <Step title=\"Finished\" description=\"This is a description\" />\n <Step title=\"In Process\" description=\"This is a description\" />\n <Step title=\"Waiting\" description=\"This is a description\" />\n </Steps>\n </div>\n )\n }\n}","desc":" 用step的status属性,指定当前step的状态"}]
|
163 |
|
164 |
|
165 | class Demo extends Component {
|
166 | constructor(props){
|
167 | super(props);
|
168 | this.state = {
|
169 | open: false
|
170 | }
|
171 | this.handleClick = this.handleClick.bind(this);
|
172 | }
|
173 | handleClick() {
|
174 | this.setState({ open: !this.state.open })
|
175 | }
|
176 |
|
177 | render () {
|
178 | const { title, example, code, desc } = this.props;
|
179 | let caret = this.state.open ? CARETUP : CARET;
|
180 | let text = this.state.open ? "隐藏代码" : "查看代码";
|
181 |
|
182 | const footer = (
|
183 | <Button shape="block" onClick={ this.handleClick }>
|
184 | { caret }
|
185 | { text }
|
186 | </Button>
|
187 | );
|
188 | const header = (
|
189 | <Row>
|
190 | <Col md={11}>
|
191 | { example }
|
192 | </Col>
|
193 | <Col md={1}>
|
194 | <Button shape="icon" onClick={ this.handleClick }>
|
195 | { caret }
|
196 | </Button>
|
197 | </Col>
|
198 | </Row>
|
199 | );
|
200 | return (
|
201 | <Col md={12} >
|
202 | <h3>{ title }</h3>
|
203 | <p>{ desc }</p>
|
204 | <Panel collapsible headerContent expanded={ this.state.open } colors='bordered' header={ header } footer={footer} footerStyle = {{padding: 0}}>
|
205 | <pre><code className="hljs javascript">{ code }</code></pre>
|
206 | </Panel>
|
207 | </Col>
|
208 | )
|
209 | }
|
210 | }
|
211 |
|
212 | class DemoGroup extends Component {
|
213 | constructor(props){
|
214 | super(props)
|
215 | }
|
216 | render () {
|
217 | return (
|
218 | <Row>
|
219 | {DemoArray.map((child,index) => {
|
220 |
|
221 | return (
|
222 | <Demo example= {child.example} title= {child.title} code= {child.code} desc= {child.desc} key= {index}/>
|
223 | )
|
224 |
|
225 | })}
|
226 | </Row>
|
227 | )
|
228 | }
|
229 | }
|
230 |
|
231 | ReactDOM.render(<DemoGroup/>, document.getElementById('tinperBeeDemo'));
|