Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: table update style #2608

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions components/Table/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,53 @@
}
}

//存在滚动条且不在右侧,需要把右侧首个td/th边框设置成与背景同色,防止边框颜色展示
&-border-cell {
&.@{table-prefix-cls}-scroll-position-left,
&.@{table-prefix-cls}-scroll-position-middle {
.@{table-cls-td}.@{table-prefix-cls}-col-fixed-right-first {
border-left-color: @table-color-bg-body-cell;
}
.@{table-cls-th}.@{table-prefix-cls}-col-fixed-right-first {
border-left-color: @table-color-bg-header-cell;
}
}
}

// 存在滚动条且不在右侧,只开启了header边框时需要把th的左边框隐藏
&-border-header-cell {
&.@{table-prefix-cls}-scroll-position-left,
&.@{table-prefix-cls}-scroll-position-middle {
.@{table-cls-th}.@{table-prefix-cls}-col-fixed-right-first {
border-left-color: @table-color-bg-header-cell;
}
}
}

// 存在滚动条且不在右侧,只开启了body边框时需要把td的左边框隐藏
&-border-body-cell {
&.@{table-prefix-cls}-scroll-position-left,
&.@{table-prefix-cls}-scroll-position-middle {
.@{table-cls-td}.@{table-prefix-cls}-col-fixed-right-first {
border-left-color: @table-color-bg-body-cell;
}
}
}

// 存在body边框但不存在header边框时,需要header也增加隐形的边框确保对齐
&-border-body-cell:not(&-border-header-cell) {
.@{table-cls-th}.@{table-prefix-cls}-col-fixed-right-first {
border-left: @table-border-width @table-border-style @table-color-bg-header-cell;
}
}

// 存在header边框但不存在body边框时,需要body也增加隐形的边框确保对齐
&-border-header-cell:not(&-border-body-cell) {
.@{table-cls-td}.@{table-prefix-cls}-col-fixed-right-first {
border-left: @table-border-width @table-border-style @table-color-bg-body-cell;
}
}

// stripe: true
&-stripe {
.@{table-cls-tr}:nth-child(even) .@{table-cls-td} {
Expand Down Expand Up @@ -690,6 +737,32 @@
}
}

&.@{table-prefix-cls}-border-header-cell:not(.@{table-prefix-cls}-border-body-cell) {
.@{table-cls-tr}:not(.@{table-prefix-cls}-empty-row):hover {
.@{table-cls-td}.@{table-prefix-cls}-col-fixed-right {
border-left-color: @table-color-bg-body-row_hover;

.@{table-prefix-cls}-rtl & {
border-left: unset;
border-right-color: @table-color-bg-body-row_hover;
}
}
}
}

&.@{table-prefix-cls}-border-body-cell:not(.@{table-prefix-cls}-border-header-cell) {
.@{table-cls-tr}:not(.@{table-prefix-cls}-empty-row):hover {
.@{table-cls-th}.@{table-prefix-cls}-col-fixed-right {
border-left-color: @table-color-bg-body-row_hover;

.@{table-prefix-cls}-rtl & {
border-left: unset;
border-right-color: @table-color-bg-body-row_hover;
}
}
}
}

// 展开行的hover效果
.@{table-prefix-cls}-expand-content:not(.@{table-prefix-cls}-empty-row):hover
.@{table-cls-td}:not(.@{table-prefix-cls}-col-fixed-left):not(.@{table-prefix-cls}-col-fixed-right) {
Expand Down Expand Up @@ -861,6 +934,54 @@
}
}

&-rtl&-border-cell {
&.@{table-prefix-cls}-scroll-position-right,
&.@{table-prefix-cls}-scroll-position-middle {
.@{table-cls-td}.@{table-prefix-cls}-col-fixed-right-first {
border-left-color: unset;
border-right-color: @table-color-bg-body-cell;
}
.@{table-cls-th}.@{table-prefix-cls}-col-fixed-right-first {
border-left-color: unset;
border-right-color: @table-color-bg-header-cell;
}
}
}

&-rtl&-border-header-cell {
&.@{table-prefix-cls}-scroll-position-right,
&.@{table-prefix-cls}-scroll-position-middle {
.@{table-cls-th}.@{table-prefix-cls}-col-fixed-right-first {
border-left-color: unset;
border-right-color: @table-color-bg-header-cell;
}
}
}

&-rtl&-border-body-cell {
&.@{table-prefix-cls}-scroll-position-right,
&.@{table-prefix-cls}-scroll-position-middle {
.@{table-cls-td}.@{table-prefix-cls}-col-fixed-right-first {
border-left-color: unset;
border-right-color: @table-color-bg-body-cell;
}
}
}

&-rtl&-border-body-cell:not(&-border-header-cell) {
.@{table-cls-th}.@{table-prefix-cls}-col-fixed-right-first {
border-left: unset;
border-right: @table-border-width @table-border-style @table-color-bg-header-cell;
}
}

&-rtl&-border-header-cell:not(&-border-body-cell) {
.@{table-cls-td}.@{table-prefix-cls}-col-fixed-right-first {
border-left: unset;
border-right: @table-border-width @table-border-style @table-color-bg-body-cell;
}
}

&-rtl &-cell-indent {
float: right;
}
Expand Down
10 changes: 9 additions & 1 deletion components/Table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,15 @@ function Table<T extends unknown>(baseProps: TableProps<T>, ref: React.Ref<Table
off(tableFoot, 'scroll', tableScrollHandler);
}
};
}, [hasFixedColumnLeft, hasFixedColumnRight, scroll?.x, scroll?.y, flattenColumns.length, data]);
}, [
hasFixedColumnLeft,
hasFixedColumnRight,
scroll?.x,
scroll?.y,
flattenColumns.length,
data,
rtl,
]);

useUpdate(() => {
const { total, pageSize } = getPaginationProps(data);
Expand Down