-
Notifications
You must be signed in to change notification settings - Fork 681
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
[css-grid-3][masonry] Masonry Syntax Debate #11243
Comments
A couple of questions for folks to (maybe?) spark some discussion:
|
TAG feedback: w3ctag/design-reviews#1003 (comment) |
FWIW: I still agree that in isolation, With that in mind, and with the also welcome shift away from using "masonry" as a term and instead leaning on the existing "collapse" keyword already found elsewhere makes a lot more sense for the future. |
If we were to choose from the two options presented, I prefer the “Just use Grid” option. I have a bigger take on this, which I just can't find an opportunity to write up properly, but the gist is that with masonry we're mixing two things: one-dimensional layouts (without the masonry specifically, as a wider feature), and the masonry auto-placement algorithm. I'd want the first feature as a part of a CSS grid, regardless of the masonry. Then, having one-dimensional grids, introducing an alternative placement algorithm in addition sounds like a reasonable iterative approach. I am against the
I agree with the arguments for the grid-independent option about good defaults and shorthands. However, I can see a future where, instead of putting the current flawed grid aside and giving up on it in favor of a new system, we could see if we could improve what we have. With new keywords added to the mix, they allow us to change the way shorthands behave, and design things better. It is true that authors rarely use the |
The CSS Working Group just discussed The full IRC log of that discussion<fantasai> Topic: Masonry Syntax Debate<fantasai> github: https://github.com//issues/11243 <fantasai> alisonmaher presenting from Chromium team <fantasai> alisonmaher: [intros the topic] <fantasai> alisonmaher: Several properties behave differently in each, or don't apply, so we think a new display type would be better. <fantasai> alisonmaher: Plus we can define a better default value for the template tracks, creating an automtical masonry instead of a single column <fantasai> alisonmaher: Regarding grid fallback, needing one is a temporary problem, so should focus on the future <fantasai> alisonmaher: authors should make explicit fallback, to avoid surprises <fantasai> alisonmaher: Positioning in masonry is simpler than grid, it's only placed in 1 axis instead of 2 <fantasai> alisonmaher: Grid is confusing because authors might make a mistake about which axis they are placing in (rows vs columns) <fantasai> alisonmaher: separate model only has one axis <fantasai> alisonmaher: this allows switching the axis easily <fantasai> alisonmaher: Shorthands also are better with separate shorthand. Grid shorthand is complicated, hard to use. Masonry shorthand is easier because don't need to remember the order <fantasai> alisonmaher: placement works differently in grid vs masonry <fantasai> alisonmaher: dense packing is also different : for grid can place in any empty slot, but due to perf considerations for masonry current proposal restricts to same-sized track <fantasai> alisonmaher: masonry also has different intrinsic sizing rules, with auto-placed items affecting all auto-sized tracks not just the one they end up in <fantasai> alisonmaher: alignment is also very different, open questions about how this works in the masonry axis <fantasai> alisonmaher: this means grid and flexbox are quite different in how they behave <fantasai> alisonmaher: in masonry layout auto-placed subgrids don't inherit line names <fantasai> alisonmaher: we expect there to also be other changes for submasonry/subgrid that will lead to divergences <fantasai> alisonmaher: Integrating masonry into grid will lead to spec bloat, will be harder to teach, and lead to developer confusion <fantasai> alisonmaher: Conclusion: masonry should be a separate display type <fantasai> jensimmons: [intro slide] <fantasai> jensimmons: At this point decision is about syntax -- mental model. Behavior is same in both. <fantasai> jensimmons: [reviews basic case] <fantasai> jensimmons: Choice to Just Use Grid is extending Grid L1. [shows example of grid vs masonry photo grid, with one difference - the grid-template-rows: collapse line] <fantasai> jensimmons: New layout type, creates a separate tool with separate syntax that's similar but not the same as what exists <fantasai> jensimmons: [shows table of properties being added] <fantasai> jensimmons: We don't believe there's a compelling argument to add so many new properties to CSS <fantasai> jensimmons: Both have properties for defining tracks; defining masonry axis <fantasai> jensimmons: both have ways to define placement, and both have a new slack property <fantasai> jensimmons: both have shorthand, and a gap property <fantasai> jensimmons: and both have ways to implicitly size tracks <fantasai> jensimmons: more significant difference is grid-auto-flow vs masonry-direction/fill/flow <fantasai> jensimmons: Chromium argues that their new syntax is more understandable. We disagree, just use grid-auto-flow <fantasai> jensimmons: Other major difference is template syntax <fantasai> jensimmons: Here's a column example using the templat syntax. identical in grid 1, and masonry in both <fantasai> jensimmons: When you layout rows in grid, template syntax is a bit different -- you stack the template names to phyiscally diagram the names for the rows <fantasai> jensimmons: Just Use Grid re-uses this syntax exactly; but new masonry layout uses the column syntax for rows. <fantasai> jensimmons: Chrome believes it's less confusing to use the same syntax in rows vs columns; but we believe it's better to use the same syntax between grid rows and masonry rows <fantasai> jensimmons: Other difference is the auto-flow -- grid's indicates the primary fill direction, Chrome believes this doesn't make sense and changed it to match the orientation of lines <fantasai> jensimmons: Debatable which is better. Might make sense if we had time machine, but is it worth creating a new layout API for this ? <fantasai> jensimmons: Lots of subtle differences are likely to trip people up. They're familiar but not quite the same. <fantasai> jensimmons: We shouldn't fork grid, would be confusing to authors. <lea> q? <lea> q+ <fantasai> jensimmons: Chrome argues that new display type allows better defaults -- but the defaults propose aren't good <fantasai> jensimmons: if you think through the default they propose, it doesn't quite work as easily as claimed [see article] <fantasai> jensimmons: requires deep understanding of autosizing <fantasai> jensimmons: We believe it's better to just use grid. Very simple, one new value, re-uses syntax and mental model makes easier to learn <fantasai> jensimmons: also easier to switch, e.g. at breakpoints or progressive enhancement <fantasai> jensimmons: follows CSS design principles to re-use what already exists <fantasai> [end presentations] <fantasai> astearns: If you have comments, please add yourself to the queue <astearns> ack lea <lea> https://github.com/w3ctag/design-reviews/issues/1003#issuecomment-2489688718 <fantasai> lea: We did a TAG review on this <fantasai> lea: My opinion is fully reflected there. I think the arguments WebKit team makes are compelling. <oriol> q+ <fantasai> lea: We thought not only should masonry be part of grid, but should go further. <fantasai> lea: a lot of arguments for integrating is that "grid is too hard". In that case we should make grid things easier. <astearns> q+ <fantasai> lea: complex things are possible, but simple things are not so easy <fantasai> lea: Big part of Google's argument is defaults, but we could just have smarter defaults -- there is precedent for this in CSS <fantasai> lea: if we decided that would help ergonomics <TabAtkins> q+ <fantasai> lea: We agree that switching between grid vs masonry is common. Grid might be a slightly better fallback than nothing, but minor argument because ppl can use @supports <fantasai> lea: Introducing all these new properties increasing the API surfaces that authors need to learn. Less they can port over. <fantasai> lea: Even if we say we will be disciplined, experience shows that we won't. Even if not intentional, accidental. <fantasai> lea: DRY - don't have multiple sources of truth <miriam> q+ <fantasai> lea: One of arguments against masonry in grid is that grid's are 2D, but actually in graphic design grids were often 1D <fantasai> lea: I agree that most masonry use cases need simpler grids than general grid use cases <fantasai> lea: but that means we should make those grids easier to define for both grid and masonry <fantasai> lea: the more we looked into this, we realize there are 3 different layout modes that give you 2D arrangement of children <fantasai> lea: we recommended not just make masonry part of grid, but find ways of integrating what we already have better <fantasai> lea: could we come up with a shorthand that sets grid-auto-flow and flex-direction, and promote that for layout direction in general? <fantasai> lea: then authors only need to learn one control for it <fantasai> lea: another concern was overfitting <fantasai> lea: it doesn't cover a lot of cases that look like masonry, like Flickr-style grid <fantasai> lea: it's like a horizontal masonry <astearns> ack oriol <fantasai> oriol: Problem with jensimmons's reasoning <fantasai> oriol: She said the proposed masonr-direction property would be new syntax that doesn't match grid-auto-flow property <fantasai> oriol: but this property matches flex-direction property <fantasai> oriol: so instead of trying to be close to grid, tries to be close to flexbox <fantasai> oriol: closer to grid is a choice, could be consistent with different things <fantasai> astearns: One question I asked is, has anyone changed their mind on which proposal they support? <fantasai> astearns: I personally have. I thought that separate display property made a lot more sense, in terms of designing the feature and I was very daunted by the idea that we'd have to consider both grid and masonry for any new development ineither <fantasai> astearns: seemed sticky to me <fantasai> astearns: but the TAG argument convinced me that we should do the work of integrating these things <astearns> ack TabAtkins <fantasai> TabAtkins: Thanks for setting that up for me, because I'm going to refute the TAg argument! I think they're wrong in this case <astearns> ack astearns <astearns> zakim, close queue <Zakim> ok, astearns, the speaker queue is closed <fantasai> TabAtkins: You can draw a lot of surface-level connections between Grid and Masonry, and Flexbox, and other hypothetical layouts <jyasskin> q+ <fantasai> TabAtkins: but when you actually look at details of how they work, behaviors each one is capable of, they're pretty distinct <fantasai> TabAtkins: if you try to combine together, it would be an unholy mess of conflicting constraints -- e.g. flexing in items of masonry or grid <fantasai> TabAtkins: or you'd have a weird mish-mash of, "the 2D layout", but if you call it a flex you get access to these properties, call it grid, access to these other properties <fantasai> TabAtkins: concrete example, "pillar" example mentioned in webKit blog post, that wasn't compatible with the base concepts in masonry and flex because it wants a shared block formattng context <fantasai> TabAtkins: grid etc have different formatting contexts, can't use floats <lea> actually, the TAG argument was that layout seems to actually be a continuum, and syntax should accommodate that rather than forcing one of two extremes (current flex vs current grid). <fantasai> TabAtkins: they're specialized for what makes sense <fantasai> TabAtkins: You can occasionally merge things together, but definitely not something you can do that by default <fantasai> TabAtkins: too distinct to be merged in a reasonable way <jensimmons> That's why the "pillar" example will use `display: block`. The argument being made when it was articulated is NOT that it should be part of Grid, but that it should be part of Block, and not it's own yet another new mode. <lea> Our argument was not "make it a part of grid" per se, but more "don't introduce a completely parallel new thing". If you can extend flex so that masonry can become part of that, that's just as fine <fantasai> TabAtkins: Then usability arguments. <lea> q+ <fantasai> TabAtkins: The masonry shorthand can be very similar to a standard CSS shorthand -- fully reorderable, just put the bits you care about <fantasai> TabAtkins: integrated one, the grid shorthand is very complex, mixing in masonry doesn't make it simpler <fantasai> TabAtkins: would stay bad and get worse <fantasai> TabAtkins: separating lets use design things catered to the use case <lea> if the `grid` shorthand has poor usability we should improve the grid shorthand, not design a new thing :) <astearns> ack miriam <fantasai> miriam: Like Alan, tend to agree with TAG on this. I'm not real excited about a future where we keep inventing new layout modes with slight differences. <TabAtkins> The `grid` shorthand is complex *intrinsically*, it's got a lot of concepts that have to all be put together. It can't really be made much better. <astearns> ack dbaron <fantasai> miriam: I get that there's complexity, but it's worth the attempt to figure out how to not invent new tracks every time we have a new layout that has tracks <TabAtkins> And that intrinsic complexity is directly tied to it being an inherently 2d layout mode, whereas Masonry, like Flex, is "1d, plus a bit" <fantasai> dbaron: I remember Ian arguing about the perf characteristics wrt intrinsic size calculations <fantasai> dbaron: Was related to fundamental ordering between how parts of the process run in grid vs masonry <fantasai> dbaron: Good perf important for end users. Is that topic still under debate? Or is masonry in grid syntax using the model that Ian wanted <fantasai> TabAtkins: Whether in grid syntax or not, using the distinct layout rules we defined to work for it <fantasai> jyasskin: Wanted to emphasize a couple aspects of TAG review <fantasai> jyasskin: It seems really nice to keep the property from Chrome proposal that you don't have to learn both, can just learn to do masonry without learning all of Grid <fantasai> jyasskin: even if that's in a unified system <fantasai> jyasskin: perhaps still define masonry shorthand, and have it set grid properties <jensimmons> To create a simple masonry-style layout in Grid, you just need 3 lines of code (4 with a gap). It's quite simple. <fantasai> jyasskin: Most consensus part of TAG feedback was to share properties whenver possible <lea> q+ <fantasai> jyasskin: Not necessary to share the same 'display' values; could define different 'display' values but share the properties. <fantasai> jyasskin: One thing we didn't like about unified proposal was `grid-auto-flow` in the unified proposal, where some values were ignored. <TabAtkins> Yeah, this is the usability point I'm pounding on <fantasai> astearns: I'm not hearing a way forward yet. At some point, one of the camps is going to have to concede in order to move this forward. <fantasai> lea: What if we do a straw poll. Not to decide, but to figure out how far are we from consensus? <fantasai> +1 lea <fantasai> lea: people may have been convinced <fantasai> POLL: 1) Just Use Grid 2) New Masonry Layout <TabAtkins> 2 <lea> 1 <fantasai> 1 <kizu> 1 <oriol> 2 <bts> 1 <alisonmaher> 2 <jensimmons> 1 <masonf> 2 <florian> 1 <miriam> 1 <ethanjv> 2 <JaseW> 1 <astearns> 1 (changed from 2) <dbaron> abstain <ydaniv> 2 <rachelandrew> 2 <dholbert> 2 (weak preference) <gfaujdar> 1 <chrishtr> 2 <SebastianZ> 2 <jfkthame> 1 <bramus> abstain <kbabbitt> 2 <joshtumath> 2 (but being persuaded) <schenney> 1 but try to move toward common property names <noamr> abstain (happy if we ship either!) <jyasskin> I would love to see both camps' attempts to move a step closer to a shared understanding. e.g. Do the WebKit folks think it makes sense to define a masonry: shorthand in the grid-unified proposal? Can they fix grid-auto-flow? Do the Chromium folks see some properties that could be more shared? <romain> 1 (changed from 2) <emilio> 1.5 <fantasai> jensimmons: Personally disappointed that we're not making more progress. We've been having this argument for 5 years. <fantasai> jensimmons: We have two implementations. We'd like to ship. Lots of discussion over the last year. <fantasai> jensimmons: Many folks have strong opinions, but the target keeps moving. A lot of the concerns have been addressed, but new reasons to keep separate. <TabAtkins> I mean, same. <fantasai> jensimmons: Argument is no longer about technical details, but overall concept and authoring experience. <JaseW> Are Jen's slides available anywhere? <fantasai> astearns: I believe both camps want to ship and are frustrated with current impasse. <rachelandrew> not new reasons here, same reasons I started with (before I was at Google) <astearns> zakim, open queue <Zakim> ok, astearns, the speaker queue is open <fantasai> jyasskin, yes I think we could do that. Not sure it would convince the Chrome folks though :) <JaseW> @jensimmons |
Slides from Jen Simmons: https://lists.w3.org/Archives/Public/www-archive/2024Dec/att-0002/Masonry_presentation_to_CSSWG_____Dec_4_2024.pdf |
Now that I've had more time to consider the opinions raised in our call on Wednesday – and particularly the TAG review which @LeaVerou shared – my mind has changed and I have swayed towards the 'Just use grid' option. I'll explain why. The TAG viewpoint set us a new north star to aim for where all layout methods that do a '2D arrangement of children' become more unified and easier for authors to declare:
This argument was particularly compelling to me (emphasis added):
This argument trumped my main concerns around how we might want the syntax to diverge. The argument also supported the vision that the WebKit team gave us at the end of their blog post about a possible future where we could even somehow use the grid properties on flow layouts. And then the TAG review goes on to talk more broadly about layout syntax.
In conclusionOn behalf of the BBC, I am happy to support the "Just use grid" syntax to move the proposal forward. However, the TAG review has set out a wider vision for shorthands or other more generic syntaxes for defining layouts. Would it be helpful, as part of this issue, to start blue-skying those, just to help the debate along? I would be interested to see any proposals. For example, the fact that we can now use |
I am an outsider here, but wanted to give my grain of sand from an author's point of view. I don't want to get into which proposal will be easier to define in the spec or implement in browsers since that's something that most developers aren't aware of but rather boil it down to what syntax developers will find easier to learn and use, and if the future gives us more layouts like the Webkit post suggests, which will make it easier for developers to learn to new layouts. Prefixes and extra propertiesOne of the main arguments for the Just Use Grid team is the enormous amount of similar properties that would need to be added to CSS. By the WebKit Post:
By the same logic, it isn't a problem of new properties with a If we look at another example given in the WebKit post: According to the Chrome proposal, this type of layout would have its own prefix, but I think everyone would agree it would be hellish to also have Onto the Webkit argument, they say that maybe in the future this layout could be achieved with a snippet like the following: article {
display: block; /* default value, unnecessary to state */
grid-template-columns: 1fr 1fr minmax(15ch, 30ch) minmax(15ch, 30ch) 1fr;
grid-default-column: 3 / 5;
} But to me, it feels unnatural to use If the conversation is focusing on unifying, then I just wanted to bring this to the table, but I must say that I am ignorant of the consequences and implications of this. Just a not-that-technical developer's point of view of what I would like to code in the future :) |
I've been sitting on this for a bit, because of vacation/Christmas/etc., but I think it's ready to post now. tldr: The "reuse when possible" principle is completely valid and should be (and is) applied as much as possible, but it shouldn't be overused, when merging/reuse is messy or complicated. Grid/Masonry is an example of the latter, with several properties that work well in Grid but are genuinely bad when used for Masonry, and several other properties that are at least clumsy in Masonry (tho technically usable). This appears to be a general issue, since Flexbox can't meaningfully merge into these either, nor can future examples that have been brought up. In short, while new layout abilities sometimes merge nicely into an existing layout mode (like Subgrid into Grid), it is usually the case that the abilities of one layout mode, and the specialized syntaxes we design to allow authors control over those abilities, are usually a bad fit for even a moderately different layout mode. Layout modes should, in general, get their own set of properties with their own specialized syntaxes, rather than trying to reuse each other's properties. I'll go into detail on exactly how the current Grid-masonry design is bad, and at the end, offer a compromise if the WG still disagrees that Masonry should be its own independent layout mode. Specific examplesApologies for the length of this section. The badness really is in the details; the way that the Grid properties work when applied to Masonry is an extraordinarily bad design, and it's worth working thru those details rather than handwaving it as "it's bad, just trust me". If you'd prefer to trust me, feel free to skim.
ConclusionEven with a few more fixes to the grammar to make it work properly, Grid-masonry is still fundamentally awkward to specify and use. We would never design such a syntax from scratch; we'd be laughed out of the WG telcon. The cost of requiring authors to use such a clumsy syntax, and the precedent it establishes for how clumsy of a syntax we're willing to tolerate, is not remotely worth the benefits of authors not having to learn a new set of property names. As well, the benefit of reusing property names does not meaningfully carry over to actually reusing the property values in many cases; the actual meaning of those values is in several cases significantly distinct anyway, so authors are effectively still learning a new set of properties when using Grid-masonry, just spelled the same as an existing set. This is actually a detriment to learning and understanding, versus having to learn a new-but-similar set of well-designed properties and values that match the underlying model better and much less clumsily. Even if we designed Flexbox from scratch today, it would similarly not be able to reuse the Grid properties without being awkward and clumsy. I assert (without showing my work) that this would be true even if we designed the entire thing from scratch, all three of Flexbox, Grid, and Masonry together without any backwards compat to worry about. And the discussed possible future layout models, like "pillar", are similarly quite distinct and would have their own awkward/clumsy integration into such a combined layout mode. In conclusion, Masonry should be its own Compromise (that I don't like)If the WG still disagrees with all of the above and thinks it is worth trying to reuse Grid properties in Masonry as much as possible, I offer this in-between proposal that avoids as much of the badness as I can. I must stress that I do not like this proposal. A lot of the clumsiness is inherent to the fact that Grid is designed to be fully 2d, while Masonry is, similar to Flexbox, 1d-and-a-bit in its concepts. But it is substantially better than the current Grid-masonry proposal.
This design lets us ignore the terrible syntax of If we really wanted to minimize the number of new properties, we could instead merge Note that accepting this compromise does not imply that we'll continue to merge more layout modes into Grid just because they're 2d-ish. We'd still evaluate them as they come. |
Apple spent some time reviewing the TAG feedback and the comments above, and particularly considering the concerns about awkwardness with
The new flow controls for masonry would look like this:
Here’s the code to accomplish two use cases from this article:
Thoughts? |
|
The content inside of flexbox or grid are items. |
The CSSWG's masonry layout draft includes two competing syntax proposals for the feature. There has been a lot of discussion between the two, and there's an overview of the debate in the TAG review issue.
Opening this issue to focus on the syntax question, since the previous issue debating two possible models started with focus on the performance implications of mixed track sizing, etc. that are no longer relevant.
Key links (primary in bold):
The text was updated successfully, but these errors were encountered: