bee-table/demo/index.js

76 lines
100 KiB
JavaScript
Raw Normal View History

2016-12-26 22:04:16 +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-27 11:28:46 +08:00
2016-12-26 22:04:16 +08:00
2017-01-11 17:01:50 +08:00
const CARET = <i className="uf uf-arrow-down"></i>;
2016-12-26 22:04:16 +08:00
2017-01-11 17:01:50 +08:00
const CARETUP = <i className="uf uf-arrow-up"></i>;
2016-12-26 22:04:16 +08:00
2018-12-24 10:56:36 +08:00
var Demo1 = require("./demolist/Demo1");var Demo10 = require("./demolist/Demo10");var Demo11 = require("./demolist/Demo11");var Demo12 = require("./demolist/Demo12");var Demo13 = require("./demolist/Demo13");var Demo14 = require("./demolist/Demo14");var Demo15 = require("./demolist/Demo15");var Demo16 = require("./demolist/Demo16");var Demo17 = require("./demolist/Demo17");var Demo18 = require("./demolist/Demo18");var Demo19 = require("./demolist/Demo19");var Demo2 = require("./demolist/Demo2");var Demo20 = require("./demolist/Demo20");var Demo21 = require("./demolist/Demo21");var Demo22 = require("./demolist/Demo22");var Demo23 = require("./demolist/Demo23");var Demo24 = require("./demolist/Demo24");var Demo25 = require("./demolist/Demo25");var Demo26 = require("./demolist/Demo26");var Demo27 = require("./demolist/Demo27");var Demo28 = require("./demolist/Demo28");var Demo29 = require("./demolist/Demo29");var Demo3 = require("./demolist/Demo3");var Demo30 = require("./demolist/Demo30");var Demo31 = require("./demolist/Demo31");var Demo32 = require("./demolist/Demo32");var Demo4 = require("./demolist/Demo4");var Demo5 = require("./demolist/Demo5");var Demo6 = require("./demolist/Demo6");var Demo7 = require("./demolist/Demo7");var Demo8 = require("./demolist/Demo8");var Demo9 = require("./demolist/Demo9");var DemoArray = [{"example":<Demo1 />,"title":" 简单表格、文字过长两种tip","code":"/**\n*\n* @title 简单表格、文字过长两种tip\n* 【Tooltip】\n* @description\n*/\n\nimport React, { Component } from \"react\";\nimport { Table, Tooltip, Button } from 'tinper-bee';\n\nconst columns = [\n {\n title: \"用户名\", dataIndex: \"a\", key: \"a\", width: 80, className: \"rowClassName\",\n render: (text, record, index) => {\n return (\n <Tooltip inverse overlay={text}>\n <span tootip={text} style={{\n display: \"inline-block\",\n width: \"60px\",\n textOverflow: \"ellipsis\",\n overflow: \"hidden\",\n whiteSpace: \"nowrap\",\n verticalAlign: \"middle\",\n }}>{text}</span>\n </Tooltip>\n );\n }\n },\n { id: \"123\", title: \"性别\", dataIndex: \"b\", key: \"b\", width: '10%' },\n { title: \"年龄\", dataIndex: \"c\", key: \"c\", width: 200 },\n {\n title: \"操作\",\n dataIndex: \"d\",\n key: \"d\",\n render(text, record, index) {\n return (\n <div style={{ position: 'relative' }} title={text} >\n <a\n href=\"javascript:;\"\n tooltip={text}\n onClick={() => {\n alert('这是第' + index + '列,内容为:' + text);\n }}\n >\n 一些操作\n </a>\n </div>\n );\n }\n }\n];\n\nconst data = [\n { a: \"令狐冲\", b: \"男\", c: 41, d: \"操作\", key: \"1\" },\n { a: \"杨过叔叔的女儿黄蓉\", b: \"男\", c: 67, d: \"操作\", key: \"2\" },\n { a: \"郭靖\", b: \"男\", c: 25, d: \"操作\", key: \"3\" }\n];\n\nclass Demo1 extends Component {\n\n constructor(props) {\n super(props);\n this.state = {\n data: data,\n selectedRowIndex: 0\n }\n }\n\n render() {\n return (\n \n <Table\n columns={columns}\n data={data}\n parentNodeId='parent'\n height={43}\n headerHeight={42}\n onRowClick={(record, index, indent) => {\n this.setState({\n selectedRowIndex: index\n });\n }}\n />\n\n \n );\n }\n}\n\n\n","desc":""},{"example":<Demo10 />,"title":" 无数据时显示","code":"/**\n*\n* @title 无数据时显示\n* @description 无数据时显示效果展示(可自定义)\n *\n* import {Table} from 'tinper-bee';\n*/\n\n\nimport React, { Component } from 'react';\nimport { Table } from 'tinper-bee';\n\n\nconst columns10 = [\n {\n title: \"Name\",\n dataIndex: \"name\",\n key: \"name\",\n width: \"40%\"\n },\n {\n title: \"Age\",\n dataIndex: \"age\",\n key
2016-12-26 22:04:16 +08:00
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 22:04:16 +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}
2018-01-16 10:50:21 +08:00
<Button style={{"marginTop": "10px"}} shape="block" onClick={ this.handleClick }>
2018-01-16 10:11:10 +08:00
{ caret }
{ text }
</Button>
</div>
2016-12-26 22:04:16 +08:00
);
return (
<Col md={12} >
<h3>{ title }</h3>
<p>{ desc }</p>
2018-08-30 15:32:18 +08:00
<Panel copyable collapsible headerContent expanded={ this.state.open } colors='bordered' header={ header } footerStyle = {{padding: 0}}>
2016-12-26 22:04:16 +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 22:04:16 +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 22:04:16 +08:00
)
})}
</Row>
)
}
}
ReactDOM.render(<DemoGroup/>, document.getElementById('tinperBeeDemo'));