2016-12-26 16:52:39 +08:00
|
|
|
|
|
|
|
import { Con, Row, Col } from 'bee-layout';
|
|
|
|
import { Panel } from 'bee-panel';
|
|
|
|
import Button from 'bee-button';
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
2017-09-08 15:07:55 +08:00
|
|
|
|
2016-12-26 16:52:39 +08:00
|
|
|
|
2017-01-11 17:01:50 +08:00
|
|
|
const CARET = <i className="uf uf-arrow-down"></i>;
|
2016-12-26 16:52:39 +08:00
|
|
|
|
2017-01-11 17:01:50 +08:00
|
|
|
const CARETUP = <i className="uf uf-arrow-up"></i>;
|
2016-12-26 16:52:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
{demolist}
|
|
|
|
|
|
|
|
class Demo extends Component {
|
|
|
|
constructor(props){
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
open: false
|
|
|
|
}
|
|
|
|
this.handleClick = this.handleClick.bind(this);
|
|
|
|
}
|
|
|
|
handleClick() {
|
|
|
|
this.setState({ open: !this.state.open })
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2018-01-16 10:11:10 +08:00
|
|
|
const { title, example, code, desc, scss_code } = this.props;
|
2016-12-26 16:52:39 +08:00
|
|
|
let caret = this.state.open ? CARETUP : CARET;
|
|
|
|
let text = this.state.open ? "隐藏代码" : "查看代码";
|
|
|
|
|
|
|
|
const header = (
|
2018-01-16 10:11:10 +08:00
|
|
|
<div>
|
|
|
|
{example}
|
|
|
|
<Button style={{"margin-top": "10px"}} shape="block" onClick={ this.handleClick }>
|
|
|
|
{ caret }
|
|
|
|
{ text }
|
|
|
|
</Button>
|
|
|
|
</div>
|
2016-12-26 16:52:39 +08:00
|
|
|
);
|
|
|
|
return (
|
|
|
|
<Col md={12} >
|
|
|
|
<h3>{ title }</h3>
|
|
|
|
<p>{ desc }</p>
|
2018-01-16 10:11:10 +08:00
|
|
|
<Panel collapsible headerContent expanded={ this.state.open } colors='bordered' header={ header } footerStyle = {{padding: 0}}>
|
2016-12-26 16:52:39 +08:00
|
|
|
<pre><code className="hljs javascript">{ code }</code></pre>
|
2018-01-16 10:11:10 +08:00
|
|
|
{ !!scss_code ? <pre><code className="hljs css">{ scss_code }</code></pre> : null }
|
2016-12-26 16:52:39 +08:00
|
|
|
</Panel>
|
|
|
|
</Col>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class DemoGroup extends Component {
|
|
|
|
constructor(props){
|
|
|
|
super(props)
|
|
|
|
}
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<Row>
|
|
|
|
{DemoArray.map((child,index) => {
|
|
|
|
|
|
|
|
return (
|
2018-01-16 10:11:10 +08:00
|
|
|
<Demo example= {child.example} title= {child.title} code= {child.code} scss_code= {child.scss_code} desc= {child.desc} key= {index}/>
|
2016-12-26 16:52:39 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
})}
|
|
|
|
</Row>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<DemoGroup/>, document.getElementById('tinperBeeDemo'));
|