Skip to content

Commit

Permalink
feat(Table.js): 新增# bee-table
Browse files Browse the repository at this point in the history
## API
  • Loading branch information
HuYuee committed Dec 24, 2017
1 parent 5542297 commit 8117b1c
Show file tree
Hide file tree
Showing 16 changed files with 345 additions and 214 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -60,6 +60,7 @@ class Demo extends Component {
| 参数 | 说明 | 类型 | 默认值 |
| :--------------------- | :--------------------------------------- | :------------------------------------- | :-------------- |
| data | 传入的表格数据 | array | [] |
| bordered | 是否展示外边框和列边框 | boolean | false |
| columns | 列的配置表,具体配置见下表 | array | - |
| defaultExpandAllRows | 默认是否展开所有行 | bool | false |
| expandedRowKeys | 展开的行,控制属性 | array | - |
Expand Down
51 changes: 33 additions & 18 deletions build/Table.css
Expand Up @@ -14,22 +14,32 @@
.u-table th {
background: #f7f7f7;
font-weight: bold;
transition: background .3s ease; }
transition: background 0.3s ease; }
.u-table th[colspan] {
text-align: center; }
.u-table td {
border-bottom: 1px solid #e9e9e9; }
.u-table tr {
transition: all .3s ease; }
transition: all 0.3s ease; }
.u-table tr:hover {
background: rgb(227,242,253); }
.u-table tr.tr-row-hover {
background: rgb(227,242,253); }
.u-table th, .u-table td {
.u-table th,
.u-table td {
padding: 16px 8px;
word-break: break-all; }
.u-table-row-hover {
background: #e3f2fd; }
.u-table-scroll {
overflow: auto; }
.u-table-bordered table {
border: 1px solid #e9e9e9; }
.u-table-bordered th {
border-bottom: 1px solid #e9e9e9; }
.u-table-bordered th,
.u-table-bordered td {
border-right: 1px solid #e9e9e9; }
.u-table-header {
overflow: hidden;
background: #f7f7f7; }
Expand All @@ -38,7 +48,7 @@
position: relative; }
.u-table-fixed-header .u-table-body-inner {
height: 100%;
overflow: scroll; }
overflow-y: hidden; }
.u-table-fixed-header .u-table-scroll .u-table-header {
overflow-x: scroll;
padding-bottom: 20px;
Expand Down Expand Up @@ -77,11 +87,11 @@
.u-table-row-spaced, .u-table-expanded-row-spaced {
visibility: hidden; }
.u-table-row-spaced:after, .u-table-expanded-row-spaced:after {
content: '.'; }
content: "."; }
.u-table-row-expanded:after, .u-table-expanded-row-expanded:after {
content: '-'; }
content: "-"; }
.u-table-row-collapsed:after, .u-table-expanded-row-collapsed:after {
content: '+'; }
content: "+"; }
.u-table tr.u-table-expanded-row {
background: #f7f7f7; }
.u-table tr.u-table-expanded-row:hover {
Expand All @@ -102,11 +112,11 @@
.u-table-prev-columns-page {
margin-right: 8px; }
.u-table-prev-columns-page:before {
content: '<'; }
content: "<"; }
.u-table-next-columns-page {
float: right; }
.u-table-next-columns-page:before {
content: '>'; }
content: ">"; }
.u-table-fixed-left, .u-table-fixed-right {
position: absolute;
top: 0;
Expand Down Expand Up @@ -137,10 +147,12 @@
.u-table.bordered table {
border-collapse: collapse; }

.u-table.bordered th, .u-table.bordered td {
.u-table.bordered th,
.u-table.bordered td {
border: 1px solid #e9e9e9; }

.move-enter, .move-appear {
.move-enter,
.move-appear {
opacity: 0;
animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
animation-duration: 2.5s;
Expand All @@ -149,11 +161,12 @@

.move-leave {
animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
animation-duration: .5s;
animation-duration: 0.5s;
animation-fill-mode: both;
animation-play-state: paused; }

.move-enter.move-enter-active, .move-appear.move-enter-active {
.move-enter.move-enter-active,
.move-appear.move-enter-active {
animation-name: moveLeftIn;
animation-play-state: running; }

Expand Down Expand Up @@ -198,7 +211,7 @@
/* margin-top: 5px; */
/* margin-bottom: 5px; */
background: transparent;
color: #F22C1D;
color: #f22c1d;
/* padding-left: 12px; */
/* padding-right: 12px; */
margin: 0;
Expand Down Expand Up @@ -285,12 +298,14 @@
.bee-table-column-sorter-up.on .uf-triangle-up {
color: #108ee9; }

.bee-table-column-sorter .uf-triangle-down, .bee-table-column-sorter .uf-triangle-up {
.bee-table-column-sorter .uf-triangle-down,
.bee-table-column-sorter .uf-triangle-up {
-webkit-filter: none;
filter: none;
font-size: 12px; }

.bee-table-column-sorter .uf-triangle-down, .bee-table-column-sorter .uf-triangle-up {
.bee-table-column-sorter .uf-triangle-down,
.bee-table-column-sorter .uf-triangle-up {
display: inline-block;
padding: 0;
font-size: 12px;
Expand All @@ -303,5 +318,5 @@
line-height: 4px;
height: 4px;
color: #999;
-webkit-transition: all .3s;
transition: all .3s; }
-webkit-transition: all 0.3s;
transition: all 0.3s; }
3 changes: 3 additions & 0 deletions build/Table.js
Expand Up @@ -802,6 +802,9 @@ var Table = function (_Component) {
if (props.useFixedHeader || props.scroll && props.scroll.y) {
className += ' ' + clsPrefix + '-fixed-header';
}
if (props.bordered) {
className += ' ' + clsPrefix + '-bordered';
}
className += ' ' + clsPrefix + '-scroll-position-' + this.state.scrollPosition;

var isTableScroll = this.columnManager.isAnyColumnsFixed() || props.scroll.x || props.scroll.y;
Expand Down
1 change: 0 additions & 1 deletion demo/demolist/Demo14.js
Expand Up @@ -299,7 +299,6 @@ class Demo14 extends React.Component {
获取数据
</Button>
<Table
bordered
data={dataSource}
columns={columns}
getBodyWrapper={this.getBodyWrapper}
Expand Down
1 change: 0 additions & 1 deletion demo/demolist/Demo2.js
Expand Up @@ -190,7 +190,6 @@ class Demo2 extends React.Component {
添加
</Button>
<Table
bordered
data={dataSource}
columns={columns}
getBodyWrapper={this.getBodyWrapper}
Expand Down
151 changes: 102 additions & 49 deletions demo/demolist/Demo3.js
@@ -1,60 +1,113 @@
/**
*
* @title 更灵活的表格
* @description 手写表格的头组件来达到更灵活的配置表格
*
*/
*
* @title 表头分组
* @description columns[n] 可以内嵌 children,以渲染分组表头。
*
*/


import Button from 'bee-button';
import React, { Component } from 'react';
import Table from '../../src';
import Button from "bee-button";
import React, { Component } from "react";
import Table from "../../src";

const { ColumnGroup, Column } = Table;

const data3 = [
{ a: '北京', b: '北京', c: '250', d: 2, key: '1' },
const columns = [
{
title: "Name",
dataIndex: "name",
key: "name",
width: 100,
fixed: "left"
},
{
title: "Other",
children: [
{
title: "Age",
dataIndex: "age",
key: "age",
width: 200
},
{
title: "Address",
children: [
{
title: "Street",
dataIndex: "street",
key: "street",
width: 200
},
{
title: "Block",
children: [
{
title: "Building",
dataIndex: "building",
key: "building",
width: 100
},
{
title: "Door No.",
dataIndex: "number",
key: "number",
width: 100
}
]
}
]
}
]
},
{
title: "Company",
children: [
{
title: "Company Address",
dataIndex: "companyAddress",
key: "companyAddress"
},
{
title: "Company Name",
dataIndex: "companyName",
key: "companyName"
}
]
},
{
title: "Gender",
dataIndex: "gender",
key: "gender",
width: 60,
fixed: "right"
}
];

class Demo3 extends Component {
render () {
return (
const data = [];
for (let i = 0; i < 20; i++) {
data.push({
key: i,
name: "John Brown",
age: i + 1,
street: "Lake Park",
building: "C",
number: 2035,
companyAddress: "Lake Street 42",
companyName: "SoftLake Co",
gender: "M"
});
}

<Table data={data3}>
<ColumnGroup title="地址">
<Column
title="省"
dataIndex="a"
key="a"
width={100}
/>
<Column
id="123"
title="市"
dataIndex="b"
key="b"
width={100}
class Demo3 extends Component {
render() {
return (
<Table
columns={columns}
data={data}
bordered
scroll={{ x: "130%", y: 240 }}
/>
</ColumnGroup>
<Column
title="数量"
dataIndex="c"
key="c"
width={200}
/>
<Column
title="操作"
dataIndex=""
key="d"
render={(text, record, index) => {
return (
<Button size="sm" colors="info" style={{ minWidth: 50 }}>增加</Button>
);
}}
/>
</Table>
)
}
);
}
}

export default Demo3;
export default Demo3;
2 changes: 1 addition & 1 deletion demo/demolist/Demo5.js
Expand Up @@ -60,7 +60,7 @@ const data5 = [

class Demo5 extends Component {
render() {
return <Table columns={columns5} data={data5}/>;
return <Table columns={columns5} data={data5}scroll={{ x: "130%", y: 140 }}/>;
}
}

Expand Down
2 changes: 1 addition & 1 deletion demo/index.js

Large diffs are not rendered by default.

0 comments on commit 8117b1c

Please sign in to comment.