-
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
Flex Layout Iterations #33687
Comments
Do we need to establish some criteria for when Flex is better over Grid? |
I didn't think much about the Grid layout yet but it seems that "Flex" is easier/simpler when it comes to basic vertical blocks (social icons, navigation, buttons) but Grid would be a better choice for "page layouts", so an option on a generic container/group block (or variation) that you apply at the top level of your template. I think what we're missing right now to start exploring Grid, is better understanding/exploration on what needs to be configured at the container level and what alignment/config options to expose on the child blocks. Maybe @jasmussen could help with that a bit. I think we could use a separate issue about the Grid layout to answer these questions:
|
I think the important aspect is that it's not just a different layout property and it's more about who has more control, the parent block or the child blocks when laying things out. And that's something we should take into account early on since it can dictate the kind of tools that get exposed and where (in the container toolbar/inspector or the children toolbar/inspector). Also relevant. |
I really like where this is going. From a UX perspective, I think that Webflow does an excellent job with their Grid/Flex layout interfaces. |
I riffed on some ideas as part of a big-picture proposal for the Group block's layout panel. Thoughts? #34558 |
@youknowriad where do you think we stand with this one after the latest work on Row, Stack and the transforms menu like #40036 ? |
I think in terms of features for the flex layout itself, we're mostly there. Maybe the only potential addition could be this:
Similar to how "alignments" appear when you chose a "flex" layout for the container, specific flex alignment options could appear in child blocks when you select "flex" as their container. That said there are a number of issues in terms of "architecture". Right now, some blocks have "align" block support which only works if container is "flow" and it works by adding an "align" attribute to the block. There are several things we should improve here:
|
One small addition is to consider a matrix-grid like alignment tool, a la what the Cover block has already, for flex containers that allow both vertical and horizontal alignments. Probably worth its own separte issue? |
For self-positioning? |
@jasmussen I'm not sure that interface make sense. What's "center": "justify center" or "space between"? |
I was talking about self-align, though — so you can place something at the top of a cover, something else at the bottom, etc, which is not possible with the matrix control on the parent. |
@jasmussen orientation doesn't make sense for individual blocks inside a container, justify might not make sense either. |
Yes, I also wonder if it should be on the toolbar. Conceptually it's the alternative to "align left/right/wide/full" that we have for children of "flow" layouts. |
@youknowriad do you see anything pending here? I think maybe some of the self-align options, which also overlap with the matrix control, but I think it'd be better to extract that into a separate issue. I feel the core work is done here. |
@mtias 👍 Let's close and do a separate one about self align. |
In #33359 we added the possibility for blocks to support multiple layouts: the default "flow" layout and the new "Flex" layout. In the future, we'll be also introducing other layouts like "Grid" or "Absolute positioning container"...
What is a layout?
A layout is a configuration you apply to a container block that changes how its inner blocks are aligned, and also impacts the behavior of these inner blocks (enable/disable some customization options). Right now, we have two types of "layouts" we can apply to container blocks:
Flow layout: This is the default behavior in HTML, meaning if you apply this to a container block, its children are rendered one after the other vertically without any specific CSS styles (it works just like adding divs inside divs). Blocks inside a flow container can be left/right aligned (float) and in this type of layout, you have the possibility to define a "content size" and a "wide size", by defining these, the inner blocks get centered by default inside the "content size" area and they receive new alignments options (full/wide alignments)
Flex layout: This is a layout where the container receives a
display: flex
style. Right now it's opinionated, meaning the inner blocks are positioned horizontally one after the other with a small gap between each block. No alignment options are available for inner blocks inside a "flex container". That said, it is likely that we'll be introducing a number of customizations for this kind of layout. For instance, we could add a config to choose whether the blocks are horizontal or vertical (some argued that flex should be only used for horizontal alignments but it's something we should discuss more). Another option could be the "gap" size,align-items
could also be a config option for the layout itself. For the children of this particular layout, we could potentially explore adding positioning tools (like align-self and such).Layout switching
Generic container blocks like the group are most likely going to require a layout switcher UI to allow users to switch layouts and configure its specific options.
Right now, the initial prototype from #33359 contains a very basic undesigned layout switcher that you can enable by replacing this line with:
You'll get something like:
This area is going to require a better design/wording...
Refactoring blocks to use declarative layouts
Historically, we've added a number of flex horizontal container blocks over time like: Social Links, Buttons, Columns and Navigation blocks. But we did so in a very ad-hoc way, meaning we just added custom CSS and custom customization options to these blocks. Now that we introduced the "layout" config and the "flex layouts", we should consider refactoring some of these blocks to be more declarative and remove the specific treatment we have right now for these blocks.
One technical issue that needs solving though to do that is that right now, the layout block support renders styles in the editor by using the
__experimentalLayout
prop of theuserInnerBlocksProps
call, but in frontend it relies on thelayout
block attribute. For the editor, the current APIs should be enough but for the frontend, these blocks might not allow users to tweak their "layout", meaning thelayout
attribute might or might not be necessary. We need to find a declarative way in block.json to define the "default layout" of a container block.Todo List
In terms of design, we need a couple of explorations:
In terms of architecture:
The text was updated successfully, but these errors were encountered: