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

85 lines
2.4 KiB
JavaScript
Raw Normal View History

2020-12-10 20:54:53 +08:00
import polyfill from '@babel/polyfill'
2016-12-26 16:52:39 +08:00
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
2019-03-21 10:02:37 +08:00
import { Con, Row, Col } from 'bee-layout';
import { Panel } from 'bee-panel';
import Drawer from 'bee-drawer';
import Clipboard from 'bee-clipboard';
import Button from '../src';
2017-09-08 15:07:55 +08:00
2016-12-26 16:52:39 +08:00
{demolist}
class Demo extends Component {
constructor(props){
super(props);
this.state = {
open: false
}
}
2019-03-21 10:02:37 +08:00
handleClick=()=> {
2016-12-26 16:52:39 +08:00
this.setState({ open: !this.state.open })
}
2019-03-21 10:02:37 +08:00
fCloseDrawer=()=>{
this.setState({
open: false
})
}
2016-12-26 16:52:39 +08:00
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
const header = (
2018-01-16 10:11:10 +08:00
<div>
2019-03-21 10:02:37 +08:00
<p className='component-title'>{ title }</p>
<p>{ desc }</p>
<span className='component-code' onClick={this.handleClick}> 查看源码 <i className='uf uf-arrow-right'/> </span>
2018-01-16 10:11:10 +08:00
</div>
2016-12-26 16:52:39 +08:00
);
return (
2019-03-21 10:02:37 +08:00
<Col md={12} id={title.trim()} className='component-demo'>
<Panel header={header}>
{example}
</Panel>
<Drawer className='component-drawerc' title={title} show={this.state.open} placement='right' onClose={this.fCloseDrawer}>
<div className='component-code-copy'> JS代码
<Clipboard action="copy" text={code}/>
</div>
<pre className="pre-js">
<code className="hljs javascript">{ code }</code>
</pre >
{!!scss_code ?<div className='component-code-copy copy-css'> SCSS代码
<Clipboard action="copy" text={scss_code}/>
</div>:null }
{ !!scss_code ? <pre className="pre-css">
<code className="hljs css">{ scss_code }</code>
</pre> : null }
</Drawer>
</Col>
)
2016-12-26 16:52:39 +08:00
}
}
class DemoGroup extends Component {
constructor(props){
super(props)
}
render () {
return (
2019-03-21 10:02:37 +08:00
<Row>
{DemoArray.map((child,index) => {
2016-12-26 16:52:39 +08:00
2019-03-21 10:02:37 +08:00
return (
<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
2019-03-21 10:02:37 +08:00
})}
</Row>
)
2016-12-26 16:52:39 +08:00
}
}
ReactDOM.render(<DemoGroup/>, document.getElementById('tinperBeeDemo'));