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