-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[VF][Polaris] IndexTable row borders is configurable #11676
Conversation
/snapit |
/snapit |
🫰✨ Thanks @oksanashopify! Your snapshot has been published to npm. Test the snapshot by updating your yarn add @shopify/polaris@0.0.0-snapshot-20240229213741 |
/snapit |
🫰✨ Thanks @oksanashopify! Your snapshot has been published to npm. Test the snapshot by updating your yarn add @shopify/polaris@0.0.0-snapshot-20240306165043 |
/snapit |
🫰✨ Thanks @oksanashopify! Your snapshot has been published to npm. Test the snapshot by updating your yarn add @shopify/polaris@0.0.0-snapshot-20240307171744 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments on:
@@ -159,6 +159,10 @@ $loading-panel-height: 53px; | |||
cursor: auto; | |||
} | |||
|
|||
&.TableRow-borderless:not(:first-child) { | |||
border-top: 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the border will affect the row height making it inconsistent across rows with different divider
values. Maybe instead of removing the border it's worth making it transparent instead which would keep the same element dimensions and remove the visual border?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing that out! Yes, I think border-top: transparent;
should work better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Trying to hide borders via applying transparent border brings implications with sticky cells, comment here.
With setting transparent color for borders we have to:
- add styles to make borders the same colour as background for all sticky cells that do not have white background (rows with status, subheaders). Without colored borders sticky cell has white spaces around it. I was trying to figure out how to eliminate this, but even chatGPT says
it is likely due to the way the position: sticky property works in conjunction with table elements.
,border-collapse: collapse;
, - didn't help as well. - when it's feasible to add all those additional styles for sticky cells, I think it will bring implications to support those style, as developers have to take into account adding new types of rows
- Trying to hide borders via applying border the same background color brings implications with sticky cells for row with status, subheaders, as they all needs owerrides for sticky cells borders. Moreover colored border will overlap with vertical border when first cells become sticky, video:
Screen.Recording.2024-03-15.at.8.24.24.PM.mov
Additionally, in all these cases we have to handle selected cells borders (and maybe something else will come up)
- I also checked how it works in Bootstrap toolkit, for example, and they also set
border: 0
to hide borders: https://getbootstrap.com/docs/4.1/content/tables/#borderless-table.
So seems like setting border: 0 is the solution that is easy to maintain and support.
@tatianau do you think border: 0
is still no way to go for us? Let's see what Polaris team thinks as well?
You can also see on my spin how it works for Variants card on PDP, here
Draft web PR that implements latest snapshot on web: https://github.com/Shopify/web/pull/120568
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also was trying to fix the initial state for sticky cells, and it seems we can do it on the table level by applying
border-collapse: separate;
border-spacing: 0;
instead of
border-collapse: collapse;
But that's affects all tables spacings and borders, here is a sandbox , where we can see that table with border-collapse: separate;
takes less space and borders look different. We see that difference because border-collapse: separate; border-spacing: 0;
treats each cell's border individually with no spacing between them, while border-collapse: collapse;
collapses the borders of adjacent cells into a single border with no spacing between them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, there's a pretty noticeable layout shift that happens when you toggle between pages that have a border and are borderless with the border: 0
solution.
I think it makes sense to modify the styles to keep the same border width with the transparent color:
&.TableRow-borderless {
border-top: var(--p-border-width-025) solid transparent;
border-bottom: var(--p-border-width-025) solid transparent;
}
And then in the TableRow-subheader
class, override the border-color for TableRow-borderless
and set it to match border-color: var(--p-color-bg-surface-secondary)
to fix the issue of the white space in the subheader example in your story. This solution should still work to resolve the issue of double borders in your other screenshots.
@@ -4663,43 +4884,255 @@ export function WithSubHeaders() { | |||
); | |||
} | |||
|
|||
export function WithPagination() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff looks weird as I didn't touch WithPagination story
@@ -260,9 +264,11 @@ $loading-panel-height: 53px; | |||
font-weight: var(--p-font-weight-medium); | |||
font-size: var(--p-font-size-300); | |||
background-color: var(--p-color-bg-surface-secondary); | |||
border-top: var(--p-border-width-025) solid var(--p-color-border); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes double borders for rowType="subheader"
(Before and After screenshots are posted in PR description).
@laurkim could you please check if removing these borders doesn't break anything. From what I can see they were added with this PR https://github.com/Shopify/polaris/pull/10683/files and than were updated with the following one: #10741
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/snapit |
🫰✨ Thanks @oksanashopify! Your snapshot has been published to npm. Test the snapshot by updating your yarn add @shopify/polaris@0.0.0-snapshot-20240312005434 |
/snapit |
converting back to draft to resolve conflicts |
93b1513
to
2a0ba1d
Compare
added story with nested rows added website example, added new story renamed divider to the borderless, updated stories, code example updated patch description updated website example refactored styles to use transparent token applied same bg color for border color instead of making it transparent moved back to border 0
2a0ba1d
to
e1db338
Compare
/snapit |
🫰✨ Thanks @oksanashopify! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-migrator@0.0.0-snapshot-20240315220634 yarn add @shopify/polaris@0.0.0-snapshot-20240315220634 yarn add @shopify/stylelint-polaris@0.0.0-snapshot-20240315220634 |
/snapit |
🫰✨ Thanks @oksanashopify! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-migrator@0.0.0-snapshot-20240316022351 yarn add @shopify/polaris@0.0.0-snapshot-20240316022351 yarn add @shopify/stylelint-polaris@0.0.0-snapshot-20240316022351 |
@@ -256,9 +260,19 @@ | |||
font-weight: var(--p-font-weight-medium); | |||
font-size: var(--p-font-size-300); | |||
background-color: var(--p-color-bg-surface-secondary); | |||
border-top: var(--p-border-width-025) solid var(--p-color-border); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/snapit |
🫰✨ Thanks @oksanashopify! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-migrator@0.0.0-snapshot-20240318160236 yarn add @shopify/polaris@0.0.0-snapshot-20240318160236 yarn add @shopify/stylelint-polaris@0.0.0-snapshot-20240318160236 |
@@ -39,6 +39,8 @@ export interface RowProps { | |||
* @default "Select {resourceName}" | |||
*/ | |||
accessibilityLabel?: string; | |||
/** Whether the row should have border-top */ | |||
borderless?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
borderless?: boolean; | |
border?: 'none'; |
Can we simplify the prop name to border
with the default being true
? When no border is desired, the usage would be border={false}
. Using border
is more aligned with the CSS semantic.
Sorry, I know that will also affect the class names and stories 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking more about it, using a string would be more flexible for future needs. Could we use border="none"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback, @sam-b-rose !
In case with borderless
we add TableRow-borderless
class and remove borders with css.
If you suggest border?: boolean;
or border="none"
, how this should be styled? Should we by default add TableRow-border
class?
With border="none"
what other values it should have, border="yes"
?
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @oksanashopify! Sam is suggesting string typing so that if there is a need in the future for other variants of border styling, they can simply be unioned with "none" as needed (like "none" | "some other option"
). For the classname, you can update to follow style variant naming convention TableRow-borderNone
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sam-b-rose @oksanashopify what do you think of aligning the prop with Box
?
/** The border-top color of the row
* @default 'secondary'
*/
borderColor?: 'secondary' | 'transparent';
(IndexTable.css @ line 158)
.TableRow {
background-color: var(--p-color-bg-surface);
cursor: pointer;
border-width: var(--p-border-width-025);
border-style: solid;
&.TableRow-unclickable {
cursor: auto;
}
&:first-child {
border-color: var(--p-color-border);
}
&.borderColorSecondary {
border-color: var(--p-color-border-secondary);
}
&.borderColorTransparent {
border-color: transparent;
}
@@ -55,6 +57,7 @@ export const Row = memo(function Row({ | |||
selectionRange, | |||
rowType = 'data', | |||
accessibilityLabel, | |||
borderless = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
borderless = false, | |
borderColor = 'secondary', |
@@ -122,6 +125,7 @@ export const Row = memo(function Row({ | |||
!selectable && | |||
!primaryLinkElement.current && | |||
styles['TableRow-unclickable'], | |||
borderless && styles['TableRow-borderless'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
borderless && styles['TableRow-borderless'], | |
borderColor && styles[variationName('borderColor', borderColor)], |
41ab59b
to
804ca2c
Compare
Localization quality issues found The following issues may affect the quality of localized translations if they are not addressed:
Please look out for other instances of this issue in your PR and fix them as well if possible. Questions about these messages? Hop in the #help-localization Slack channel. |
As we not getting any requests to make these rows configurable anymore, we are closing this PR for now |
Resolves first acceptance criteria from https://github.com/Shopify/web/issues/110163 and adds conditional borders
WHY are these changes introduced?
While woking on Variants card, we decided to provide better visualization for nested rows and remove borders the achieve the following design:
WHAT is this pull request doing?
borderless
property to theRow
component to specify whether the row should haveborder-top
, especially useful for nested rows(have some issues with first two columns sticky, we have white spaces for first two cells in each row)
.Polaris-IndexTable__TableRow.Polaris-IndexTable__TableRow--subheader .Polaris-IndexTable__TableCell:first-child
andIndexTable__TableRow.Polaris-IndexTable__TableRow--subheader .Polaris-IndexTable__TableCell:last-child
. CommitBefore:
How to 🎩
Pull this branch, run
yarn && yarn build
andyarn turbo run dev --filter=polaris.shopify.com
to tophat changes on polaris.shopify.comYou can also see on my spin how it works for Variants card on PDP, here
Draft web PR that implements latest snapshot on web: PR
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
🎩 checklist
README.md
with documentation changes