-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Make it possible to set the width of blocks within Row #44467
Comments
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Looks good! (Nit: hould use the 40px heights, padding and border color in input looks wrong, as does the padding on the segmented control.)
We respect what would happen if you wrote this CSS. It breaks out of the boundaries. CSS is awesome.
It does, yes, but it's a way shorter word than "constrain width to content", and even "content width", and the help text helps.
Seems worth moving this into a codepen, and writing the accompanying CSS to try this out in practice, seeing what happens to short and long paragraphs, with fill and hug and fixed, etc. Keep in mind, both the container and the child can have hug/fill/fixed options. I imagine a fixed width container, with overflow hidden (still missing that in the Advanced section) and a long paragraph set to hug inside, would be cropped off. This can make sense for future eliding options.
Not for this ticket, but yes I think there's a separate ticket for it, would be nice to have that in advanced. |
We really need to update our Figma components :D Here's a quick codepen I made to explore the options. Observations: I was surprised to see that children with Fill width don't occupy equal horizontal space by default. A % The only way I could get Hug to work was to set a fixed width based on the total width of the children. This makes me wonder if this option should be reserved only for containers. Which leads to a follow-up question... if you add the width tool to a paragraph, what is the default setting, Fill? We need to account for conceptually incompatible configurations. See demos "Row with Hug width and Fill width children" and "Row with Hug width and Fixed and Fill width children" for examples. Neither are behaving as expected. As I'm sure you know, Figma doesn't allow these configurations – if you attempt to create one then it automatically updates the width on the parent or child respectively to create a compatible config (and displays a Snackbar to inform you of what's going on). We'll probably need to do something similar. |
It could also be very cool for both the Gallery block (to have control over column span of individual images, and replace the ad hoc width implementation), and also fine-grained control over columns in the Post Template block, too (related issue to refactor Post Template block to use the flex layout type properly: #44557) |
Because we have a design that should provide a great starting point, I've updated this ticket and added the "Needs dev" label! |
I've updated #45364 and it's now ready for review! One thing regarding child blocks with "Fill" set not occupying an equal amount of horizontal space: this is impossible to deal with on the child level, because it depends on what type and size the sibling blocks are. If we do want to have a way to set equal width on all children of a Row block, I'd suggest setting it as a control on the actual Row layout. It could just be a toggle, and it would add a rule like |
Thanks for all the work here, this is exciting. Designwise, I think we can potentially simplify this even further, @jameskoster and I will follow up with some designs we can iterate in. One aspect that was discussed a great deal in #42385 was the responsive behavior, of which fit and fill both handle things well. However, we forgot how to account for "Fixed" in this, so it may be good to follow up on this pretty quickly so we start with expectations of smart defaults. That is, if I set a menu item to be 400px wide, this really only makes sense to do in a non-responsive design. I created this quick codepen to look at flex behavior for a specific width item: https://codepen.io/joen/pen/rNKrVeZ?editors=1100 — this one is working as I would expect it to, that is, 400px is a max-width but when I resize down, Item 1 is allowed to scale and doesn't push off items from the container. To put it differently, it's behaving as if it's Fill + 400px wide, which is good. That's the fixed width behavior we want for these controls as well, but that doesn't appear to be the case in trunk at the moment. What flex arcana do we need to tinker with to make that happen? Is it flex-basis, flex-shrink, flex-grow related? Do we need to look into clamp values? CC: @tellthemachines @andrewserong @priethor A bit more here: #45364 (comment) |
A small part of #42385. Regardless of the Justification setting on the parent, child blocks within a row will always "hug" their content (except for blocks like Image that can have a fixed width applied).
If it were possible to apply different width rules to child blocks then the creation of more elaborate layouts would be simplified.
Additional options to consider:
Here's how it could look:
Issue updated Sep 30.
The text was updated successfully, but these errors were encountered: