-
Notifications
You must be signed in to change notification settings - Fork 535
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
Vertically align cell contents in DataTable
#3843
Conversation
🦋 Changeset detectedLatest commit: 1fae2c7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
Here's a screenshot from the storybook showing the new alignment: |
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.
Really like this change. The table cell items look a lot better. I ran the storybooks and compared them with the original and couldn't really find any regressions so far. I will approve but please don't merge till @joshblack or @mperrotti (original component authors) approve
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.
LGTM! Will wait to see what @mperrotti says before merging 👀
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'm open to merging this with the assumption that most table cells will not wrap to multiple lines.
@@ -66,7 +66,10 @@ const StyledTable = styled.table<React.ComponentPropsWithoutRef<'table'>>` | |||
.TableHeader, | |||
.TableCell { | |||
text-align: start; | |||
display: flex; | |||
align-items: center; |
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.
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.
Yeah that's a good point. I'm not sure if the best solution is something that involves proper padding if there's a row action available, or increasing the base height of a row when there is no action. I don't think anyone but us is using DataTable
at the moment, and our current plan is to truncate row content when it overflows a cell.
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.
Late on this but I think align-items: baseline
would solve for that specific issue, though not sure if it would introduce problems with other elements like IconButtons or Labels.
Changelog
This PR vertically aligns cell content for the
DataTable
component. When a row has actions, the typical pattern is to use anIconButton
. However, the button is taller than the row when the row contents are text. Currently, by default, cell contents are top-aligned, so this creates a disparity between the top and bottom margins for cell content. This is best demonstrated by this storybook:New
Added styles to
TableCell
andTableHeader
Changed
NA
Removed
NA
Rollout strategy
Testing & Reviewing
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.