Re: [csswg-drafts] [css-grid-2] Masonry layout (#4650)

The CSS Working Group just discussed `Masonry Layout`, and agreed to the following:

* `RESOLVED: Adopt Masonry layout proposal, editors fantasai and Tab, and Mats if he's convinceable`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: Masonry Layout<br>
&lt;TabAtkins> github: https://github.com/w3c/csswg-drafts/issues/4650<br>
&lt;fantasai> jensimmons: Mats Palmgren, layout engineer at Mozilla, over Christmas break, this is what he did for Christmas present<br>
&lt;fantasai> jensimmons: He's thought in detail about what it would take to add something to Grid to accomplish Masonry layout<br>
&lt;fantasai> jensimmons: It's lots of detailed from implementer perspective<br>
&lt;fantasai> jensimmons: So what is Masonry layout?<br>
&lt;fantasai> jensimmons: It's a popular idea of how to lay out content on the Web, e.g. on Pintrest<br>
&lt;fantasai> jensimmons: People wanted to do it with Grid, but you can't really, still have to use JS<br>
&lt;fantasai> jensimmons: works fast on Pintrest because they put a lot of money and effort into it<br>
&lt;fantasai> jensimmons: others use this library<br>
&lt;fantasai> jensimmons: Here's what the layout looks like [shows outline]<br>
&lt;fantasai> jensimmons: Why not do it with flexbox? well that would give the wrong content order<br>
&lt;fantasai> jensimmons: Don't want the early things to be below the fold with late things up at top in the later columns<br>
&lt;fantasai> jensimmons: also makes a problem with lazy loading, would rejigger layout<br>
&lt;fantasai> jensimmons: Order ppl need is going across<br>
&lt;fantasai> jensimmons: This version of Masonry, the most common one, is that as it goes to fill in the rest of the pieces of content<br>
&lt;fantasai> jensimmons: puts next item into the column that is the shortest, so always closest to the top<br>
&lt;fantasai> jensimmons: Other option is to go from 1st column to last column always<br>
&lt;fantasai> jensimmons: but skip columns that are too full to keep things roughly in order<br>
&lt;fantasai> jensimmons: Mats believes he's figured out how to do it in Grid<br>
&lt;fantasai> jensimmons: That's the issue<br>
&lt;fantasai> jensimmons: I think it would be popular and ppl would be super happy to have<br>
&lt;fantasai> TabAtkins: Yes, this has been requested for like 15 years<br>
&lt;fantasai> TabAtkins: Overall, love the proposal, think it's great, lots of detail in it<br>
&lt;bkardell_> q+<br>
&lt;fantasai> TabAtkins: Only concern, making it part of Grid instead of its own display type<br>
&lt;rachelandrew> q+<br>
&lt;fantasai> TabAtkins: Think we should make it display: masonry, copy over concepts from Grid<br>
&lt;heycam> fantasai: any examples of things you're concerned about?<br>
&lt;emilio> q+<br>
&lt;heycam> fantasai: this is somewhat similar in that subgrid is also kind of like a mode<br>
&lt;heycam> ... which creates a different way of laying out items in the grid<br>
&lt;heycam> ... masonry is a different model for doing the rows<br>
&lt;fantasai> TabAtkins: Sugrid is fundamenally a grid still<br>
&lt;fantasai> TabAtkins: but Masonry is different<br>
&lt;fantasai> TabAtkins: Example, Mats suggests an align-tracks property that only applies to masonry<br>
&lt;heycam> fantasai: what's it do?<br>
&lt;fantasai> TabAtkins: it aligns the Masonry stuff within their track<br>
&lt;fantasai> TabAtkins: So there are a few different layout concepts<br>
&lt;fantasai> TabAtkins: that don't apply to Masonry in Grid<br>
&lt;fantasai> TabAtkins: and that don't apply to Grid in Masonry<br>
&lt;jensimmons> q+<br>
&lt;fantasai> TabAtkins: So I think we should re-use as many concepts as possible<br>
&lt;tantek> Is this orientation specific? I.e. presumably masonry refers to the overlapping brick like layout. Flickr does this for displaying photo results, e.g. https://flickr.com/photos/tags/csswg<br>
&lt;fantasai> TabAtkins: but separate out as a distinct display type<br>
&lt;fantasai> TabAtkins: that has a clear signal for what applies here vs in Grid<br>
&lt;fantasai> florian: For align-tracks property, if we did have different modes, could we use an existing alignment property to do this?<br>
&lt;heycam> fantasai: if I understand correctly, you have a box, then some masonry tracks<br>
&lt;heycam> ... each individual track aligning its content to the bottom<br>
&lt;heycam> ... rather than taking the entire masonry chunk and sliding it to the bottom<br>
&lt;heycam> ... isn't this exactly what justify-content does in flexbox? why not just reuse align-content?<br>
&lt;heycam> TabAtkins: only given an hour thought to this<br>
&lt;heycam> fantasai: I think it's premature to split it out, it's its own layout model, but which should think about that<br>
&lt;heycam> ... for now leaving it as part of grid makes sense until we have a clearer idea of what doesn't fit<br>
&lt;tantek> q?<br>
&lt;fantasai> Rossen__: Fan of this proposal<br>
&lt;fantasai> Rossen__: What are we trying to get out of this discussion?<br>
&lt;fantasai> heycam: Wanted to get temperature of the room, see if there's interest<br>
&lt;fantasai> heycam: and also get thoughts on integration<br>
&lt;fantasai> bkardell_: Of course I want this<br>
&lt;fantasai> bkardell_: Want to say same thing as Grid and Flexbox, we should stop and solve the a11y problem with content reordering<br>
&lt;fantasai> bkardell_: I have concerns about that, that's all<br>
&lt;fantasai> rachelandrew: I would really like to see Masonry solved<br>
&lt;fantasai> rachelandrew: I also agree we should look at content reordering proble<br>
&lt;iank_> q+<br>
&lt;fantasai> rachelandrew: Don't think it should be part of Grid<br>
&lt;astearns> ack bkardell_<br>
&lt;fantasai> rachelandrew: Trying to teach it, it's not a grid<br>
&lt;TabAtkins> I think this doesn't introduce any new content-reordering problems; it's definitely no worse than "a pile of floats", still according with the standard "left to right, top to bottom" ordering.<br>
&lt;astearns> ack rachelandrew<br>
&lt;TabAtkins> (Unless you use 'order', of course.)<br>
&lt;fantasai> rachelandrew: would make a lot more sense to have a separate layout model<br>
&lt;tantek> Is there no attempt to do baseline alignment across masonry items in different columns?<br>
&lt;tantek> That might be one reason to consider it grid-like<br>
&lt;Rossen__> ack emilio<br>
&lt;fantasai> emilio: I don't know if should be separate model<br>
&lt;fantasai> emilio: but multicol changes layout model quite a lot, this still mostly fits within grid layout paradigm<br>
&lt;fantasai> emilio: can share a lot of code<br>
&lt;fantasai> emilio: so not quite like multicol<br>
&lt;Rossen__> ack jensimmons<br>
&lt;fantasai> jensimmons: I think these are great issues to bring up<br>
&lt;fantasai> jensimmons: taking of introducer hat<br>
&lt;fantasai> jensimmons: this is jen<br>
&lt;fantasai> jensimmons: I was also concerned about a11y order<br>
&lt;astearns> tantek: I doubt it would be feasible to to baseline alignment when there are not grid lines in the block direction<br>
&lt;fantasai> jensimmons: but aftter explaining, I think it's less of a problem than Grid<br>
&lt;fantasai> jensimmons: It does seem like ppl are tabbing through DOM order, focus rings<br>
&lt;fantasai> jensimmons: Easier because content doesn't go below the fold<br>
&lt;fantasai> jensimmons: I do feel like this belongs as grid<br>
&lt;fantasai> jensimmons: there are 2 axes, and this only works in one axis<br>
&lt;fantasai> jensimmons: do this in row directly, have all power of grid in column direction<br>
&lt;fantasai> jensimmons: Things when it comes to subgrid and nesting a grid inside a grid, might want things to interact<br>
&lt;tantek> would https://flickr.com/photos/tags/csswg be an example of doing it in the "row direction"?<br>
&lt;fantasai> jensimmons: things interact<br>
&lt;Rossen__> q?<br>
&lt;fantasai> jensimmons: Just choose how you want to treat other axis<br>
&lt;fantasai> jensimmons: ...<br>
&lt;fantasai> iank_: I'll try and channel Adam Argyle<br>
&lt;fantasai> iank_: He previously worked in industry and built lots and lots of Masonry layouts<br>
&lt;TabAtkins> Ah, I remember why *-content can't work for distributing the items in a masonry track!<br>
&lt;fantasai> iank_: he had similar reaction that might fit better as a separate layout model<br>
&lt;Rossen__> ack iank_<br>
&lt;Rossen__> ack dbaron<br>
&lt;Zakim> dbaron, you wanted to ask about which grid properties apply sensibly given the placement algorithm<br>
&lt;fantasai> dbaron: Jen was talking about, and think this might relate to Tab's comment on IRC, applying grid properties in vertical axis in masonry<br>
&lt;fantasai> dbaron: One thing I was wondering is how many interact with placement concept of Masonry<br>
&lt;fantasai> dbaron: e.g. if you have align-content in the vertical axis<br>
&lt;fantasai> dbaron: space-around, you want even gaps<br>
&lt;fantasai> dbaron: you don't know how many items until you place them<br>
&lt;hober> q+ myles<br>
&lt;fantasai> dbaron: and you can't place them until you know the number of gaps in each column above the item<br>
&lt;fantasai> TabAtkins: Mats answered it by saying you place items before applying align-content<br>
&lt;astearns> tantek: I don't think the flickr thing is masonry-row. The content order would go top to bottom in that case, and it looks to me like the first three pictures in the first row are in content order<br>
&lt;heycam> TabAtkins: align-content is a different thing, it moves the whole grid<br>
&lt;heycam> ... repeat autofill doesn't work<br>
&lt;fantasai> TabAtkins: But back to fantasai's point about align-content, in Grid it aligns the entire grid<br>
&lt;fantasai> florian: If you have a grid with sized tracks in the Block axis, and the size of the tracks is smaller than the container, then you can align<br>
&lt;fantasai> florian: but masonry tracks don't have such a size<br>
&lt;tantek> astearns, I have heard what Flickr does called "masonry" layout as well so that likely deserves some clarification<br>
&lt;tantek> in particular, the feature of resizing images to fit like that<br>
&lt;fantasai> TabAtkins: Track does have a size, it's the sum of all masonry items in it<br>
&lt;astearns> q+ to surface my side convo with tantek<br>
&lt;fantasai> myles: Want to jump on bandwagon and say it's really exciting<br>
&lt;fantasai> myles: wrt new display type, I think Mats makes a compelling argument wrt graceful degradation<br>
&lt;fantasai> fremy: you can just say `display: grid; display: masonry` which works<br>
&lt;Rossen__> ack myles<br>
&lt;fantasai> TabAtkins: Especially if we re-use grid-template-columns or whatever, it's easy fallback<br>
&lt;fantasai> astearns: Side conversation with Tantek on IRC<br>
&lt;fantasai> astearns: Has example of Flickr, wants to ask if that's also Masonry layout<br>
&lt;tantek> specifically with the resizing of items in the masonry layout<br>
&lt;tantek> yes dbaron<br>
&lt;fantasai> Rossen__: This is a multiline flex<br>
&lt;astearns> ack astearns<br>
&lt;Zakim> astearns, you wanted to surface my side convo with tantek<br>
&lt;fantasai> jensimmons: Flickr decides how many photos to put in a row<br>
&lt;fantasai> jensimmons: then makes the outer edges to match the container<br>
&lt;tantek> it's not just flex. it's about resizing the images automatically to fit them in the row<br>
&lt;fantasai> jensimmons: then changes the height of the row to match<br>
&lt;fantasai> jensimmons: it's weird and complicated and totally done in JS<br>
&lt;fantasai> dbaron: each image is sized based on other photos in the row<br>
&lt;tantek> anyway the point is due to the brick-like layout, this is *also* called masonry<br>
&lt;fantasai> jensimmons: If you [...] then you get basically that layout, but the images are cropped by object-fit<br>
&lt;fantasai> jensimmons: they use JS to avoid cropping the images<br>
&lt;fantasai> jensimmons: and Masonry is a whole different layout<br>
&lt;tantek> having the row heights adjust automatically is key<br>
&lt;tantek> I'm saying that web developers (some at least) know this as masonry as well<br>
&lt;tantek> so if you call something masonry, some may/will expect this to be supported<br>
&lt;fantasai> Rossen__: In summary, I'm hearing a lot of support for this proposal<br>
&lt;fantasai> Rossen__: reminds me of early days of Grid, when we proposed something<br>
&lt;fantasai> Rossen__: and 2nd model was proposed to add to it, at first seemed unlikely to fit<br>
&lt;fantasai> Rossen__: but ended up with a harmonious merge<br>
&lt;fantasai> Rossen__: Let's get something in a more spec-like proposal<br>
&lt;fantasai> Rossen__: then decide if it should fit into Grid, or should be its own thing<br>
&lt;jensimmons> The demo I was just talking about: https://labs.jensimmons.com/2016/examples/image-gallery-flexbox-1.html It only works in FIrefox because of the flexbox sizing bug of images in Chrome, Edge &amp; Safari.<br>
&lt;fantasai> Rossen__: Are there parts that should be extensions to Grid?<br>
&lt;fantasai> Rossen__: I think it will take some time to figure out<br>
&lt;fantasai> Rossen__: but overall goal of proposal and exposure of topic is achieved in sense that there's a lot of support and demand for this, so let's continue working on this in a separate module for now to bake out the details and decide the next path forward<br>
&lt;fantasai> Rossen__: might be Grid, might be something else<br>
&lt;fantasai> Rossen__: sound good?<br>
&lt;fantasai> fantasai: +1<br>
&lt;tantek> +1<br>
&lt;bkardell_> ... and to double down on solving the general reordering issue?<br>
&lt;fantasai> Rossen__: So I propose we take a resolution to adopt Masonry layout and move from there.<br>
&lt;fantasai> fantasai: Who's editing<br>
&lt;fantasai> TabAtkins: I'll co-edit, but not primary edit<br>
&lt;fantasai> Rossen__: Mats?<br>
&lt;fantasai> dbaron: We might have to do some convincing<br>
&lt;fantasai> fantasai: I can edit.<br>
&lt;fantasai> RESOLVED: Adopt Masonry layout proposal, editors fantasai and Tab, and Mats if he's convinceable<br>
&lt;fantasai> bkardell_: Masonry isn't in content order<br>
&lt;dbaron> and Jen?<br>
&lt;fantasai> florian: yes and no, it's not a 1D thing, they're in 2D space<br>
&lt;fantasai> florian: but within that space they're in content order<br>
&lt;astearns> they are always top to bottom, not necessarily left to right<br>
&lt;fantasai> s/convinceable/convinceable, and Jen if she's allows/<br>
&lt;fantasai> ?<br>
&lt;bkardell_> for the record, not pushing back on 'this' - worried about the general space<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4650#issuecomment-577614598 using your GitHub account

Received on Thursday, 23 January 2020 10:13:00 UTC