bee-table/demo/index-demo-base.js

75 lines
2.1 KiB
JavaScript

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';
const CARET = <i className="uf uf-arrow-down"></i>;
const CARETUP = <i className="uf uf-arrow-up"></i>;
{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 () {
const { title, example, code, desc, scss_code } = this.props;
let caret = this.state.open ? CARETUP : CARET;
let text = this.state.open ? "隐藏代码" : "查看代码";
const header = (
<div>
{example}
<Button style={{"marginTop": "10px"}} shape="block" onClick={ this.handleClick }>
{ caret }
{ text }
</Button>
</div>
);
return (
<Col md={12} >
<h3>{ title }</h3>
<p>{ desc }</p>
<Panel collapsible headerContent expanded={ this.state.open } colors='bordered' header={ header } footerStyle = {{padding: 0}}>
<pre><code className="hljs javascript">{ code }</code></pre>
{ !!scss_code ? <pre><code className="hljs css">{ scss_code }</code></pre> : null }
</Panel>
</Col>
)
}
}
class DemoGroup extends Component {
constructor(props){
super(props)
}
render () {
return (
<Row>
{DemoArray.map((child,index) => {
return (
<Demo example= {child.example} title= {child.title} code= {child.code} scss_code= {child.scss_code} desc= {child.desc} key= {index}/>
)
})}
</Row>
)
}
}
ReactDOM.render(<DemoGroup/>, document.getElementById('tinperBeeDemo'));