1 | import {Col, Row} from 'bee-layout';
|
2 | import {Panel} from 'bee-panel';
|
3 | import Button from 'bee-button';
|
4 | import React, {Component} from 'react';
|
5 | import ReactDOM from 'react-dom';
|
6 |
|
7 |
|
8 | const CARET = <i className="uf uf-arrow-down"></i>;
|
9 |
|
10 | const CARETUP = <i className="uf uf-arrow-up"></i>;
|
11 |
|
12 |
|
13 | var Demo1 = require("./demolist/Demo1");var DemoArray = [{"example":<Demo1 />,"title":" 基础级联菜单","code":"/**\n *\n * @title 基础级联菜单\n * @description\n *\n */\n\nimport React, { Component } from 'react';\nimport { Cascader, Row, Col } from 'tinper-bee';\n\n const options = [\n \t{\n \t value: '浙江',\n \t children: [\n \t\t {\n \t\t value: '杭州',\n \t\t children: [\n \t\t\t {\n \t\t\t value: '西湖',\n \t\t\t children: [\n \t\t\t\t {\n \t\t\t\t value: '白娘子'\n \t\t\t\t },\n \t\t\t\t {\n \t\t\t\t value: '许仙'\n \t\t\t\t }]\n \t\t\t }]\n \t\t }\n \t ]\n \t},\n \t{\n \t value: '江苏',\n \t children: [\n \t\t {\n \t\t value: '南京',\n \t\t children: [\n \t\t\t {\n \t\t\t value: '中华门'\n \t\t\t }]\n \t\t }\n \t ]\n \t},\n \t{\n \t value: '山东'\n \t}\n ];\n class Demo1 extends Component {\n\n\n\tonClickHandler=(data)=>{\n\t\tconsole.log(\"data: \",data);\n\t}\n\n \trender(){\n \t\treturn(\n <Row>\n <Col md={4}>\n <div className=\"height-150\">\n \t<Cascader options = {options} onClick={this.onClickHandler}/>\n </div>\n </Col>\n </Row>\n \t\t)\n \t}\n }\n","desc":""}]
|
14 |
|
15 |
|
16 | class 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 |
|
25 | handleClick() {
|
26 | this.setState({open: !this.state.open})
|
27 | }
|
28 |
|
29 | render() {
|
30 | const {title, example, code, desc, scss_code} = this.props;
|
31 | let caret = this.state.open ? CARETUP : CARET;
|
32 | let text = this.state.open ? "隐藏代码" : "查看代码";
|
33 |
|
34 | const header = (
|
35 | <div>
|
36 | {example}
|
37 | <Button style={{"marginTop": "10px"}} shape="block" onClick={this.handleClick}>
|
38 | {caret}
|
39 | {text}
|
40 | </Button>
|
41 | </div>
|
42 | );
|
43 | return (
|
44 | <Col md={12}>
|
45 | <h3>{title}</h3>
|
46 | <p>{desc}</p>
|
47 | <Panel collapsible headerContent expanded={this.state.open} colors='bordered' header={header}
|
48 | footerStyle={{padding: 0}}>
|
49 | <pre><code className="hljs javascript">{code}</code></pre>
|
50 | {!!scss_code ? <pre><code className="hljs css">{scss_code}</code></pre> : null}
|
51 | </Panel>
|
52 | </Col>
|
53 | )
|
54 | }
|
55 | }
|
56 |
|
57 | class DemoGroup extends Component {
|
58 | constructor(props) {
|
59 | super(props)
|
60 | }
|
61 |
|
62 | render() {
|
63 | return (
|
64 | <Row>
|
65 | {DemoArray.map((child, index) => {
|
66 |
|
67 | return (
|
68 | <Demo example={child.example} title={child.title} code={child.code} scss_code={child.scss_code}
|
69 | desc={child.desc} key={index}/>
|
70 | )
|
71 |
|
72 | })}
|
73 | </Row>
|
74 | )
|
75 | }
|
76 | }
|
77 |
|
78 | ReactDOM.render(<DemoGroup/>, document.getElementById('tinperBeeDemo'));
|