-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: Support CSS gap in Box, use it for spacing in Stack, Inline, Columns #739
Conversation
Update: this seems to be solved now. See below. I hit an issue trying to use The problemThe issue is accurately and succinctly explained in this StackOverflow question.
It includes code to reproduce, and I can show here how this manifested in our own columns components: Loot at the top right area how all the rows that had no column sized as auto suffer from this issue. When all columns in a row have a fraction-based width, it accumulates as many gaps as it has between columns, and that amount of space overflows to the right. Potential fixAfter some investigation, and thanks to insights from an answer in that very StackOverflow page, it turns out that we can "solve" this by switching to use You can see how having different numbers of gaps in a row can affect how the widths are calculated. If a row has two columns (and therefore 1 gap) the percentages for the width are computed as
So clearly, the width of a 1/4 column is going to change depending on Why our current non-gap approach works?Compare the above situation with how it works today: It works with the code today because it gives us more control over the gap. The way it works today is, each column owns the spacing (it's implemented as padding on the column container element). So when the browser rendering engine computes the size of a column based on its percentage, the spacing is already in it. There's no way for the number of columns to affect the spacing size. What should we do?I see 3 options1:
Footnotes
|
Let's drop everything we're not using 👍 |
@henningmu does this mean you're voting for option 2? Just to be clear, when I said "we barely use fraction-sized columns", it means that we do use that feature a bit. We'd have to figure out the handful of cases in which we use it (2 or 3 in Todoist, if I recall correctly). One alternative I can see us adopting is to drop all fractions except "1/2". Having the ability to create a half-and-half layout is something I would not like to lose, and this layout cannot possibly suffer from the described short-coming. I could see me voting for option 2 in that case. |
Update: I may be on to something with this answer. Still not a 100% there, but looking good. |
cdb9ec9
to
3c051f8
Compare
3c051f8
to
7df6c5a
Compare
7df6c5a
to
ae5f11b
Compare
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 to me 🚀 Great job 👍
I guess the real test for this will be to update both todoist-web
and twist-web
with this version, and smoke test it. I can't remember any particular use case from the top of my head, but I remember that sometimes I had to add extra margins/paddings for things to be properly aligned.
// // for width="content" no css class is added | ||
// for (const width of columnWidths) { | ||
// expect(column).not.toHaveClass(`columnWidth-${width.replace('/', '-')}`) | ||
// } |
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.
💭 Is this comment meant to be kept around?
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.
Nope. Good catch.
@rfgamaral did you go through the test plan above? It includes a step about running Todoist locally with this version of the library linked locally as well. I did it myself, but I would not want to merge this until someone else do that too. |
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.
@gnapse No, I didn't. I always had trouble linking Reactist to Todoist, not exactly sure why, so I focused on the code only. Let's wait for @scottlovegrove review, otherwise I'll take a second look at a later time, if that's okay with you.
8399f83
to
082df29
Compare
Short description
Introduce support for the CSS
gap
property.References
gap
as a property of the Box component #691gap
on MDNTest plan
Due to this being so far-reaching, let's do a bit more manual QA review here than usual. I personally worked over the entire test plan myself already1, but a second pair of eyes would not hurt.
Test the library on its own
Run storybook locally
npm run storybook
while on this branch, and check the following:Inline
Stack
(similar steps toInline
, but with some more)Columns
Test the library along the app
Run Todoist locally but linked to Reactist locally rather than using the published Reactist package.
gap:
CSS applied via Reactist component styling.PR Checklist
npm run validate
and made sure no errors / warnings were shownCHANGELOG.md
package.json
andpackage-lock.json
(npm --no-git-tag-version version <major|minor|patch>
) refnpm run build-all
)Versioning
It looks like this should be a patch release.Not at all. This introduces a new prop in theBox
component, so this absolutely needs to be part of a new minor release.Footnotes
In fact, that's how I found out about the issue with the columns described below. ↩