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 Button from 'bee-button';
|
7 | import Switch from '../src';
|
8 |
|
9 |
|
10 | const CARET = <i className="uf uf-arrow-down"></i>;
|
11 |
|
12 | const CARETUP = <i className="uf uf-arrow-up"></i>;
|
13 |
|
14 |
|
15 | {demolist}
|
16 |
|
17 | class Demo extends Component {
|
18 | constructor(props){
|
19 | super(props);
|
20 | this.state = {
|
21 | open: false
|
22 | }
|
23 | this.handleClick = this.handleClick.bind(this);
|
24 | }
|
25 | handleClick() {
|
26 | this.setState({ open: !this.state.open })
|
27 | }
|
28 |
|
29 | render () {
|
30 | const { title, example, code, desc } = this.props;
|
31 | let caret = this.state.open ? CARETUP : CARET;
|
32 | let text = this.state.open ? "隐藏代码" : "查看代码";
|
33 |
|
34 | const footer = (
|
35 | <Button shape="block" onClick={ this.handleClick }>
|
36 | { caret }
|
37 | { text }
|
38 | </Button>
|
39 | );
|
40 |
|
41 |
|
42 | return (
|
43 | <Col md={12} >
|
44 | <h3>{ title }</h3>
|
45 | <p>{ desc }</p>
|
46 | <Panel collapsible expanded={ this.state.open } colors='bordered' header={ example } footer={footer} footerStyle = {{padding: 0}}>
|
47 | <pre><code className="hljs javascript">{ code }</code></pre>
|
48 | </Panel>
|
49 | </Col>
|
50 | )
|
51 | }
|
52 | }
|
53 |
|
54 | class DemoGroup extends Component {
|
55 | constructor(props){
|
56 | super(props)
|
57 | }
|
58 | render () {
|
59 | return (
|
60 | <Row>
|
61 | {DemoArray.map((child,index) => {
|
62 |
|
63 | return (
|
64 | <Demo example= {child.example} title= {child.title} code= {child.code} desc= {child.desc} key= {index}/>
|
65 | )
|
66 |
|
67 | })}
|
68 | </Row>
|
69 | )
|
70 | }
|
71 | }
|
72 |
|
73 | ReactDOM.render(<DemoGroup/>, document.getElementById('tinperBeeDemo'));
|