diff --git a/.storybook/preview-head.html b/.storybook/preview-head.html index 72eeb9e5f..11f883a0e 100644 --- a/.storybook/preview-head.html +++ b/.storybook/preview-head.html @@ -18,7 +18,4 @@ overflow: hidden; padding: 16px; } - .grouped-th { - border-bottom: none !important; - } diff --git a/src/components/Table/Internal/OcTable.tsx b/src/components/Table/Internal/OcTable.tsx index 9dbe2b8c5..9723837ae 100644 --- a/src/components/Table/Internal/OcTable.tsx +++ b/src/components/Table/Internal/OcTable.tsx @@ -88,6 +88,7 @@ function OcTable( props: OcTableProps ) { const { + bordered, classNames, rowClassName, style, @@ -671,6 +672,7 @@ function OcTable(
{ + /** + * Show all Table borders. + */ + bordered?: boolean; /** * The Table custom class names. */ diff --git a/src/components/Table/Internal/octable.module.scss b/src/components/Table/Internal/octable.module.scss index 7b8c09abd..33073e25a 100644 --- a/src/components/Table/Internal/octable.module.scss +++ b/src/components/Table/Internal/octable.module.scss @@ -3,8 +3,8 @@ &::-webkit-scrollbar { background-color: transparent; - height: 16px; - width: 16px; + height: $space-m; + width: $space-m; } &::-webkit-scrollbar-corner { @@ -29,8 +29,8 @@ &:hover:focus { &::-webkit-scrollbar { display: block; - height: 16px; - width: 16px; + height: $space-m; + width: $space-m; } &::-webkit-scrollbar-button { @@ -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; } } @@ -70,8 +70,8 @@ &::-webkit-scrollbar { background-color: $table-background-color; - height: 16px; - width: 16px; + height: $space-m; + width: $space-m; } &::-webkit-scrollbar-corner { @@ -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; } @@ -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 { @@ -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; } @@ -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; } @@ -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; } @@ -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 { @@ -327,6 +329,10 @@ } } + &-placeholder { + text-align: center; + } + &-container { color: $table-foreground-color; } @@ -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; @@ -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; @@ -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 { diff --git a/src/components/Table/Styles/bordered.scss b/src/components/Table/Styles/bordered.scss index 869215518..590968127 100644 --- a/src/components/Table/Styles/bordered.scss +++ b/src/components/Table/Styles/bordered.scss @@ -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; } @@ -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; @@ -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); } } } @@ -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); } } } @@ -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; @@ -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); } } } @@ -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); } } } @@ -264,10 +270,6 @@ border-right: $table-border-width $table-border-style $table-border-color; - - &:last-of-type { - border-right: none; - } } tbody tr td, @@ -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; @@ -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); } } } @@ -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); } } } @@ -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; @@ -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; @@ -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); } } } @@ -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); } } } @@ -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); } } } @@ -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); } } } diff --git a/src/components/Table/Styles/mixins.scss b/src/components/Table/Styles/mixins.scss index 694b9d462..e4a574000 100644 --- a/src/components/Table/Styles/mixins.scss +++ b/src/components/Table/Styles/mixins.scss @@ -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 { diff --git a/src/components/Table/Styles/rtl.scss b/src/components/Table/Styles/rtl.scss index 230c01675..12c6f5576 100644 --- a/src/components/Table/Styles/rtl.scss +++ b/src/components/Table/Styles/rtl.scss @@ -120,13 +120,17 @@ tbody tr td, tfoot tr th, tfoot tr td { - border-right: none; - border-left: $table-border-width $table-border-style $table-border-color; + border-right: none; + } + tbody tr td, + tfoot tr th, + tfoot tr td { &:last-of-type { - border-left: none; + border-left: $table-border-width $table-border-style + $table-border-color; border-right: none; } } diff --git a/src/components/Table/Styles/size.scss b/src/components/Table/Styles/size.scss index 5bf68a9b4..197ed9a5e 100644 --- a/src/components/Table/Styles/size.scss +++ b/src/components/Table/Styles/size.scss @@ -14,7 +14,7 @@ } &-filter-trigger { - margin-right: -($table-padding-horizontal / 2); + margin-right: calc(($table-padding-horizontal / 2) * -1); } &-expanded-row-fixed { @@ -25,7 +25,7 @@ .table-wrapper:only-child { .table { margin: -$table-padding-vertical -$table-padding-horizontal -$table-padding-vertical - ($table-padding-horizontal + ceil((14 * 1.4))); + calc($table-padding-horizontal + ceil((14 * 1.4))); } } } @@ -44,12 +44,21 @@ padding: $table-padding-vertical-lg $table-padding-horizontal-lg; } + &.table-bordered { + &.table-ping-right { + .table-cell-fix-right-first, + .table-cell-fix-right-last { + padding-left: calc($table-padding-horizontal-lg - 1px); + } + } + } + .table-title { padding: $table-padding-vertical-lg $table-padding-horizontal-lg; } .table-filter-trigger { - margin-right: -($table-padding-horizontal-lg / 2); + margin-right: calc(($table-padding-horizontal-lg / 2) * -1); } .table-expanded-row-fixed { @@ -60,13 +69,13 @@ .table-wrapper:only-child { .table { margin: -$table-padding-vertical-lg -$table-padding-horizontal-lg -$table-padding-vertical-lg - ($table-padding-horizontal-lg + ceil((14 * 1.4))); + calc($table-padding-horizontal-lg + ceil((14 * 1.4))); } } } .table-selection-column { - padding-inline-start: ($table-padding-horizontal-lg / 4); + padding-inline-start: calc($table-padding-horizontal-lg / 4); } } @@ -80,6 +89,15 @@ padding: $table-padding-vertical-md $table-padding-horizontal-md; } + &.table-bordered { + &.table-ping-right { + .table-cell-fix-right-first, + .table-cell-fix-right-last { + padding-left: calc($table-padding-horizontal-md - 1px); + } + } + } + .table-title { padding: $table-padding-vertical-md $table-padding-horizontal-md; } @@ -96,13 +114,13 @@ .table-wrapper:only-child { .table { margin: -$table-padding-vertical-md -$table-padding-horizontal-md -$table-padding-vertical-md - ($table-padding-horizontal-md + ceil((14 * 1.4))); + calc($table-padding-horizontal-md + ceil((14 * 1.4))); } } } .table-selection-column { - padding-inline-start: ($table-padding-horizontal-md / 4); + padding-inline-start: calc($table-padding-horizontal-md / 4); } } @@ -116,6 +134,15 @@ padding: $table-padding-vertical-sm $table-padding-horizontal-sm; } + &.table-bordered { + &.table-ping-right { + .table-cell-fix-right-first, + .table-cell-fix-right-last { + padding-left: calc($table-padding-horizontal-sm - 1px); + } + } + } + .table-title { padding: $table-padding-vertical-sm $table-padding-horizontal-sm; } @@ -125,7 +152,7 @@ } .table-filter-trigger { - margin-right: -($table-padding-horizontal-sm / 2); + margin-right: calc(calc($table-padding-horizontal-sm / 2) * -1); } .table-expanded-row-fixed { @@ -136,13 +163,13 @@ .table-wrapper:only-child { .table { margin: -$table-padding-vertical-sm -$table-padding-horizontal-sm -$table-padding-vertical-sm - ($table-padding-horizontal-sm + ceil((14 * 1.4))); + calc($table-padding-horizontal-sm + ceil((14 * 1.4))); } } } .table-selection-column { - padding-inline-start: ($table-padding-horizontal-sm / 4); + padding-inline-start: calc($table-padding-horizontal-sm / 4); } } } diff --git a/src/components/Table/Styles/table.module.scss b/src/components/Table/Styles/table.module.scss index 0038f14b2..0fee6fd87 100644 --- a/src/components/Table/Styles/table.module.scss +++ b/src/components/Table/Styles/table.module.scss @@ -82,7 +82,7 @@ font-weight: 500; text-align: left; background: $table-header-background-color; - transition: background 0.3s ease; + transition: background $motion-duration-extra-fast ease; &[colspan]:not([colspan='1']) { text-align: center; @@ -96,7 +96,7 @@ height: 1.6em; background-color: $table-header-cell-split-color; transform: translateY(-50%); - transition: background-color 0.3s; + transition: background-color $motion-duration-extra-fast; content: ''; } } @@ -112,13 +112,13 @@ &-tbody { tr { td { - transition: background 0.3s; + transition: background $motion-duration-extra-fast; .table-wrapper:only-child, .table-expanded-row-fixed > .table-wrapper:only-child { .table { margin: -$table-padding-vertical -$table-padding-horizontal -$table-padding-vertical - ($table-padding-horizontal + ceil(14px * 1.4)); + calc($table-padding-horizontal + ceil(14px * 1.4)); &-tbody > tr:last-child > td { border-bottom: 0; @@ -196,7 +196,7 @@ &-thead th.table-column-has-sorters { outline: none; cursor: pointer; - transition: all 0.3s; + transition: all $motion-duration-extra-fast; &:hover { background: $table-header-sort-active-background-color; @@ -252,7 +252,7 @@ margin-left: $space-xxs; color: $table-header-icon-color; font-size: 0; - transition: color 0.3s; + transition: color $motion-duration-extra-fast; &-inner { display: inline-flex; @@ -287,13 +287,13 @@ position: relative; display: flex; align-items: center; - margin: -4px calc(-#{$table-padding-horizontal} / 2) -4px 4px; + margin: -4px calc(calc(#{$table-padding-horizontal} / 2) * -1) -4px 4px; padding: 0 4px; color: $table-header-icon-color; font-size: $table-font-size-sm; border-radius: $table-border-radius; cursor: pointer; - transition: all 0.3s; + transition: all $motion-duration-extra-fast; &:hover { color: var(--text-secondary-color); @@ -386,6 +386,26 @@ } } + &-empty { + tbody { + tr { + text-align: center; + + &:nth-child(odd) { + td { + background-color: $table-background-color; + } + + &:hover { + td { + background-color: $table-background-color; + } + } + } + } + } + } + &-selection { position: relative; display: inline-flex; @@ -396,7 +416,7 @@ top: 0; z-index: 1; cursor: pointer; - transition: all 0.3s; + transition: all $motion-duration-extra-fast; margin-inline-start: 100%; padding-inline-start: calc(#{$table-padding-horizontal} / 4); @@ -436,15 +456,15 @@ width: 18px; height: 18px; padding: 0; - margin: 2px 16px 0 16px; + margin: 2px $space-m 0 $space-m; color: inherit; line-height: 18px; background: $table-expand-icon-background-color; border: 2px $table-border-style var(--grey-color-70); - border-radius: 4px; + border-radius: $border-radius-s; outline: none; transform: scale(unit(22) / unit(18)); - transition: all 0.3s; + transition: all $motion-duration-extra-fast; user-select: none; &:focus, @@ -457,7 +477,7 @@ &:after { position: absolute; background: currentcolor; - transition: transform 0.3s ease-out; + transition: transform $motion-duration-extra-fast ease-out; content: ''; } @@ -573,7 +593,7 @@ bottom: -1px; width: 30px; transform: translateX(100%); - transition: box-shadow 0.3s; + transition: box-shadow $motion-duration-extra-fast; content: ''; pointer-events: none; } @@ -586,7 +606,7 @@ left: 0; width: 30px; transform: translateX(-100%); - transition: box-shadow 0.3s; + transition: box-shadow $motion-duration-extra-fast; content: ''; pointer-events: none; } @@ -599,7 +619,7 @@ bottom: 0; z-index: 1; width: 30px; - transition: box-shadow 0.3s; + transition: box-shadow $motion-duration-extra-fast; content: ''; pointer-events: none; } diff --git a/src/components/Table/Table.tsx b/src/components/Table/Table.tsx index f2aed57d6..85e98a28c 100644 --- a/src/components/Table/Table.tsx +++ b/src/components/Table/Table.tsx @@ -72,7 +72,7 @@ function InternalTable( ) { const { alternateRowColor = true, - bordered, + bordered = false, cancelSortText: defaultCancelSortText, cellBordered = false, children, @@ -762,6 +762,7 @@ function InternalTable( }, { [styles.tableEmpty]: rawData.length === 0 }, ])} + bordered={bordered} data={pageData} locale={locale!.lang} rowKey={getRowKey}