-
Notifications
You must be signed in to change notification settings - Fork 4k
Refactor Table to use flex layouts #2622
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
Conversation
|
packages/gitbook/src/components/DocumentView/Table/table.module.css
Outdated
Show resolved
Hide resolved
GitBook Preview |
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
packages/gitbook/src/components/DocumentView/Table/RecordColumnValue.tsx
Show resolved
Hide resolved
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.
Looks good, but I'm not a CSS expert
packages/gitbook/src/components/DocumentView/Table/RecordRow.tsx
Outdated
Show resolved
Hide resolved
b8fa4d4
to
2ff1075
Compare
This PR changes the way we render Tables. It now implements a strategy closer to the GitBook in-app editor, where we use flexbox for layout instead of semantic
<table>
<tr>
etc, and userole
on divs for these instead.The change was motivated by limitations of layout with html table elements. Our columns can be sized in 3 different ways:
1. Set to auto-size by default, these columns share the available width
2. Explicitly set by the user by dragging column separator (we then turn off auto-size)
3. Auto-size is turned off without setting a width, we then default to a fixed width of 100px
This lead to a bunch of layout headaches, like:
<table>
take upwidth: 100%
of the available space, columns would always increase in size when possible, even though if we/users explicitly set a customwidth
on a column through dragging the column separatorwidth: fit-content
, which also allows for tables in smaller width than the page (altho this is currently broken, but then any columns with no set width should enforce auto-sizing. but this is not possible without measuring the DOM (inefficient), as the parent is set to fit-content, not 100%Ultimately using flexbox gives us a lot more flexibility and potential for adding more features, and we're closer to the editor.
This PR also fixes a number of bugs: