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

fix(/lib/components/table): prevent scrollbars around <Table>s #608

Merged
merged 8 commits into from
Apr 17, 2023

Conversation

multiwebinc
Copy link
Contributor

Description

This moves the background color and border radius to the cells and places a div under the table for the box shadow effect. That way if a table is modified (rows or columns added or removed) or if the screen resolution changes, it won't create scrollbars around the table.

Fixes #605

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Just tested by trying it out

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@tulup-conner
Copy link
Collaborator

I love this idea, but we don't want to ship custom CSS. Can you find a way to accomplish this in Tailwind CSS via the theme instead of creating a stylesheet file?

@tulup-conner tulup-conner added the 🚀 enhancement New feature or request label Feb 21, 2023
@tulup-conner tulup-conner added this to the 0.4.0 milestone Feb 21, 2023
@tulup-conner tulup-conner marked this pull request as draft February 21, 2023 03:04
@tulup-conner tulup-conner changed the title Prevent scrollbars around dynamic tables fix(/lib/components/table): prevent scrollbars around <Table>s Feb 21, 2023
@multiwebinc
Copy link
Contributor Author

@tulup-conner What about like this?

@tulup-conner
Copy link
Collaborator

We will want a solution using Tailwind CSS purely, which has support for custom selectors like these. Inline CSS has other negative implications for users, e.g., it will break Content Security Policies.

src/lib/components/Table/Table.tsx Outdated Show resolved Hide resolved
@multiwebinc
Copy link
Contributor Author

multiwebinc commented Feb 22, 2023

Edit: I think I might have found it. https://tailwindcss.com/docs/hover-focus-and-other-states#differentiating-nested-groups. Let me test it out first.

@rluders @tulup-conner I was looking into the group-{modifier} class, however I need 2 levels of groups, because it needs to select the first/last child of <table> combined with the first/last <td> or <th>. Would you be opposed to using https://www.npmjs.com/package/tailwindcss-scoped-groups?

If not, the only thing I can do with tailwind is style the top borders in <thead> (if there is one) and bottom borders of <tfoot> (if there is one). Without knowing whether <tbody> is the first or last child, you can't add a border radius to any of the cells in it. Unless maybe I add two more props to the <Table> component - headless and footless and if either of these are true, it will add the border radius to the corresponding tbody cells.

@multiwebinc
Copy link
Contributor Author

@rluders @tulup-conner Ok, I think that's it. No stylesheets. I didn't know about nested groups, so I didn't think it was possible without stylesheets.

@rluders
Copy link
Collaborator

rluders commented Feb 22, 2023

@multiwebinc could you sync your branch with the main branch? It has some conflicts because the theme structure was changed. So, you may have to adjust a few things on your PR.

@multiwebinc
Copy link
Contributor Author

@rluders What do you think, would it make sense to move the table.cell interface to table.body.cell to avoid confusion with table.head.cell?

@multiwebinc multiwebinc reopened this Feb 22, 2023
@rluders
Copy link
Collaborator

rluders commented Feb 23, 2023

@rluders What do you think, would it make sense to move the table.cell interface to table.body.cell to avoid confusion with table.head.cell?

I think that it makes sense. WDYT, @tulup-conner ?

@tulup-conner tulup-conner marked this pull request as ready for review March 1, 2023 05:47
@tulup-conner tulup-conner modified the milestones: 0.4.0, 1.0.0 Mar 1, 2023
@codecov
Copy link

codecov bot commented Apr 13, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (a4f39f5) 99.42% compared to head (c82b488) 99.42%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #608   +/-   ##
=======================================
  Coverage   99.42%   99.42%           
=======================================
  Files         130      130           
  Lines        6450     6476   +26     
  Branches      485      485           
=======================================
+ Hits         6413     6439   +26     
  Misses         37       37           
Impacted Files Coverage Δ
src/lib/components/Table/Table.tsx 100.00% <100.00%> (ø)
src/lib/components/Table/TableBody.tsx 100.00% <100.00%> (ø)
src/lib/components/Table/TableCell.tsx 100.00% <100.00%> (ø)
src/lib/components/Table/TableRow.tsx 100.00% <100.00%> (ø)
src/lib/theme/default.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@rluders
Copy link
Collaborator

rluders commented Apr 17, 2023

Well, I can't see any reason to keep this one pending. I'm accepting it, @multiwebinc. Thank you!

@rluders rluders merged commit 6f1869b into themesberg:main Apr 17, 2023
rluders pushed a commit to multiwebinc/flowbite-react that referenced this pull request Apr 17, 2023
…mesberg#608)

* Update default.ts

* Update Table.tsx

* Update TableBody.tsx

* Update TableCell.tsx

* Update TableRow.tsx

* Update defaults.ts

* Fix prettier errors
@multiwebinc multiwebinc deleted the patch-5 branch April 17, 2023 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scrollbars appear around tables when resizing the window or when table content is modified
3 participants