Skip to content
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

Merged
merged 5 commits into from
Feb 13, 2025

Conversation

rayangler
Copy link
Collaborator

@rayangler rayangler commented Feb 10, 2025

Stories/Links:

DOP-5342
Related Osiris PR

Current Behavior:

Test tables staging (main branch)

Staging Links:

Test tables staging page - should ideally look the same as the one on the main branch.

Notes:

  • Wraps cell content inside of a div so that all of its content are together when laid out. This allows us greater flexibility with layout styling of cell contents without needing to worry about exact structure.
  • The main reason for this change was to help prevent awkward styling with elements passed in from Osiris. Seems like if there were header cells with styling in them, the layout might be awkward (can see a slight difference in spacing in the above staging link), so this PR helps avoid that going forward.

README updates

    • This PR introduces changes that should be reflected in the README, and I have made those updates.
    • This PR does not introduce changes that should be reflected in the README

Copy link

netlify bot commented Feb 10, 2025

Deploy Preview for docs-frontend-dotcomstg ready!

Name Link
🔨 Latest commit d4b8b2c
🔍 Latest deploy log https://app.netlify.com/sites/docs-frontend-dotcomstg/deploys/67ae0c6a5cbaec000873658e
😎 Deploy Preview https://deploy-preview-1346--docs-frontend-dotcomstg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 10, 2025

Deploy Preview for docs-frontend-stg ready!

Name Link
🔨 Latest commit d4b8b2c
🔍 Latest deploy log https://app.netlify.com/sites/docs-frontend-stg/deploys/67ae0c6a0425f30007cb0cec
😎 Deploy Preview https://deploy-preview-1346--docs-frontend-stg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rayangler rayangler marked this pull request as ready for review February 11, 2025 19:17
Copy link
Collaborator

@caesarbell caesarbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, LGTM. The layout looks real nice.

I left a small suggestion/comment, but not a blocker.

margin: 0 0 12px;
& > *,
& > div p {
margin: 0 0 12px !important;
Copy link
Collaborator

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.

Copy link
Collaborator Author

@rayangler rayangler Feb 12, 2025

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?

Copy link
Collaborator

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.

Copy link
Collaborator Author

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 and gatsby-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:

  • Pass some 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)
  • We have a context that can keep track if a component is inside of a table or not. Maybe we can leverage that and write some conditional css at the component level to handle the styling accordingly (this may be annoying to have to add to every possible nested component though...)

@@ -308,7 +309,7 @@ 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())}
<div>{flexRender(header.column.columnDef.header, header.getContext())}</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout. This sounds like a div I'd accidentally remove

@rayangler rayangler merged commit 0a6e6e0 into main Feb 13, 2025
10 checks passed
@rayangler rayangler deleted the DOP-5342-lone-table branch February 13, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants