-
Notifications
You must be signed in to change notification settings - Fork 693
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-flexbox][css-grid] Unifying grid-auto-flow and flex-flow #11480
Comments
I wanted to comment on one piece of this. The rest looks like a great direction to explore, but I'm not enough of a CSS expert to opine that it's definitely the way to go. Giving a Fundamentally, these say whether to stack items in the |
It's great that we're starting to think about solutions to the TAG recommendation for unified layout properties. I think this is a good proposal. And I agree Do you see this as part of a family of other For example, I wonder if maybe the syntax for However, I'm thinking about how there are still lots of essential properties needed for each layout system that are unique to each layout system. For example, to create a flex or grid layout, I'm still most likely going to use If I mixed them together in the same layout, I'd probably write something like this: .my-layout {
display: flex;
item-flow: row-reverse wrap;
> * {
flex: 1;
}
@media (width > 20rem) {
display: grid;
grid-template-columns: repeat(auto-fill, 8rem);
}
} In the above example, using |
(tldr: complaints up top, counter-proposal near the bottom) I don't think this proposal works. If we were just talking about Flexbox and Grid, this seems pretty reasonable, to the point that I'd likely have supported it if was suggested a few years ago. But in trying to wedge Masonry into the same framework of property and value names, it makes some pretty serious mistakes. In both Flexbox and Grid, the Also, the So far, so good: these two layout modes (Flexbox, and Grid auto-layout) have very similar concepts, used in very similar ways, and the same sorts of terms apply meaningfully across both. There's some tension - These arguments don't apply to Masonry. @jyasskin brings up the first issue: this proposal defines that Second, the Third, the entire concept of wrapping doesn't apply to Masonry. This proposal defines it as dictating in which direction Masonry fills its tracks, but this exact concept is controlled by Fourth, the additional values still don't have great meanings in Masonry:
Fifth, while I think applying the 'slack' concept to Flexbox is pretty interesting and worth pursuing †², afaict there's no meaningful definition for Grid. In conclusion, I think this proposal makes some unacceptable design decisions, which are forced on it due to trying to fit Masonry's layout concepts into the "direction + wrap" concept pair that Flexbox and auto-Grid use. I would oppose this. Instead, Masonry needs its own set of properties to handle the "direction + tie-breaking" concept pair that it actually uses, as I proposed in #11243 (comment). If we did want to define a single collective set of properties, I think it's possible! A good design just has to recognize that some concepts don't apply to some layout modes, rather than trying to cram all of them into the same set of concepts, like how different layout modes use different subsets of the
If we use Grid-masonry, we'll still need a separate way to indicate that a given Grid is using Masonry instead of Grid layout. If using [edited to move some comments to #3071] |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
An idea that's been floating in my head (to point 2 of my comment in #11243) is to have a property that both selects between, and parameterizes, flexbox/grid/masonry/etc. Something like:
The grammar's a bit more verbose, but the branching leaves room to avoid the problems of specifying combinations that don't make sense. That particular example also leads to |
Moved some comments about Flexbox's My alternate proposal for those Flexbox behaviors is presented in a small final comment. |
@fantasai and I did some brainstorming yesterday to reconcile our ideas: keeping the "track-centric" naming system from my counter-proposal that I find important, while reducing the amount of divergence among the layout modes in it, which fantasai finds important. I think this proposal we've come up with is acceptable, and sufficiently extensible for future layout modes.
The core difference between this proposal and Apple's proposal is how they map onto the two axes: in this proposal, row/column/etc describes the track axis--i.e. the resulting layout that you see--whereas in Apple's proposal it describes the primary placement direction. (That is, "a masonry layout, arranged into columns" uses the It also generalizes the property name and values for the "cross axis flow" property, called It otherwise matches @fantasai's earlier proposal wrt the other properties Some examples:
|
The CSS Working Group just discussed
The full IRC log of that discussion<bramus> fantasai: one of the key feeedback points from tag was to see better unificiation between grid and flexbox and grid auto flow and flex flow<bramus> … also grid auto flow aspect of the grid integrated proposal was pointed out by google to be awkard <bramus> … want to unify in a reasonable way <bramus> … some ideas in the issues <bramus> … tab had some variations on that <bramus> … jen created a presentation to walk us through all of it <bramus> florian: are you presenting a synthesis or a propsal? <bramus> jensimons: both <bramus> … one of the areas that is difffern betwwn both proposal is grid auto flow vs masonry direction and such <bramus> … tag reviewed that <bramus> … need more general properties <bramus> … flexbox: have direction, wrap and flow <ntim> jensimmons: let's go down this rabbit role <bramus> … grid; no directoin or wrap, but auto flow <bramus> … unified: maybe some item-* props? <bramus> … item-direction, item-wrap, item-pack, item-slack, item-flow, … <bramus> … leading to new ideas for grid and flex <bramus> … intersting things <bramus> … new homes for long standing feature requests <bramus> … things click together suddenly <bramus> … grid could gain nowrap <bramus> … to not define expcliit tracks and have all implicit tracks and have grid autocreate rows or cols <bramus> … flexbox gains dense packing <bramus> … it can backfill if items fit on a previous line that was already filled <bramus> … flexbox could get balance <bramus> … thanks to item-pack <bramus> … we could have something to balance the rows out a bit more <bramus> … few ideas <astearns> q? <bramus> … and there is item-pack: collapse <bramus> … (names TBD BTW) <bramus> … and item-flow as a shorthand <bramus> … with collapse we get into masonry <bramus> … had the "just use grid" idea <bramus> … or a new display value – masonry <bramus> … with item-pack we can unify that: item-pack: row collapse <lea> q? <lea> q+ <bramus> … high level questions <TabAtkins> q+ <bramus> … 1. do we want to pursue item flow and longhands, unifying grid-auto-flow? <bramus> … 2. do we want to use item-pack as the trigger for masonry style? <bramus> 3. (bikeshedding) <bramus> … 4. decide what row and column mean for item-direction <bramus> … does it mean flow of items or shape of layout? <bramus> … ** shows example with named area columsns ** <bramus> … in grid it flows back in rows with grid-auto=flow: row; <bramus> … with just use grid consistency is contained, but masonry-flow; coljunn describes the columns <bramus> … (example with named area rows) <bramus> … in the unified world … been discussing in context of masonry alone, but should be consistent for grid and flexbox too <bramus> … flex-flow: row wrap vs item-flow: row wrap; <bramus> … with grid its a bit different <bramus> … grid-auto-flow: row wrap; <bramus> … item-flow: row wrap; is a bit different <bramus> … (missed) <lea> `flow-direction` perhaps? <bramus> … adding one more paper cut adding to the syntax <bramus> … shape of the layout would be the <bramus> … in masonry style layout it becomes clearer <bramus> … is it item-flow: row collapse wrap; <bramus> … but I know there are people who dont like that <bramus> … so yeah, we have 4 questions <bramus> … question about shape vs flow is ??? might help to write out examples <iank_> q+ <oriol> q+ <astearns> ack lea <bramus> lea: was one of th epeople on tag. this is great. <bramus> … really like this <bramus> … obvs things to bikeshed, but right direction <bramus> … getting towards a simpler thing eventually <bramus> … and seems more powerful than what was previously proposed <ntim> q+ <bramus> … like how it leaves the template open – both rows and cols <bramus> … can still have masonry layou tand efine a specific row height and that still has an effect <bramus> … quite like that as well <bramus> … did suggest flow-direction instead of item-flow <bramus> … a bit weir dbut no strong opinion <bramus> … details can always be fleshed out <astearns> ack TabAtkins <bramus> … this is fantastic <bramus> TabAtkins: overall pretty happy with to move this functionality to item-* props <bramus> … am very happy with it <bramus> … one bit of objection which is item-pack property (after talking with ian) <bramus> … conflict between new behaviors needing to be defined for all things <bramus> … comes up here too <astearns> qq+ <bramus> … side bits of behavior needed <bramus> … item pack is more of a grab back of functinality <bramus> … triggers betwen normal and dens in grid <bramus> … swtich between grid and masonry <ntim> s/grab back/grabbag <bramus> ¬… and possibly turn flex in a ??? <bramus> … new piece of fn that needs to predefine things for deverything <bramus> … inclined to not do item-pack <bramus> … but accept all the rest <florian> q+ <bramus> astearns: i like the discipline of needing to consider all layouts that a new thing might need to adapt to <astearns> ack astearns <Zakim> astearns, you wanted to react to TabAtkins <bramus> … would still need to have an escape hatch where we could define values like flex-balance for item-pack that only work on flex until we figure out how to make balance work with the rest <bramus> TabAtkins: definitily possible <bramus> iank_: what tab said <bramus> … item pack is problematic for reasons that tab outlined <fantasai> +1 astearns <bramus> … historically done a poor job as implementers <bramus> … impltd these in block step (>) <bramus> … this hurts devs bc they cant feature detect <bramus> … stuff in alignment that was hard to ship <astearns> s/would still need to have/would still have/ <bramus> … and things like align-content: baseline <bramus> … historically done a bad job at these sort of complex things <bramus> … would be a bit happy with this (i am working on balance in flex). for grid its very complex <bramus> … dont want to see that we cant ship balancing for flexbox bc we have to figure out what it does for grid <bramus> … layout specific keywords <astearns> ack iank_ <bramus> … implementation cost would be huge otherwise <astearns> ack oriol <bramus> oriol: concern this seems to add fn that may add duplication or sth that may not really make sense in some layouts <bramus> … in grid you can assign expl positions for the items and nowrap does not make sense in that case <jensimmons_phone> q? <bramus> … idea about nowrap adding new cols <bramus> … with grid auto flow col you get that <jensimmons_phone> q+ <bramus> … is duplication <bramus> … will create more confusion <bramus> … for authors <bramus> … thing of item-pack to refer to the direction or shape of layout <iank_> q+ <bramus> … not using shape of layout would be confusing <bramus> … in grid auto flow that would a conflict was presented <bramus> … though inc ase of non masonry grid you get both rows and cols <bramus> … it does not apply well <bramus> … some of these may make sense, but would prefer to add them explcity for each layout <bramus> … not fond of defining everything in gereral because of duplication or conflicts <astearns> ack ntim <bramus> ntim: comment on item-flow <bramus> … flow representes how things are ordered, not shape <bramus> … so using shape would be confusing <astearns> ack fantasai <Zakim> fantasai, you wanted to comment on flow-direction, maybe <bramus> fantasai: agree 100% with what alan said <bramus> … i thinkk that idea of prefixing as we introduce new fn is an nice compromise to getting full allignment across layouts <bramus> … idea iof flow-direction <bramus> … (missed) <bramus> … use flow in 2 places now <bramus> … 1 is in various flow-???. its a suffix <bramus> … 2 is why this could not be a shorthand <bramus> …æ still have display: flow <bramus> … these props dont apply to that type of layout <bramus> … have 2 types of layout in CSS: flow layout <details missed> and a different kind of layout where you go down from parent to childrena and child is a chunk and gets manipulated as an item <bramus> … flex and grid are in one type of those <astearns> flow layout versus item layout <bramus> … dont want to get too deep into wraping this set of props with the flow word <bramus> … other that we use it as a shorthand to ??? <bramus> ; thought about prefixed <bramus> … item was 1 <astearns> (or item-in-a-container layout) <bramus> … thought about placement too <bramus> … went with item bc we use item in align-items <bramus> ; already have the concept of items <bramus> … and syntax for it <bramus> … open to naming of course <astearns> ack florian <bramus> florian: i like this <bramus> … and generally agree with alans comment <bramus> … re: ian <bramus> … not everyting is the same <bramus> … a bunhc o fthings need to work across layout modes <bramus> … like margin and gap and rows and align and ; <bramus> … if we dont do that its bad <bramus> … not sure its all of it though <bramus> … possibly around item-pack <bramus> … squeeze mode of flex <bramus> ; 2 proposals for what dense might mean for flex <bramus> … looks like grid, but there are some flexbox-specific traits to it <bramus> … when some of them are not diff appls of the same thing but related but diff concepts, then we get into the “you have to define all across all 3 modes” <astearns> ack fantasai <Zakim> fantasai, you wanted to react to florian <bramus> … theres at least a part tha tmakes sense across all layou tmodes but not all <bramus> fantasai: there was a proposal for dens epacking in flexbox (unrelated to this proposal) <bramus> … idea was to instead of fill line and wrap when it overflows, cram in last items and shrink it <bramus> … first edition of that tagged that behavior to the dense keyword <bramus> florian: that is the dens keyword? <bramus> fantasai: no <bramus> … the thing on the slide is different <bramus> TabAtkins: oh, the slide is not up to date I see <bramus> fantasai: so, dense packing for flex should be same concept as grid to fill in the gaps <bramus> … slack is cram things in <astearns> q+ <bramus> … for masonry its which col is the shortest <astearns> ack fantasai <Zakim> fantasai, you wanted to clarify this <dholbert> +1 to florian's concern, particularly for cases where the relative utility and/or implementation-complexity of the the same keyword is substantially different between different layout modes (which risks implementors shipping the feature for one layout mode but not others, as Ian noted) <bramus> …for flex its close enough to fitting and ifts close to 10px cram it in <bramus> … fudge distance <bramus> … say how much you want to cram in <bramus> florian: and in grid? <bramus> TabAtkins: nothing, not possible there <bramus> fantasai: the only keywords tied to 1 layout in this set are collapse for grid and balance only for flexbox <bramus> florian: makes sense <bramus> … lets try not to overfit this <bramus> … would be a mistake <bramus> … forcing that would be bad <bramus> TabAtkins: strong agree <bramus> … that is why i am happy with the current form <astearns> ack jeroen <astearns> ack jensimmons_phone <bramus> jensimmons: an early reaction was to not do pack <bramus> … and folks were sort of bummed out about doing balance <bramus> … think that creating balance – doing balance keyword at all … can be a later version <bramus> … exciting to present the propposed thing where it paints the future <bramus> … dense already have for grid, can figure out what it does for flex <bramus> … dont have to ship right away <bramus> … ipml detail <florian> s/lets try not to overfit this/lets try not to overfit this, by forcing the creation of different-but-analogus options in other layout modes just because we now have a keyword that could trigger them <bramus> … collapse though is the toggle for masonry <fantasai> s/detail; let's think about what's good for the Web/ <bramus> … skipping all of item pack <bramus> TabAtkins: there’d be a diff switch <florian> s/would be a mistake/would be a mistake, because it would force synchronous shipping of essentially unrelated (even if similar) functionality <bramus> jensimmons: exciting things to add pack and slack here <bramus> … (missed) <astearns> ack iank_ <bramus> iank_: one thing, handling balance <ntim> jensimmons: what's exciting is the unified way to control the flow for authors <bramus> … imminently would be good <bramus> … in the next month or so i’ll prolly do some research <bramus> … would like to solve soon <TabAtkins> concretely, instead of item-pack, we could keep the existing `grid-auto-flow`, add `flex-pack: normal | dense`, add balance to `flex-pack`, and trigger masonry layout via `display: masonry` or another new property. <bramus> jensimmons: it is cool <bramus> iank_: yep! <astearns> ack astearns <bramus> astearns: response to florian but i think jen covered it already <bramus> … this new stuff is not the new item in containers property set to rule them all <fantasai> I think having the unified properties is cooler than introducing more one-offs <bramus> … this is a support mechanism that we use when appropriate to put them together where it makes sense <bramus> … still lmost likely to have values with layout prefixes <bramus> … spefific to those modes <bramus> … that dont make sense into this other thing <fantasai> s/values/values and properties/ <bramus> … but q is how do the existing or future layout props with these new item things? <bramus> fantasai: this propopsal is meant to be replacing the existing grid-auto-flow and flex-flow props <bramus> … is it an alias or how does it interact? thinking about making it a shorthand <bramus> … 3 diff directions <bramus> … alias, keyword magic, or shorthand <bramus> … its not gonna rule all of layout controls, its this set of stuff to represent common concepts for all layout modes <bramus> … gives them a unified home to live in <bramus> … like flex property is not gonna be ported to grid or stuff <bramus> jensimmons: think of things like alignment <bramus> … does 1 thing <bramus> … do they wrap or pack <bramus> … its not about the layout at all, its about the item behavior <astearns> s/likely to have values/likely to have values and properties/ <bramus> … when brendan and I came up with this, these props could alias other props <TabAtkins> q+ <bramus> … but proplem with that we could end up with strange behavior where a strey prop starts to have effect <bramus> … would expect that the flex props dont escape that <bramus> … (missed) <bramus> … authors can still grab to the flex and grid props <astearns> +1 to not aliasing, that seems too constraining (and dangerous) <bramus> … if we wnated in the future to define balance only for flex, then we can stick to that <astearns> ack TabAtkins <bramus> TabAtkins: this set of fn (with or without item pack) is sufficiently generic or useful dfns that they will be usable for prolly all future layout modes <bramus> … knowing where it flows is always gonna be present <bramus> … this is a good design set of pieces that will work for future layout modes <bramus> … there should be direct analoging behavior between everything <bramus> iank_: item-pack is arguably the one that violates that the most <bramus> … bheaviors are diff between the modes <bramus> … thats the one <bramus> fantasai: dont think this is the case <bramus> … normal is normal <bramus> … dense is analogus between flex and grid <bramus> TabAtkins: but not masonry <bramus> fantasai: but it also has dense <TabAtkins> nm, masonry does have dense <bramus> … collapse gonna set out next separtely <dholbert> q+ <bramus> … leftover one is balance. masonry is inhernetly that <bramus> … only 1 keyword <bramus> iank_: there is also nowrap <bramus> fantasai: there is a dfn for nowrap that makes sens for grid <bramus> … (grid) <TabAtkins> The set of property names/values from mine and fantasai's compromise, btw, are: <TabAtkins> item-track: auto | row | column | row-reverse | column-reverse <TabAtkins> item-cross: [ [ nowrap | wrap ] || [ normal | reverse ] ] | wrap-reverse <TabAtkins> /* wrap-reverse is a combination of wrap and reverse, for convenience */ <TabAtkins> item-pack: normal | dense || [ collapse | balance ] <TabAtkins> item-slack: normal | <length-percentage> | infinite <TabAtkins> item-flow: <'item-track'> || <'item-cross'> || <'item-pack'> || <'item-slack'> <bramus> … this lets you set it at a higher level on the container <bramus> … and that gets you similar to a nonwrapped flex box where you cerate tracks and apply certain track sizing mutations on it <bramus> … and its a very obvs straigth way to get that <bramus> … in grid you use grid-row: 1 <bramus> … but now you can add it at a higher level <bramus> … not critical to add now, but i think it makes sens <astearns> ack dholbert <bramus> … not higghly reqd feature but straightforward to describe and implement <bramus> dholbert: share ian’s concerns <bramus> … in particular feels dense is well defined for grid but not sure i like the behavior for flex <bramus> … seems like that behavior would be unpredicatable as space grows or shrinks <bramus> … with rows and small items snapping down to a later row <bramus> … you would get sth that looks like masonry with a lot of tiny items attached to the end of each line <iank_> i also wonder a subset of requests for `flex-wrap: dense` was people really wanting `flex-wrap: balance` <bramus> … would do the job to fill a line densely, bu tskeptiacal if that is what authors want <bramus> … feels like dense is agrid thing that gets backfilled into flexbox <bramus> … on the flip side it seems like balance might needed to be backfilled to grid <bramus> … worried about being forced to implement both in order to ship 1 <TabAtkins> note: we can defer the item-pack property for discussion in another issue or later meeting. it would just remove one possible "masonry" switch <bramus> astearns: see tab’s note in irc: can defer dense <bramus> TabAtkins: if we end up to not put dense into item-pack and only had collapse then it would not be a good name for it <bramus> … but does not prevent us from doing a diff switch from now and later have item pack take on those duties <bramus> astearns: aside from some details, i hear general enthusiasm? <bramus> … shall we resolve to continue to work on this general item-* prefix proposal? <bramus> … seeing thumbs up <bramus> … concerns? <bramus> TabAtkins: and ideally resolve in upcoming telecons soon <TabAtkins> items-in-container layout modes <bramus> astearns: not hearing stuff, prop resolution is to continue to work on the item-* props as a set of switches for all items-in-container layout modes <florian> +1 <kbabbitt> 👍 <bramus> RESOLVED: Continue to work on the item-* props as a set of switches for all items-in-container layout modes <bramus> fantasai: curerntly to be shoved in the grid-3 spec <bramus> jensimmons: could end up using its own <bramus> florian: can move eventually <ntim> ntim: could use css-display <bramus> PROPOSED RESOLUTION: Put it in grid-3 for now, with intention to move <bramus> RESOLVED: Put it in grid-3 for now, with intention to move <ntim> <3 |
@fantasai and I wrote up the item-flow idea into the Grid 3 spec (as an appendix) and republished a Working Draft. We marked all the open questions as issues in the draft. We encourage people to take a look and continue the conversation here. |
@tabatkins one typo: in sent PR |
The TAG response to the masonry syntax issue asked us to look into unifying controls for our layout modes, calling out
grid-auto-flow
andflex-flow
(flex-direction
+flex-wrap
) in particular. Apple looked into this, and we have the following syntax proposal:Introduce
item-flow
aliased to bothflex-flow
andgrid-auto-flow
and defined as a shorthand for the following properties:item-direction
(also aliased asflex-direction
)row | column | row-reverse | column-reverse
item-wrap
(also aliased asflex-wrap
)auto | wrap | wrap-reverse | nowrap
auto
computes to eitherwrap
(for Grid) ornowrap
(for Flexbox)nowrap
in Grid would mean autoplacement adds implicit tracks instead of wrapping to the next rowitem-pack
normal | dense
dense
packing for Flexbox would mean that instead of breaking lines as soon as an item can’t fit, we try to cram in one more, triggeringflex-shrink
behavior instead offlex-grow
on that line. See [css-flexbox-2] Add flex-wrap: dense #3071.item-pack: normal | dense || [ collapse | balance ]
could allow:collapse
triggering a masonry-style layout for Grid (see [css-grid-3][masonry] Masonry Syntax Debate #11243).balance
opting into balanced line-wrapping for Flexbox ([css-flexbox-2] Add flex-wrap: balance; #3070).item-slack
<length-percentage>
masonry-slack
property. See [css-grid] Decide on a name formasonry-slack
#10884.10px
slack would mean “if there’s only 10px overflow on this line when adding the next item, cram it in anyway, as squeezing in an extra 10px is no big deal”.10px
slack would mean “if there’s only 10px empty space left on this line, don’t try to cram in the next item, that’s too much cramming”.Caveats: This would make
flex-flow
andgrid-auto-flow
cascade as a single property, which is a change in behavior and therefore could have some Web-compat impact.Variations: This is our initial sketch, but there are some variations we’ve considered:
item-slack
should be a longhand ofitem-flow
or not: it's often nice to put it in theitem-flow
shorthand, but it might also make sense for it to cascade independently.item-
prefix. Ideas we’ve come up with so far includeitem-
,box-
,items-
, andplacement-
. (We’re drawing the “item” terminology from the specs and from thealign-items
property.)Thoughts?
The text was updated successfully, but these errors were encountered: