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

Improvements to Grid Layout and Subgrid support #57478

Open
6 of 18 tasks
tellthemachines opened this issue Jan 2, 2024 · 6 comments
Open
6 of 18 tasks

Improvements to Grid Layout and Subgrid support #57478

tellthemachines opened this issue Jan 2, 2024 · 6 comments
Assignees
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues.

Comments

@tellthemachines
Copy link
Contributor

tellthemachines commented Jan 2, 2024

Related to overview issue with Design Tools: #33447

The Grid layout type shipped in WP 6.3 and in #59051 a new Grid variation for the Group block was stabilised. This issue tracks further enhancements.

Grid layout and Grid variation

Enhancements to the Grid layout type and the Grid variation for the Group block.

  • Grid children spanning multiple columns with the "auto" grid setting will need some sort of responsive behaviour so the grid doesn't break at smaller breakpoints (see Add support for column and row span in grid children. #58539 (comment))
  • The ability to position a child in/starting from a specific column or row (this should only work for the "manual" grid, given that with the "auto" grid column number varies depending on container width) - could be an "offset" input control? (PR)
  • Regarding subgrids: they can be made to work for direct descendants of a block with grid layout fairly easily.
  • Allow grouping into a Grid block, similar to Rows and Stacks.
  • Allow setting number of rows when Grid is in manual mode.

Grid interactivity experiment

Experimental feature that lets you move and resize grid items in the editor canvas. Enable via Gutenberg → Experiments → Grid interactivity.

Original issue description

What problem does this address?

The Grid layout type shipped in WP 6.3. No blocks use it as default yet, but there's a Group block grid variation that can be enabled in Gutenberg experiments.

Currently grid layout can only be used to either set a minimum column width (so the number of columns depends on container size) or a number of columns (with responsive width). This doesn't offer huge flexibility in terms of positioning child blocks inside a grid, so it would be great to offer more controls for that purpose.

What is your proposed solution?

Child blocks of a grid layout could have controls to align them to the parent grid columns. I'm not sure what might be the best representation of this: should the concept of column span be transparent to users? Should the controls work more like traditional alignments (in which case it would be interesting to experiment with making the grid configuration match theme content and wide width settings)?

The option to position a child within a grid would also be useful, and I am also unsure of how this might translate into a control 😅

Allowing use of drag and drop to position elements in a grid would be ideal. This would involve somehow mapping drop areas to grid columns.

It would also be useful if grids nested inside other grids and spanning multiple columns became subgrids by default (they could still have the option to not be a subgrid by defining their own columns).

@tellthemachines tellthemachines added [Type] Enhancement A suggestion for improvement. [Feature] Layout Layout block support, its UI controls, and style output. labels Jan 2, 2024
@SaxonF
Copy link
Contributor

SaxonF commented Jan 3, 2024

Quick sketch showing what a next iteration of grid might look like. Keeping in mind we still want to push layout forward in general including generic width/height options via #53455.

image

Children fill width/height of column/row by default. I'm showing width/height controls just to illustrate they are different to span and can be included in the separate layout work. We can start with inspector controls and work our way towards on canvas manipulation, including start/end of grid items which can lead to overlapping blocks.

@paaljoachim
Copy link
Contributor

Some free flowing thoughts....
Can we have one grid system that can be used by the Cover block, Group block. Columns block etc? (with some minor adjustments where needed.)

I say this as the "Change Content Position" inside the Cover block can use a nice upgrade. Having one grid system used between the various blocks would be very helpful.

In relation to grid. It would also be helpful to have an icon to turn on/off helper lines. Somewhat like InDesign/Photoshop one can turn on the grid lines to see how things line up.

@tellthemachines
Copy link
Contributor Author

Thinking through what's needed here in light of #58539:

  • Grid children spanning multiple columns with the "auto" grid setting will need some sort of responsive behaviour so the grid doesn't break at smaller breakpoints (see suggestion)
  • The ability to position a child in/starting from a specific column or row (this should only work for the "manual" grid, given that with the "auto" grid column number varies depending on container width) - could be an "offset" input control?
  • Positioning grid items with drag and drop: the drop indicators when dragging over a grid block could show a block dropzone over empty columns.
  • Changing column and row span of grid items with drag to resize
  • Regarding subgrids: they can be made to work for direct descendants of a block with grid layout fairly easily.

it would be interesting to experiment with making the grid configuration match theme content and wide width settings

I played around with this a bit and it doesn’t seem possible to match the current behaviour of content and wide layouts with grid. In any case there’s no real gain in replacing the content sizing and alignment logic with a grid-based implementation.

@noisysocks
Copy link
Member

noisysocks commented Feb 7, 2024

  • Positioning grid items with drag and drop: the drop indicators when dragging over a grid block could show a block dropzone over empty columns.
  • Changing column and row span of grid items with drag to resize

👋 I'm going to try and build a prototype of this stuff.

@noisysocks noisysocks added [Type] Overview Comprehensive, high level view of an area of focus often with multiple tracking issues and removed [Type] Enhancement A suggestion for improvement. labels Feb 27, 2024
@noisysocks
Copy link
Member

@tellthemachines, @SaxonF and I are actively working on this. I updated the issue to be an overview issue and added a few tasks that we've discussed.

#59052 added a new Grid interactivity experiment which you can enable in Gutenberg → Experiments. Currently you can visualise where the grid cells are when you select a Grid block and use a resize handle to set the span of a block within the Grid. I'm looking into drag and drop now.

@noisysocks
Copy link
Member

noisysocks commented Apr 30, 2024

Update:

A lot of this feature has involved synchronous back-and-forth chat so in an effort to make those conversations more transparent I've create a channel in the w.org slack called #feature-grid.

I've been experimenting lots with drag and drop in #59490 and in #61025. There's some good progress but still a lot of discovery to do and questions to answer.

@tellthemachines and I both have a few commitments coming up, and @SaxonF is now on parental leave, so we're running out of time to get things polished for WP 6.6.

With that in mind @tellthemachines and I are going to focus on shipping:

  • Column / row span attributes
  • The grid line overlay
  • Resize handles

Tasks to do:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues.
Projects
Status: No status
Development

No branches or pull requests

5 participants