Skip to content

Commit

Permalink
improve(design): Table border-bottom display logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dengfuping committed Nov 11, 2024
1 parent 2d5b986 commit a3fc280
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
3 changes: 3 additions & 0 deletions packages/design/src/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function Table<T extends Record<string, any>>(props: TableProps<T>, ref: React.R
const {
locale: customLocale,
columns,
footer,
pagination: customPagination,
rowSelection,
toolAlertRender,
Expand Down Expand Up @@ -80,6 +81,7 @@ function Table<T extends Record<string, any>>(props: TableProps<T>, ref: React.R
const tableCls = classNames(
{
[`${prefixCls}-expandable`]: !isEmpty(expandable),
[`${prefixCls}-has-footer`]: !!footer,
},
className
);
Expand Down Expand Up @@ -238,6 +240,7 @@ function Table<T extends Record<string, any>>(props: TableProps<T>, ref: React.R
}
: undefined
}
footer={footer}
pagination={
pagination === false
? false
Expand Down
24 changes: 9 additions & 15 deletions packages/design/src/table/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export const genTableStyle: GenerateStyle<TableToken> = (token: TableToken): CSS
color: colorText,
backgroundColor: colorBgBase,
borderRadius: borderRadiusLG,
[`${componentCls}-footer`]: {
borderBottom: `1px solid ${colorBorderSecondary}`,
},
// head 样式
[`${componentCls}-thead > tr`]: {
['td, th']: {
Expand Down Expand Up @@ -115,6 +118,12 @@ export const genTableStyle: GenerateStyle<TableToken> = (token: TableToken): CSS
},
},

// 非可展开表格、带 footer 表格、空表格、带边框表格: 底部添加分隔线
[`${componentCls}-wrapper:not(${componentCls}-expandable):not(${componentCls}-has-footer) ${componentCls}:not(${componentCls}-bordered):not(${componentCls}-empty)`]:
{
borderBottom: `1px solid ${colorBorderSecondary}`,
},

// 滚动表格样式
// 由于滚动表格会在 tbody 下最前面多一个 tr 元素,因此需要设置相反的斑马条样式
// .ant-table-scroll-horizontal: 水平滚动
Expand Down Expand Up @@ -163,12 +172,6 @@ export const genTableStyle: GenerateStyle<TableToken> = (token: TableToken): CSS
},
},
},
// Remove pagination borderTop for expandable Table
[`${componentCls}-pagination`]: {
[`&${antCls}-pagination`]: {
borderTop: 'none',
},
},
},

// loading style
Expand All @@ -187,7 +190,6 @@ export const genTableStyle: GenerateStyle<TableToken> = (token: TableToken): CSS
[`&${antCls}-pagination`]: {
padding: `${padding}px 0`,
margin: '0 !important',
borderTop: `1px solid ${colorBorderSecondary}`,
},
// 批量操作栏样式
[`${componentCls}-batch-operation-bar`]: {
Expand All @@ -205,14 +207,6 @@ export const genTableStyle: GenerateStyle<TableToken> = (token: TableToken): CSS
},
},
},
// Remove pagination borderTop for bordered Table
[`${componentCls}${componentCls}-bordered`]: {
[`&+${componentCls}-pagination`]: {
[`&${antCls}-pagination`]: {
borderTop: 'none',
},
},
},
},

// 批量操作栏中的弹出层样式
Expand Down

0 comments on commit a3fc280

Please sign in to comment.