From 08722dd718d44b83da378f2151997b27205db49e Mon Sep 17 00:00:00 2001 From: Steven Spriggs Date: Mon, 29 Jan 2024 09:07:22 -0500 Subject: [PATCH] fix(table): custom background hover colors (#1462) * fix(table): use fallbacks, rename and deprecate css varsadd to cem * docs(table): add deprecation note to cssprop description * chore(table): add changeset --- .changeset/sixty-lemons-smoke.md | 5 +++ elements/rh-table/rh-table-lightdom.css | 55 +++++++++++++++---------- elements/rh-table/rh-table.ts | 6 +++ 3 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 .changeset/sixty-lemons-smoke.md diff --git a/.changeset/sixty-lemons-smoke.md b/.changeset/sixty-lemons-smoke.md new file mode 100644 index 0000000000..8793a51259 --- /dev/null +++ b/.changeset/sixty-lemons-smoke.md @@ -0,0 +1,5 @@ +--- +"@rhds/elements": patch +--- + +``: corrected custom background hover color tokens. diff --git a/elements/rh-table/rh-table-lightdom.css b/elements/rh-table/rh-table-lightdom.css index b48afd8ad1..29dab7635e 100644 --- a/elements/rh-table/rh-table-lightdom.css +++ b/elements/rh-table/rh-table-lightdom.css @@ -1,23 +1,36 @@ rh-table { - --rh-table-row-border: - var(--rh-border-width-sm, 1px) - solid - var(--rh-color-border-subtle-on-light, #c7c7c7); - --rh-table-row-background-color: - rgb( + --_row-border: + var( + --rh-table-row-border, + var(--rh-border-width-sm, 1px) + solid + var(--rh-color-border-subtle-on-light, #c7c7c7) + ); + --_row-background-hover-color: + var( + --rh-table-row-background-hover-color, var( - --rh-color-gray-20-rgb, - 224 224 224 + /* rh-table-row-background-color is deprecated + please use --rh-table-row-background-hover-color*/ + --rh-table-row-background-color, + rgb( + var(--rh-color-gray-20-rgb, 224 224 224) + / var(--rh-opacity-40, 40%) + ) ) - / var(--rh-opacity-40, 40%) ); - --rh-table-column-background-color: - rgb( + --_column-background-hover-color: + var( + --rh-table-column-background-hover-color, var( - --rh-color-blue-50-rgb, - 0 102 204 + /* rh-table-column-background-color is deprecated + please use --rh-table-column-background-hover-color */ + --rh-table-column-background-color, + rgb( + var(--rh-color-blue-50-rgb, 0 102 204) + / var(--rh-opacity-10, 10%) + ) ) - / var(--rh-opacity-10, 10%) ); } @@ -38,11 +51,11 @@ rh-table thead th { } rh-table tr { - border-bottom: var(--rh-table-row-border); + border-bottom: var(--_row-border); } rh-table tr:hover { - background: var(--rh-table-row-background-color); + background: var(--_row-background-hover-color); } rh-table tr > * { @@ -84,7 +97,7 @@ rh-table td { } rh-table :is(col.active) { - background: var(--rh-table-column-background-color); + background: var(--_column-background-hover-color); } @media (max-width: 768px) { @@ -117,19 +130,19 @@ rh-table :is(col.active) { } rh-table thead ~ tbody tr:first-child { - border-top: var(--rh-table-row-border); + border-top: var(--_row-border); } rh-table thead ~ tbody tr:last-child { - border-bottom: var(--rh-table-row-border); + border-bottom: var(--_row-border); } rh-table thead ~ tbody tr:nth-child(even) { - background: var(--rh-table-row-background-color); + background: var(--_row-background-hover-color); } rh-table thead ~ tbody tr:hover { - background: var(--rh-table-column-background-color); + background: var(---_column-background-hover-color); } rh-table thead ~ tbody tr > * { diff --git a/elements/rh-table/rh-table.ts b/elements/rh-table/rh-table.ts index fefc18f04d..3610940369 100644 --- a/elements/rh-table/rh-table.ts +++ b/elements/rh-table/rh-table.ts @@ -18,6 +18,12 @@ import styles from './rh-table.css'; * * @slot - an HTML table * @slot summary - a brief description of the data + * + * @cssprop {} --rh-table-row-background-color - deprecated use --rh-table-row-background-hover-color {@default `224 224 224 / 40%`} + * @cssprop {} --rh-table-column-background-color - deprecated use --rh-table-column-background-hover-color {@default `0 102 204 / 10%`} + * @cssprop {} --rh-table-row-background-hover-color - row hover background color {@default `224 224 224 / 40%`} + * @cssprop {} --rh-table-column-background-hover-color - column hover background color {@default `0 102 204 / 10%`} + * @cssprop --rh-table-row-border - row border {@default `1px solid #c7c7c7`} */ @customElement('rh-table') export class RhTable extends LitElement {