Skip to content

Commit

Permalink
Merge pull request #195 from oceanbase/dengfuping-dev
Browse files Browse the repository at this point in the history
fix(design): zebra stripe style should be correct for scroll table
  • Loading branch information
dengfuping authored Oct 19, 2023
2 parents bc20fcb + 3357711 commit 37858ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const App: React.FC = () => {
const columns: ColumnProps<DataType>[] = [
{
title: 'Full Name',
width: 100,
width: 120,
dataIndex: 'name',
key: 'name',
fixed: 'left',
Expand Down Expand Up @@ -76,7 +76,7 @@ const App: React.FC = () => {
},
];

return <Table columns={columns} dataSource={dataSource} scroll={{ x: 1440, y: 200 }} />;
return <Table columns={columns} dataSource={dataSource} scroll={{ x: 1440 }} />;
};

export default App;
19 changes: 19 additions & 0 deletions packages/design/src/table/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,25 @@ export const genTableStyle: GenerateStyle<TableToken> = (token: TableToken): CSS
},
},

// 滚动表格样式
// 由于滚动表格会在 tbody 下最前面多一个 tr 元素,因此需要设置相反的斑马条样式
// .ant-table-scroll-horizontal: 水平滚动
// .ant-table-fixed-header: 垂直滚动
[`${componentCls}-wrapper ${componentCls}${componentCls}-scroll-horizontal, ${componentCls}-wrapper ${componentCls}${componentCls}-fixed-header`]:
{
[`${componentCls}-tbody`]: {
// 斑马纹样式
[`tr:nth-child(2n + 1):not(${componentCls}-placeholder):not(${componentCls}-row-selected):not(${antCls}-descriptions-row) > td`]:
{
backgroundColor: colorFillQuaternary,
},
[`tr:nth-child(2n):not(${componentCls}-placeholder):not(${componentCls}-row-selected):not(${componentCls}-expanded-row):not(${antCls}-descriptions-row) > td`]:
{
backgroundColor: colorBgBase,
},
},
},

// large 表格样式
[`${componentCls}-wrapper`]: {
[`${componentCls}:not(${componentCls}-middle):not(${componentCls}-small)`]: {
Expand Down

0 comments on commit 37858ef

Please sign in to comment.