Skip to content

Commit 437a3bb

Browse files
authored
[IndexTable] Add hasZebraStriping optional prop (#8595)
<!-- ☝️How to write a good PR title: - Prefix it with [ComponentName] (if applicable), for example: [Button] - Start with a verb, for example: Add, Delete, Improve, Fix… - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ### WHY are these changes introduced? Closes #8592 The Pixels Index Redesign for Customer Events uses IndexTable and zebra striping is desired. <!-- Context about the problem that’s being addressed. --> I used the same color variable as the zebra striping in [DataTable](https://github.com/Shopify/polaris/pull/5365/files#diff-afd7e6258c31974d33a41a0be5cae45bd14466b2e68b17725e11d884ba2647ec). ### WHAT is this pull request doing? Adds `hasZebraStriping` optional prop on IndexTable. <img width="950" alt="screenshot of ZebraStriping in storybook" src="https://user-images.githubusercontent.com/12080891/223773325-30d763c7-4f87-4727-b007-07e3586a3eb8.png"> <!-- Summary of the changes committed. Before / after screenshots are appreciated for UI changes. Make sure to include alt text that describes the screenshot. If you include an animated gif showing your change, wrapping it in a details tag is recommended. Gifs usually autoplay, which can cause accessibility issues for people reviewing your PR: <details> <summary>Summary of your gif(s)</summary> <img src="..." alt="Description of what the gif shows"> </details> --> ### 🎩 checklist - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [ ] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [x] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
1 parent 230786a commit 437a3bb

File tree

4 files changed

+416
-1
lines changed

4 files changed

+416
-1
lines changed

.changeset/chatty-pets-enjoy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Added option zebra striping to `IndexTable` ([#8595](https://github.com/Shopify/polaris/pull/8595))

polaris-react/src/components/IndexTable/IndexTable.scss

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,30 @@ $loading-panel-height: 53px;
197197
color: var(--p-text-subdued);
198198
}
199199

200+
// Extra specificity is needed to address edge cases where the zebra striping is combined with other options
201+
// stylelint-disable selector-max-specificity, selector-max-class, selector-max-combinators -- extra specificity needed for when combining props
202+
.ZebraStriping {
203+
.TableRow:nth-child(2n + 1) {
204+
background: none;
205+
}
206+
207+
.TableRow:nth-child(2n),
208+
.TableRow:nth-child(2n) .TableCell:last-child {
209+
background: var(--p-surface-subdued);
210+
211+
&:hover {
212+
background-color: var(--p-surface-hovered);
213+
}
214+
}
215+
216+
.TableRow-hovered:nth-child(2n + 1),
217+
.TableRow-hovered:nth-child(2n),
218+
.TableRow-hovered:nth-child(2n) .TableCell:last-child {
219+
background-color: var(--p-surface-hovered);
220+
}
221+
}
222+
// stylelint-enable selector-max-specificity, selector-max-class, selector-max-combinators
223+
200224
.TableHeading {
201225
background: var(--p-surface-subdued);
202226
z-index: var(--p-z-index-1);

0 commit comments

Comments
 (0)