UNPKG

7.2 kBJavaScriptView Raw
1import { Con, Row, Col } from 'bee-layout';
2import { Panel } from 'bee-panel';
3import Button from 'bee-button';
4import React, { Component } from 'react';
5import ReactDOM from 'react-dom';
6
7
8const CARET = <i className="uf uf-arrow-down"></i>;
9
10const CARETUP = <i className="uf uf-arrow-up"></i>;
11
12
13var Demo1 = require("./demolist/Demo1");var Demo2 = require("./demolist/Demo2");var Demo3 = require("./demolist/Demo3");var Demo4 = require("./demolist/Demo4");var Demo5 = require("./demolist/Demo5");var DemoArray = [{"example":<Demo1 />,"title":" 常用基础 Step","code":"/**\n*\n* @title 常用基础 Step\n* @description current 标记当前进行哪一步\n*\n*/\n\nimport React, { Component } from 'react';\nimport { Step } from 'tinper-bee';\n\nclass Demo1 extends Component {\n render () {\n return (\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 )\n }\n}\n\n\n","desc":" current 标记当前进行哪一步"},{"example":<Demo2 />,"title":" 自定义icon Step","code":"/**\n*\n* @title 自定义icon Step\n* @description\n*\n*/\n\nimport React, { Component } from 'react';\nimport { Step, Icon } from 'tinper-bee';\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\n","desc":""},{"example":<Demo3 />,"title":" 结合切换事件的 Step","code":"\n/**\n*\n* @title 结合切换事件的 Step\n* @description 点击next,Step的流程跟进\n*\n*/\nimport React, { Component } from 'react';\nimport { Step, Button, Message } from 'tinper-bee';\n\nconst Steps = Step.Steps;\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: '完成', 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()}>下一页</Button>\n }\n {\n this.state.current === steps.length - 1\n &&\n <Button type=\"primary\" onClick={() => this.alertDone()}>完成</Button>\n }\n {\n this.state.current > 0\n &&\n <Button style={{ marginLeft: 8 }} onClick={() => this.prev()}>\n 上一页\n </Button>\n }\n </div>\n </div>\n );\n }\n}\n\n","desc":" 点击next,Step的流程跟进","scss_code":".steps-content {\n margin-top: 16px;\n border: 1px dashed #e9e9e9;\n border-radius: 6px;\n background-color: #fafafa;\n min-height: 200px;\n text-align: center;\n padding-top: 80px;\n}\n\n.steps-action {\n margin-top: 24px;\n}"},{"example":<Demo4 />,"title":" vertical Step","code":"/**\n*\n* @title vertical Step\n* @description \n*\n*/\n\nimport React, { Component } from 'react';\nimport { Step } from 'tinper-bee';\n\nconst Steps = Step.Steps;\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}\n\n","desc":" "},{"example":<Demo5 />,"title":" 指定状态的Step","code":"/**\n*\n* @title 指定状态的Step\n* @description 用step的status属性,指定当前step的状态\n*\n*/\n\nimport React, { Component } from 'react';\nimport { Step } from 'tinper-bee';\n\nconst Steps = Step.Steps;\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}\n\n","desc":" 用step的status属性,指定当前step的状态"}]
14
15
16class Demo extends Component {
17 constructor(props){
18 super(props);
19 this.state = {
20 open: false
21 }
22 this.handleClick = this.handleClick.bind(this);
23 }
24 handleClick() {
25 this.setState({ open: !this.state.open })
26 }
27
28 render () {
29 const { title, example, code, desc, scss_code } = this.props;
30 let caret = this.state.open ? CARETUP : CARET;
31 let text = this.state.open ? "隐藏代码" : "查看代码";
32
33 const header = (
34 <div>
35 {example}
36 <Button style={{"marginTop": "10px"}} shape="block" onClick={ this.handleClick }>
37 { caret }
38 { text }
39 </Button>
40 </div>
41 );
42 return (
43 <Col md={12} >
44 <h3>{ title }</h3>
45 <p>{ desc }</p>
46 <Panel collapsible headerContent expanded={ this.state.open } colors='bordered' header={ header } footerStyle = {{padding: 0}}>
47 <pre><code className="hljs javascript">{ code }</code></pre>
48 { !!scss_code ? <pre><code className="hljs css">{ scss_code }</code></pre> : null }
49 </Panel>
50 </Col>
51 )
52 }
53}
54
55class DemoGroup extends Component {
56 constructor(props){
57 super(props)
58 }
59 render () {
60 return (
61 <Row>
62 {DemoArray.map((child,index) => {
63
64 return (
65 <Demo example= {child.example} title= {child.title} code= {child.code} scss_code= {child.scss_code} desc= {child.desc} key= {index}/>
66 )
67
68 })}
69 </Row>
70 )
71 }
72}
73
74ReactDOM.render(<DemoGroup/>, document.getElementById('tinperBeeDemo'));