Skip to content

Commit

Permalink
feat: table: adds column border and disable row bg hover color props (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dkilgore-eightfold committed Jun 1, 2023
1 parent 3576613 commit 78a333d
Show file tree
Hide file tree
Showing 46 changed files with 238 additions and 94 deletions.
4 changes: 4 additions & 0 deletions src/components/Table/Internal/OcTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function OcTable<RecordType extends DefaultRecordType>(
onRow,
onHeaderRow,
transformColumns,
rowHoverBackgroundEnabled = true,
sticky,
headerClassName,
onRowHoverEnter,
Expand Down Expand Up @@ -713,6 +714,9 @@ function OcTable<RecordType extends DefaultRecordType>(
className={mergeClasses([
styles.table,
{ [styles.tableBordered]: bordered },
{
[styles.tableRowHover]: rowHoverBackgroundEnabled,
},
{ [styles.tableRtl]: direction === 'rtl' },
{ [styles.tablePingLeft]: pingedLeft },
{ [styles.tablePingRight]: pingedRight },
Expand Down
5 changes: 5 additions & 0 deletions src/components/Table/Internal/OcTable.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,11 @@ export interface OcTableProps<RecordType = unknown> {
* The custom class name of Table row.
*/
rowClassName?: string | RowClassName<RecordType>;
/**
* Enables row background hover color.
* @default true
*/
rowHoverBackgroundEnabled?: boolean;
/**
* Table Row's unique key.
* May be a string or function that returns a string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Expand childrenColumnName 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Expand work in expandable fix 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-fixed-column table-scroll-horizontal table-has-fix-left",
"class": "table table-row-hover table-fixed-column table-scroll-horizontal table-has-fix-left",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Expand work in expandable fix 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-fixed-column table-scroll-horizontal table-has-fix-left",
"class": "table table-row-hover table-fixed-column table-scroll-horizontal table-has-fix-left",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Expand not use nest when children is invalid 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Expand renders fixed column correctly work 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
"class": "table table-row-hover table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Expand renders tree row correctly 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Expand renders tree row correctly with different children 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Expand does not crash if scroll is not set 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-fixed-column table-scroll-horizontal table-has-fix-left",
"class": "table table-row-hover table-fixed-column table-scroll-horizontal table-has-fix-left",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Expand does not crash if scroll is not set 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-fixed-column table-scroll-horizontal table-has-fix-left",
"class": "table table-row-hover table-fixed-column table-scroll-horizontal table-has-fix-left",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.FixedColumn renders correctly scrollX - withdata 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
"class": "table table-row-hover table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
},
"children": Array [
Node {
Expand Down Expand Up @@ -5519,7 +5519,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - withdata 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-fixed-header table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
"class": "table table-row-hover table-fixed-header table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.FixedColumn renders correctly scrollX - withoutdata 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
"class": "table table-row-hover table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
},
"children": Array [
Node {
Expand Down Expand Up @@ -4475,7 +4475,7 @@ exports[`Table.FixedColumn renders correctly scrollXY - withoutdata 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-fixed-header table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
"class": "table table-row-hover table-fixed-header table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.FixedColumn fixed column renders correctly RTL 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-rtl table-fixed-column table-scroll-horizontal table-has-fix-left",
"class": "table table-row-hover table-rtl table-fixed-column table-scroll-horizontal table-has-fix-left",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic renders correctly column children undefined 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic custom components renders correctly 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic renders correctly falsy columns 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic renders correctly no columns 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic renders correctly basic 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table test-class-name",
"class": "table table-row-hover test-class-name",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic renders colSpan correctly 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic custom components renders fixed column and header correctly
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-fixed-header table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
"class": "table table-row-hover table-fixed-header table-fixed-column table-scroll-horizontal table-has-fix-left table-has-fix-right",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic renders rowSpan correctly 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic renders correctly RTL 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-rtl test-class-name",
"class": "table table-row-hover table-rtl test-class-name",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic custom components scroll content with scroll 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table table-fixed-header table-scroll-horizontal",
"class": "table table-row-hover table-fixed-header table-scroll-horizontal",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic syntactic sugar 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Table.Basic internal api transformColumns basic 1`] = `
LoadedCheerio {
"0": Node {
"attribs": Object {
"class": "table",
"class": "table table-row-hover",
},
"children": Array [
Node {
Expand Down
48 changes: 26 additions & 22 deletions src/components/Table/Internal/octable.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -193,34 +193,38 @@
&:last-of-type {
border-right: none;
}
}

&-row-hover {
background-color: $table-row-hover-background-color;
&-row-hover {
.table-cell {
&-row-hover {
background-color: $table-row-hover-background-color;

&:first-of-type {
&:before {
border-left: 2px solid $table-border-active-color;
&:first-of-type {
&:before {
border-left: 2px solid $table-border-active-color;
}
}
}

&:last-of-type {
&:before {
border-right: 2px solid $table-border-active-color;
width: 100%;
&:last-of-type {
&:before {
border-right: 2px solid $table-border-active-color;
width: 100%;
}
}
}

&:before {
border-bottom: 2px solid $table-border-active-color;
border-top: 2px solid $table-border-active-color;
content: '';
height: 100%;
left: 0;
pointer-events: none;
position: absolute;
top: 0;
width: calc(100% + 2px);
z-index: 2;
&:before {
border-bottom: 2px solid $table-border-active-color;
border-top: 2px solid $table-border-active-color;
content: '';
height: 100%;
left: 0;
pointer-events: none;
position: absolute;
top: 0;
width: calc(100% + 2px);
z-index: 2;
}
}
}
}
Expand Down
Loading

0 comments on commit 78a333d

Please sign in to comment.