Skip to content

Commit

Permalink
fix(table): #2596
Browse files Browse the repository at this point in the history
  • Loading branch information
zyprepare committed Sep 19, 2023
1 parent 3c16b3b commit fb9b128
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-books-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/table": patch
---

fix: 修复紧凑模式下多选项间距问题
5 changes: 5 additions & 0 deletions .changeset/smart-onions-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

Table fix: 修复紧凑模式下多选项间距问题
5 changes: 3 additions & 2 deletions packages/ui/table/src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ export const Table = forwardRef<HTMLDivElement | null, TableProps>(
const checkboxColWidth = React.useMemo(() => {
return rowSelection && typeof rowSelection.checkboxColWidth === 'number'
? rowSelection.checkboxColWidth
: 38
}, [rowSelection])
: // 适配不同尺寸,默认常规尺寸
{ sm: 36, md: 44, lg: 52 }[rest.size ?? 'md']
}, [rest.size, rowSelection])

// 预处理 column 支持 多选渲染
const {
Expand Down
50 changes: 36 additions & 14 deletions packages/ui/table/src/styles/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,20 @@ $emptyContent: '#{$component-prefix}-table-empty-content' !default;
tbody {
& > tr:not(.#{$emptyContent}) > td {
padding: use-spacing(7);

&.#{$prefix}__selection-col {
padding: use-spacing(7);
}
}
}

thead {
& > tr > th {
padding: use-spacing(7);

&.#{$prefix}__selection-col {
padding: use-spacing(7);
}
}
}
}
Expand All @@ -59,12 +67,20 @@ $emptyContent: '#{$component-prefix}-table-empty-content' !default;
tbody {
& > tr:not(.#{$emptyContent}) > td {
padding: use-spacing(5);

&.#{$prefix}__selection-col {
padding: use-spacing(5);
}
}
}

thead {
& > tr > th {
padding: use-spacing(5);

&.#{$prefix}__selection-col {
padding: use-spacing(5);
}
}
}
}
Expand All @@ -75,12 +91,20 @@ $emptyContent: '#{$component-prefix}-table-empty-content' !default;
tbody {
& > tr:not(.#{$emptyContent}) > td {
padding: use-spacing(9);

&.#{$prefix}__selection-col {
padding: use-spacing(9);
}
}
}

thead {
& > tr > th {
padding: use-spacing(9);

&.#{$prefix}__selection-col {
padding: use-spacing(9);
}
}
}
}
Expand Down Expand Up @@ -161,6 +185,17 @@ $emptyContent: '#{$component-prefix}-table-empty-content' !default;

&-cell {
background-color: use-color('gray', 50);
color: use-color('gray', 700);
font-size: use-text-size('normal');
font-weight: use-text-weight('medium');
line-height: use-text-lineheight('sm');
padding: use-spacing(7) use-spacing(8);
border-bottom: use-border-size('normal') use-color('gray', 300);

&.#{$prefix}__embed-col,
&.#{$prefix}__selection-col {
padding: use-spacing(7) use-spacing(5);
}

$this: &;

Expand Down Expand Up @@ -241,6 +276,7 @@ $emptyContent: '#{$component-prefix}-table-empty-content' !default;
}
}
}

&--virtual {
display: flex;
}
Expand Down Expand Up @@ -270,20 +306,6 @@ $emptyContent: '#{$component-prefix}-table-empty-content' !default;
overflow: auto;
}

.#{$prefix}-header-cell {
color: use-color('gray', 700);
font-size: use-text-size('normal');
font-weight: use-text-weight('medium');
line-height: use-text-lineheight('sm');
padding: use-spacing(7) use-spacing(8);
border-bottom: use-border-size('normal') use-color('gray', 300);

&.#{$prefix}__embed-col,
&.#{$prefix}__selection-col {
padding: use-spacing(7) use-spacing(5);
}
}

// 单元格
.#{$prefix}-cell {
word-break: break-word;
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/table/stories/size.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ export const Size = () => {
<>
<h1>Size for Table</h1>
<div className="table-size__wrap" style={{ minWidth: 660, background: '#fff' }}>
<Table bordered columns={column} data={data} size="sm" />
<Table bordered columns={column} data={data} size="sm" rowSelection={{}} />
<br />
<br />
<Table bordered columns={column} data={data} size="md" />
<Table bordered columns={column} data={data} size="md" rowSelection={{}} />
<br />
<br />
<Table bordered columns={column} data={data} size="lg" />
<Table bordered columns={column} data={data} size="lg" rowSelection={{}} />
</div>
</>
)
Expand Down

0 comments on commit fb9b128

Please sign in to comment.