-
Notifications
You must be signed in to change notification settings - Fork 36
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
DOP-5342: ListTable consolidates cell content inside of divs #1346
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,6 @@ const baseCellStyle = css` | |
* { | ||
// Wrap in selector to ensure it cascades down to every element | ||
font-size: ${theme.fontSize.small} !important; | ||
line-height: inherit; | ||
} | ||
|
||
// Ensure each cell is no higher than the highest content in row | ||
|
@@ -78,23 +77,25 @@ const bodyCellStyle = css` | |
flex-direction: column; | ||
align-items: flex-start; | ||
} | ||
`; | ||
|
||
const bodyCellContentStyle = css` | ||
*, | ||
p, | ||
a { | ||
line-height: 20px; | ||
} | ||
|
||
// Target any nested components (paragraphs, admonitions, tables) and any paragraphs within those nested components | ||
& > div > *, | ||
& > div > div p { | ||
margin: 0 0 12px; | ||
& > *, | ||
& > div p { | ||
margin: 0 0 12px !important; | ||
} | ||
|
||
// Prevent extra margin below last element (such as when multiple paragraphs are present) | ||
& > div > div *:last-child, | ||
& > div > *:last-child { | ||
margin-bottom: 0; | ||
& > div *:last-child, | ||
& > *:last-child { | ||
margin-bottom: 0 !important; | ||
} | ||
`; | ||
|
||
|
@@ -308,7 +309,8 @@ const ListTable = ({ nodeData: { children, options }, ...rest }) => { | |
{headerGroup.headers.map((header) => { | ||
return ( | ||
<HeaderCell className={cx(baseCellStyle, headerCellStyle)} key={header.id} header={header}> | ||
{flexRender(header.column.columnDef.header, header.getContext())} | ||
{/* Wraps cell content inside of a div so that all of its content are together when laid out. */} | ||
<div>{flexRender(header.column.columnDef.header, header.getContext())}</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My only request: Maybe we leave a comment here and below to explain why the div is there so no one removes it one day. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good callout. This sounds like a div I'd accidentally remove |
||
</HeaderCell> | ||
); | ||
})} | ||
|
@@ -323,7 +325,8 @@ const ListTable = ({ nodeData: { children, options }, ...rest }) => { | |
const role = isStub ? 'rowheader' : null; | ||
return ( | ||
<Cell key={cell.id} className={cx(baseCellStyle, bodyCellStyle, isStub && stubCellStyle)} role={role}> | ||
{cell.renderValue()} | ||
{/* Wraps cell content inside of a div so that all of its content are together when laid out. */} | ||
<div className={cx(bodyCellContentStyle)}>{cell.renderValue()}</div> | ||
</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.
@rayangler is there any way we can use another approach other than
!important
? if not, then it is what it is.!important
is normally considered to be bad practice, and can make maintaining difficult down the road.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, I'm not a fan of
!important
either. Honestly, I don't really understand it but when I was trying to work on it on local development, it was working fine without!important
, but when statically built, the order of CSS was different, causing the styling of these components to be different as well. I couldn't think of or find a more straightforward way to handle it.I can timebox 30-60 minutes at some point to look into this more to see if there are other options that don't require writing some roundabout CSS/JS logic. Would that work?
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.
@rayangler that would be perfect, but please don't spend anything more than what you mentioned above. I don't think it is worth eating up too much of your time.
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 spent some time looking into it but couldn't find a full fix for it that kept changes minimal. I've tried upgrading a couple of dependencies
@leafygreen-ui/emotion
andgatsby-plugin-emotion
, and modifying the selectors to be a little bit more specific (this worked for some elements but not for others, and it might require an exhaustive list of HTML since tables can have any elements in them).Some things I didn't try that might be interesting in the future would be:
table-cell-content
classname down to all cell child components and then use those classnames as the selectors? (Unsure how well this would work with deeply nested components; we might have to make sure every component is passing that exact classname every time)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.
@rayangler thank you for looking into this a bit more. Those are some interesting approaches, and like you said, something we can look into in the possible future.