Skip to content

Commit

Permalink
fix: table�: groups header right border on last element in n+1 rows i…
Browse files Browse the repository at this point in the history
…s 0 when bordered prop is true (#492)

* fix: table�: groups header right border on last element in n+1 rows is 0 when bordered prop is true

* chore: table: revert selector omission

* chore: table: address pr feedback

includes some more css cleanup
  • Loading branch information
dkilgore-eightfold authored Jan 9, 2023
1 parent 3689147 commit 96150f8
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 78 deletions.
3 changes: 0 additions & 3 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@
overflow: hidden;
padding: 16px;
}
.grouped-th {
border-bottom: none !important;
}
</style>
2 changes: 2 additions & 0 deletions src/components/Table/Internal/OcTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function OcTable<RecordType extends DefaultRecordType>(
props: OcTableProps<RecordType>
) {
const {
bordered,
classNames,
rowClassName,
style,
Expand Down Expand Up @@ -671,6 +672,7 @@ function OcTable<RecordType extends DefaultRecordType>(
<div
className={mergeClasses([
styles.table,
{ [styles.tableBordered]: bordered },
{ [styles.tableRtl]: direction === 'rtl' },
{ [styles.tablePingLeft]: pingedLeft },
{ [styles.tablePingRight]: pingedRight },
Expand Down
4 changes: 4 additions & 0 deletions src/components/Table/Internal/OcTable.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ export interface MemoTableContentProps {
}

export interface OcTableProps<RecordType = unknown> {
/**
* Show all Table borders.
*/
bordered?: boolean;
/**
* The Table custom class names.
*/
Expand Down
65 changes: 39 additions & 26 deletions src/components/Table/Internal/octable.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

&::-webkit-scrollbar {
background-color: transparent;
height: 16px;
width: 16px;
height: $space-m;
width: $space-m;
}

&::-webkit-scrollbar-corner {
Expand All @@ -29,8 +29,8 @@
&:hover:focus {
&::-webkit-scrollbar {
display: block;
height: 16px;
width: 16px;
height: $space-m;
width: $space-m;
}

&::-webkit-scrollbar-button {
Expand All @@ -52,7 +52,7 @@
&::-webkit-scrollbar-thumb {
background-color: transparent;
border: 5px solid transparent;
border-radius: 24px;
border-radius: $border-radius-xl;
box-shadow: 4px 0px 0px 4px rgba(105, 113, 127, 0.7) inset;
}
}
Expand All @@ -70,8 +70,8 @@

&::-webkit-scrollbar {
background-color: $table-background-color;
height: 16px;
width: 16px;
height: $space-m;
width: $space-m;
}

&::-webkit-scrollbar-corner {
Expand All @@ -83,7 +83,7 @@
&::-webkit-scrollbar-thumb {
background-color: transparent;
border: 5px solid transparent;
border-radius: 24px;
border-radius: $border-radius-xl;
box-shadow: 4px 0px 0px 4px rgba(105, 113, 127, 0.7) inset;
}

Expand Down Expand Up @@ -121,7 +121,7 @@
white-space: normal;
border-top: 0;
border-left: 0;
transition: box-shadow 0.3s;
transition: box-shadow $motion-duration-extra-fast;
}

&-cell {
Expand All @@ -144,7 +144,7 @@
bottom: -1px;
width: 20px;
transform: translateX(100%);
transition: box-shadow 0.3s;
transition: box-shadow $motion-duration-extra-fast;
content: '';
pointer-events: none;
}
Expand All @@ -158,7 +158,7 @@
left: -1px;
width: 20px;
transform: translateX(-100%);
transition: box-shadow 0.3s;
transition: box-shadow $motion-duration-extra-fast;
content: '';
pointer-events: none;
}
Expand Down Expand Up @@ -239,6 +239,16 @@
}
}

&-bordered {
&.table-ping-right {
.table-cell-fix-right-first,
.table-cell-fix-right-last {
border-left: $table-border;
padding-left: calc($table-padding-horizontal-md - 1px);
}
}
}

&-expand-icon-col {
width: 84px;
}
Expand Down Expand Up @@ -297,14 +307,6 @@
color: $table-header-foreground-color;
}

&-placeholder {
&:nth-child(odd) td {
background-color: $table-background-color !important;
}

text-align: center;
}

tbody {
tr {
&:last-of-type {
Expand All @@ -327,6 +329,10 @@
}
}

&-placeholder {
text-align: center;
}

&-container {
color: $table-foreground-color;
}
Expand Down Expand Up @@ -377,10 +383,10 @@

&-row-expand-icon {
display: inline-block;
width: 16px;
height: 16px;
width: $space-m;
height: $text-line-height-1;
color: #aaa;
line-height: 16px;
line-height: $text-line-height-1;
text-align: center;
vertical-align: middle;
border: 1px solid currentColor;
Expand Down Expand Up @@ -472,10 +478,6 @@
border-left-color: transparent;
}

&-fix-left-first {
box-shadow: 1px 0 0 $table-border-color;
}

&-fix-right-first,
&-fix-right-last {
box-shadow: none;
Expand Down Expand Up @@ -525,6 +527,17 @@
}
}

// TODO: handle internal ping styles for other border props e.g. header-border
&.table-bordered {
&.table-ping-left {
.table-cell-fix-left-first:after,
.table-cell-fix-left-last:after {
border-left: $table-border;
right: 0;
}
}
}

thead {
td,
th {
Expand Down
50 changes: 32 additions & 18 deletions src/components/Table/Styles/bordered.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
tfoot tr td {
border-right: $table-border-width $table-border-style
$table-border-color;
}

tbody tr td,
tfoot tr th,
tfoot tr td {
&:last-of-type {
border-right: none;
}
Expand Down Expand Up @@ -61,7 +65,8 @@

table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical (-$table-padding-horizontal - 1);
margin: -$table-padding-vertical
calc(calc($table-padding-horizontal - 1px) * -1);

&:after {
position: absolute;
Expand Down Expand Up @@ -94,7 +99,7 @@
table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical-md
(-$table-padding-horizontal-md - 1);
calc(calc($table-padding-horizontal-md - 1px) * -1);
}
}
}
Expand All @@ -108,7 +113,7 @@
table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical-sm
(-$table-padding-horizontal-sm - 1);
calc(calc($table-padding-horizontal-sm - 1px) * -1);
}
}
}
Expand Down Expand Up @@ -189,7 +194,8 @@

table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical (-$table-padding-horizontal - 1);
margin: -$table-padding-vertical
calc(calc($table-padding-horizontal - 1px) * -1);

&:after {
position: absolute;
Expand All @@ -209,7 +215,7 @@
table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical-md
(-$table-padding-horizontal-md - 1);
calc(calc($table-padding-horizontal-md - 1px) * -1);
}
}
}
Expand All @@ -223,7 +229,7 @@
table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical-sm
(-$table-padding-horizontal-sm - 1);
calc(calc($table-padding-horizontal-sm - 1px) * -1);
}
}
}
Expand Down Expand Up @@ -264,10 +270,6 @@

border-right: $table-border-width $table-border-style
$table-border-color;

&:last-of-type {
border-right: none;
}
}

tbody tr td,
Expand Down Expand Up @@ -305,7 +307,8 @@

table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical (-$table-padding-horizontal - 1);
margin: -$table-padding-vertical
calc(calc($table-padding-horizontal - 1px) * -1);

&:after {
position: absolute;
Expand All @@ -325,7 +328,7 @@
table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical-md
(-$table-padding-horizontal-md - 1);
calc(calc($table-padding-horizontal-md - 1px) * -1);
}
}
}
Expand All @@ -339,7 +342,7 @@
table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical-sm
(-$table-padding-horizontal-sm - 1);
calc(calc($table-padding-horizontal-sm - 1px) * -1);
}
}
}
Expand Down Expand Up @@ -388,14 +391,24 @@
&:first-of-type {
border-left: none;
}
}

thead tr th,
tbody tr td,
tfoot tr th,
tfoot tr td {
border-right: $table-border-width $table-border-style
$table-border-color;
}

tbody tr td,
tfoot tr th,
tfoot tr td {
&:last-of-type {
border-right: none;
}
}

thead {
tr th {
border-bottom: $table-border;
Expand Down Expand Up @@ -425,7 +438,8 @@

table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical (-$table-padding-horizontal - 1);
margin: -$table-padding-vertical
calc(calc($table-padding-horizontal - 1px) * -1);

&:after {
position: absolute;
Expand All @@ -445,7 +459,7 @@
table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical-md
(-$table-padding-horizontal-md - 1);
calc(calc($table-padding-horizontal-md - 1px) * -1);
}
}
}
Expand All @@ -459,7 +473,7 @@
table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical-sm
(-$table-padding-horizontal-sm - 1);
calc(calc($table-padding-horizontal-sm - 1px) * -1);
}
}
}
Expand Down Expand Up @@ -521,7 +535,7 @@
table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical-md
(-$table-padding-horizontal-md - 1);
calc(calc($table-padding-horizontal-md - 1px) * -1);
}
}
}
Expand All @@ -535,7 +549,7 @@
table tbody tr td {
.table-expanded-row-fixed {
margin: -$table-padding-vertical-sm
(-$table-padding-horizontal-sm - 1);
calc(calc($table-padding-horizontal-sm - 1px) * -1);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/Styles/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $border: $border-width solid $border-color;
text-decoration: none;
outline: none;
cursor: pointer;
transition: color 0.3s;
transition: color $motion-duration-extra-fast;

&:focus,
&:hover {
Expand Down
Loading

0 comments on commit 96150f8

Please sign in to comment.