diff --git a/.changeset/silly-lies-march.md b/.changeset/silly-lies-march.md new file mode 100644 index 00000000000..70cfa2f1aba --- /dev/null +++ b/.changeset/silly-lies-march.md @@ -0,0 +1,5 @@ +--- +'@shopify/polaris': minor +--- + +Fixed hover state of `IndexTable.Row` when `selectable` is `false` diff --git a/polaris-react/src/components/IndexTable/IndexTable.scss b/polaris-react/src/components/IndexTable/IndexTable.scss index 5f9b7da9a2a..9b40be05b39 100644 --- a/polaris-react/src/components/IndexTable/IndexTable.scss +++ b/polaris-react/src/components/IndexTable/IndexTable.scss @@ -803,10 +803,74 @@ $loading-panel-height: 53px; } .TableRow-hovered:not(.TableRow-disabled) { - // stylelint-disable-next-line selector-max-combinators, selector-max-class, selector-max-specificity -- generated by polaris-migrator DO NOT COPY - .TableCell:first-child { + // stylelint-disable-next-line selector-max-combinators, selector-max-class, selector-max-specificity, selector-max-compound-selectors -- generated by polaris-migrator DO NOT COPY + &, + .TableCell:first-child, + .TableCell-first, + .TableCell-first + .TableCell, + .TableCell:last-child { background-color: var(--p-color-bg-surface-hover); } + + // stylelint-disable-next-line selector-max-class, selector-max-specificity -- fixed hover state for nonselected indexTable + &.toneSuccess { + // stylelint-disable-next-line selector-max-combinators, selector-max-class, selector-max-specificity, selector-max-compound-selectors -- fixed hover state for nonselected indexTable + &, + .TableCell:first-child, + .TableCell-first, + .TableCell-first + .TableCell, + .TableCell:last-child { + background-color: var(--p-color-bg-surface-success-hover); + } + } + + // stylelint-disable-next-line selector-max-class, selector-max-specificity -- fixed hover state for nonselected indexTable + &.toneWarning { + // stylelint-disable-next-line selector-max-combinators, selector-max-class, selector-max-specificity, selector-max-compound-selectors -- fixed hover state for nonselected indexTable + &, + .TableCell:first-child, + .TableCell-first, + .TableCell-first + .TableCell, + .TableCell:last-child { + background-color: var(--p-color-bg-surface-warning-hover); + } + } + + // stylelint-disable-next-line selector-max-class, selector-max-specificity -- fixed hover state for nonselected indexTable + &.toneCritical { + // stylelint-disable-next-line selector-max-combinators, selector-max-class, selector-max-specificity, selector-max-compound-selectors -- fixed hover state for nonselected indexTable + &, + .TableCell:first-child, + .TableCell-first, + .TableCell-first + .TableCell, + .TableCell:last-child { + background-color: var(--p-color-bg-surface-critical-hover); + } + } + + // stylelint-disable-next-line selector-max-class, selector-max-specificity -- fixed hover state for nonselected indexTable + &.toneSubdued { + // stylelint-disable-next-line selector-max-combinators, selector-max-class, selector-max-specificity, selector-max-compound-selectors -- fixed hover state for nonselected indexTable + &, + .TableCell:first-child, + .TableCell-first, + .TableCell-first + .TableCell, + .TableCell:last-child { + background-color: var(--p-color-bg-surface-secondary-hover); + } + } + + // stylelint-disable-next-line selector-max-class, selector-max-specificity -- fixed hover state for nonselected indexTable + &.TableRow-subheader { + // stylelint-disable-next-line selector-max-class, selector-max-combinators, selector-max-specificity, selector-max-compound-selectors -- fixed hover state for nonselected indexTable + &, + .TableCell:first-child, + .TableCell-first, + .TableCell-first + .TableCell, + .TableCell:last-child { + background-color: var(--p-color-bg-surface-secondary); + } + } } .toneSuccess { diff --git a/polaris-react/src/components/IndexTable/IndexTable.stories.tsx b/polaris-react/src/components/IndexTable/IndexTable.stories.tsx index f3648791ffa..63c99129840 100644 --- a/polaris-react/src/components/IndexTable/IndexTable.stories.tsx +++ b/polaris-react/src/components/IndexTable/IndexTable.stories.tsx @@ -2171,6 +2171,114 @@ export function WithoutCheckboxes() { ); } +export function WithTonesWithoutCheckboxes() { + const customers = [ + { + id: '3410', + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + orders: 20, + amountSpent: '$2,400', + }, + { + id: '3411', + url: '#', + name: 'Joe Jemison', + location: 'Sydney, AU', + orders: 20, + amountSpent: '$1,400', + status: 'success', + }, + { + id: '3412', + url: '#', + name: 'Sam Jemison', + location: 'Decatur, USA', + orders: 20, + amountSpent: '$400', + status: 'critical', + }, + { + id: '3413', + url: '#', + name: 'Mae Jemison', + location: 'Decatur, USA', + orders: 20, + amountSpent: '$4,300', + status: 'warning', + }, + { + id: '2563', + url: '#', + name: 'Ellen Ochoa', + location: 'Los Angeles, USA', + orders: 30, + amountSpent: '$140', + status: 'subdued', + }, + ]; + const resourceName = { + singular: 'customer', + plural: 'customers', + }; + + const rowMarkup = customers.map( + ({id, name, location, orders, amountSpent, status}, index) => ( + + + + {name} + + + {location} + + + {orders} + + + + + {amountSpent} + + + + ), + ); + + return ( + + + {rowMarkup} + + + ); +} + export function WithAllOfItsElements() { const customers = [ {