Re: [csswg-drafts] [css-conditional] [css-contain] Fleshing out @container queries with single-axis containment (#5796)

The CSS Working Group just discussed `@container queries with single-axis containment`, and agreed to the following:

* `RESOLVED: Define container queries in css-contain-3, editors L2 editors + Miriam`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: @container queries with single-axis containment<br>
&lt;ChrisL> git?<br>
&lt;astearns> github: https://github.com/w3c/csswg-drafts/issues/5796<br>
&lt;fantasai> miriam: Wanted to take the time to walk through presentation<br>
&lt;miriam> https://slides.oddbird.net/csswg/f2f2102/<br>
&lt;fantasai> miriam: slides here<br>
&lt;fantasai> miriam: A number of use cases around container queries<br>
&lt;fantasai> miriam: a few links ppl can follow for more complex and simpler use cases<br>
&lt;fantasai> miriam: with MQ, we can change all instances of an element and will all change based on viewport<br>
&lt;fantasai> miriam: breakpoint established, create a new layout for e.g. this card<br>
&lt;fantasai> miriam: but even if those cards are in different parts of layout where they have different space available to them, will change based on viewport<br>
&lt;fantasai> miriam: don't want to respond based on viewport though, want to respond based on size of container<br>
&lt;fantasai> miriam: 2 proposals brought up last year<br>
&lt;fantasai> miriam: dbaron's @container proposal<br>
&lt;fantasai> miriam: and bkardell's switch()<br>
&lt;fantasai> miriam: interesting tradeoffs, handle different cases<br>
&lt;fantasai> miriam: not necessarily competing<br>
&lt;fantasai> miriam: but main idea, I'm following up on dbaron's proposal<br>
&lt;fantasai> miriam: it covers a lot of the use cases but requires establishing containers and being able to establish containers<br>
&lt;fantasai> miriam: and have cards inside containers that can respond to containers they're in<br>
&lt;fantasai> miriam: container can have nested containers<br>
&lt;fantasai> miriam: each card is rsponding to its own container, even as size of window changes<br>
&lt;fantasai> miriam: so to make that work, have to describe container itself<br>
&lt;fantasai> miriam: to establish containers in this proposal<br>
&lt;fantasai> miriam: what's required is having size and layout containment<br>
&lt;fantasai> miriam: byt applying size and layout containment, we can establish them as containment contexts<br>
&lt;fantasai> miriam: a bit of a problem here also noted by dbaron<br>
&lt;fantasai> miriam: size containment is very invasive<br>
&lt;fantasai> miriam: if always have to explicitly set height and width, doesn't work for many use case<br>
&lt;fantasai> miriam: need 1D containment<br>
&lt;fantasai> miriam: developing prototype to prove that can work<br>
&lt;fantasai> miriam: for inline axis<br>
&lt;fantasai> miriam: for block axis, a bit more complicated<br>
&lt;bkardell_> q+ if there are use cases for block axis even?<br>
&lt;fantasai> miriam: if that doesn't work, then width/height can't be made to work because can be iether inline or block<br>
&lt;fantasai> miriam: most essential however is inline-size<br>
&lt;fantasai> miriam: dbaron's syntax looks like this<br>
&lt;astearns> zakim, open queue<br>
&lt;Zakim> ok, astearns, the speaker queue is open<br>
&lt;fantasai> @container &lt;selector> (&lt;query>) { &lt;rules> }<br>
&lt;fantasai> miriam: If we have to be explicity about which containers we're looking at, less flexible<br>
&lt;bkardell_> q+ if there are use cases for block axis even?<br>
&lt;fantasai> miriam: really what we want is to say h2 or card can respond to whatever container it's in, and wherever we put it can respond<br>
&lt;bkardell_> q+ i<br>
&lt;fantasai> miriam: modular that way<br>
&lt;fantasai> miriam: proposal is to remove the selector block<br>
&lt;fantasai> miriam: just describe the query, not the container that it will match against<br>
&lt;fantasai> miriam: and instead we use the DOM tree to find the container that we're in<br>
&lt;bkardell_> q- i<br>
&lt;bkardell_> q+<br>
&lt;fantasai> miriam: so each card looks up its ancestors to the first container that has the limits we're querying<br>
&lt;fantasai> miriam: code example [slide]<br>
&lt;fantasai> @container (min-width: 40ch) { ... change grid template ... }<br>
&lt;fantasai> miriam: that would work in any container<br>
&lt;fantasai> miriam: h2 is good example of why this needs to be very modular<br>
&lt;fantasai> miriam: might want to use h2 in any container, not defining specifically how one component work<br>
&lt;fantasai> miriam: tree can be nested however<br>
&lt;fantasai> miriam: if both are h2, they each look up their nearest ancestor container and respond to size of that container<br>
&lt;fantasai> [shows tree]<br>
&lt;fantasai> miriam: rules in @container apply when aancestor with appropriate containment, and query applies<br>
&lt;fantasai> miriam: query against actual values on element, not the viewport, can look at e.g. actual size of the element<br>
&lt;fantasai> s/size/font size/<br>
&lt;fantasai> miriam: Could we have queries that respond to font size on container / element?<br>
&lt;fantasai> miriam: containment is external<br>
&lt;fantasai> miriam: so can't query e.g. size available to you in a grid track, always querying the element itself<br>
&lt;fantasai> miriam: that's one place where the switch proposal would be a bit more powerful<br>
&lt;fantasai> miriam: but this is also something we can work around by adding an intermediate layer<br>
&lt;fantasai> miriam: add an element that's a container as the grid item, put the card inside<br>
&lt;fantasai> miriam: some talk of alternate syntax based on pseudo-class<br>
&lt;fantasai> miriam: :container(query)<br>
&lt;fantasai> miriam: Some downsides and some positives<br>
&lt;fantasai> miriam: adding in nesting, becomes quite similar<br>
&lt;fantasai> miriam: this provides a few use cases that the @container wouldn't<br>
&lt;fantasai> miriam: a lot of other open questions<br>
&lt;fantasai> miriam: some of them already have issues, some don't<br>
&lt;fantasai> miriam: we can dig into any of that later<br>
&lt;fantasai> miriam: links to explainer, issue, TAG review<br>
&lt;fremy> q+<br>
&lt;Rossen_> ack bkardell_<br>
&lt;astearns> https://github.com/oddbird/css-sandbox/blob/main/src/rwd/query/explainer.md<br>
&lt;fantasai> bkardell_: I think this is great<br>
&lt;ChrisL> q+<br>
&lt;fantasai> bkardell_: question when presenting, are there known use cases for block direction?<br>
&lt;fantasai> miriam: think would be similar to viewport height use cases<br>
&lt;fantasai> miriam: those are rare<br>
&lt;fantasai> bkardell_: I found use cases for thing you're doing first, easier part with very strict containment<br>
&lt;fantasai> bkardell_: plenty for inline-axis<br>
&lt;fantasai> bkardell_: much more than I thought there were initially<br>
&lt;fantasai> bkardell_: I actually agree with you that nesting is super-important to work out for a whole bunch of things<br>
&lt;astearns> tag review: https://github.com/w3ctag/design-reviews/issues/592<br>
&lt;fantasai> bkardell_: we're making a lot of choices differently; nesting is big deal, one of the biggest things we could work on<br>
&lt;fantasai> bkardell_: would like us to prioritize<br>
&lt;fantasai> bkardell_: also want to express that this is awesome, and would love to coordinate some more between Igalia and Google who are doing this work<br>
&lt;fantasai> bkardell_: to make alignments<br>
&lt;Rossen_> q?<br>
&lt;fantasai> bkardell_: some similarities in internals that would be good to sort out<br>
&lt;fantasai> bkardell_: some opportunities to sugar things as well<br>
&lt;Rossen_> ack fremy<br>
&lt;fantasai> fremy: very good proposal, like the feel of it<br>
&lt;fantasai> fremy: I am wondering if makes sense to say that everything containing something becomes a container<br>
&lt;fantasai> fremy: sometimes you need that for perf reasons, be weird if that also changes layout in CSS<br>
&lt;fantasai> fremy: maybe add a new value to get the behavior<br>
&lt;fantasai> fremy: Something that you can do with this that can't otherwise<br>
&lt;fantasai> fremy: can use these containers to set display:none to things<br>
&lt;fantasai> fremy: which would change counters etc.<br>
&lt;fantasai> fremy: maybe we need a bit more containment that just size?<br>
&lt;fantasai> fremy: Unsure also about how easy to implement<br>
&lt;fantasai> miriam: Anders and Rune have been working on that, idk if they're here<br>
&lt;fantasai> fremy: globally I like the idea, if I make one change to proposal, if we don't use selectors about what is a container, then need to have an explicit way to indicate which is a container<br>
&lt;fantasai> miriam: solution you mentioned, of explicit value for contain, that would address the issues you raised<br>
&lt;fantasai> chrishtr: was this about counters?<br>
&lt;fantasai> miriam: potential of accidentally creating a container somewhere<br>
&lt;fantasai> miriam: I haven't found use cases where you want to skip a containment box<br>
&lt;fantasai> miriam: but being more explicit can be handled by a specific value<br>
&lt;fantasai> miriam: also way it relates to counters, might need style containment<br>
&lt;fantasai> miriam: bulky if contain: inline-size layout style<br>
&lt;fantasai> miriam: maybe can be combined into that explicit value<br>
&lt;fantasai> fremy: exactly what I had in mind<br>
&lt;Rossen_> ack ChrisL<br>
&lt;fantasai> leaverou2: I wanted to say, 2 syntaxes proposed at-rule vs pseudo-class<br>
&lt;fantasai> leaverou2: is pseudo-class actually doable?<br>
&lt;fantasai> leaverou2: they match at an earlier stage, can't match at computed value time<br>
&lt;fantasai> TabAtkins: generally speaking yes<br>
&lt;argyle> q+<br>
&lt;fantasai> TabAtkins: theoretically don't need to if there's not a computation loop<br>
&lt;fantasai> TabAtkins: could do another pass later, but usually want to avoid<br>
&lt;fantasai> leaverou2: thought significant pushback against 2 passes<br>
&lt;fantasai> fremy: but in this case we need it anyway<br>
&lt;fantasai> leaverou2: if both fair game, I think pseudo-class syntax allows combining with other selector criteria if both doable<br>
&lt;fremy> s/fremy/florian/<br>
&lt;Rossen_> ack argyle<br>
&lt;fantasai> argyle: so many fun use cases, breakdown so good<br>
&lt;fantasai> argyle: one of the difference between switch and container syntax<br>
&lt;fantasai> argyle: question of what am I targetting<br>
&lt;fantasai> argyle: switch can know its own size<br>
&lt;fantasai> argyle: that's an important use case<br>
&lt;fantasai> argyle: container might have 20 items in it, what's the space I'm given?<br>
&lt;fantasai> argyle: not sure how to wrestle with those thoughts<br>
&lt;fantasai> argyle: pseudo-class selector might be opportunity to specify which container<br>
&lt;fantasai> argyle: what if want immediate parent?<br>
&lt;fremy> btw, this won't require just two pass, it would require one pass per element, but each pass might require a layout pass in between<br>
&lt;una> +1 to the individual container<br>
&lt;fremy> I should just say that on call, nevermind<br>
&lt;fremy> q+<br>
&lt;fantasai> miriam: wouldn't be immediate parent, would be nearest contained parent<br>
&lt;fantasai> argyle: what if you want container a few steps up?<br>
&lt;fantasai> miriam: Question has come up, but haven't come up with any use cases for it<br>
&lt;fantasai> miriam: wrt switch, agree, that's why these are parellel solutions<br>
&lt;fantasai> miriam: with switch(), element queries itself, but is limited in how much can be changed<br>
&lt;fantasai> miriam: can't change width based on width<br>
&lt;fantasai> miriam: limited properties, but querying actual self space<br>
&lt;fantasai> miriam: but with this one querying something external, but can change anything inside it<br>
&lt;fantasai> miriam: address differnet use cases with a bit of overlap, both worth pursuing<br>
&lt;Rossen_> q?<br>
&lt;Rossen_> ack fremy<br>
&lt;fantasai> fremy: Wrt lea's multiple passes<br>
&lt;fantasai> fremy: You don't need to have multiple passes<br>
&lt;fantasai> fremy: need one pass for element<br>
&lt;fantasai> fremy: but need to do layout<br>
&lt;fantasai> fremy: [missed]<br>
&lt;fantasai> fremy: One case I feel a big issue<br>
&lt;fantasai> fremy: proposal of containing only in one dimension<br>
&lt;una> q+<br>
&lt;fantasai> fremy: that's the only case you have to do layout and then styling inside container<br>
&lt;fantasai> fremy: then have to do layout of everything again<br>
&lt;fantasai> fremy: that could change size of container<br>
&lt;fantasai> fremy: that one is much more tricky, and could do layout many times<br>
&lt;fantasai> fremy: multiplied by nesting of containers<br>
&lt;florian> s/[missed]/you only need to layout outside the container in one pass, and inside in the second pass, so it's not really two passes/<br>
&lt;astearns> s/[missed] you just have to stop and start at container boundaries (instead of two pass)<br>
&lt;fantasai> fremy: bigger problem, not easy to solve<br>
&lt;Rossen_> q?<br>
&lt;fantasai> fremy: if you have only one, unsure if there's any restriction that we don't have to do the layout of everything in a nested way, so maybe file an issue that and think about it<br>
&lt;fantasai> miriam: issue opened already<br>
&lt;fantasai> Rossen_: OK, good presentation, what do you want to ask WG?<br>
&lt;fantasai> miriam: support for going forward, and feedback like I'm getting<br>
&lt;fremy> s/[missed]/between the styling passes<br>
&lt;fantasai> una: For slide 15, you have great diagram of initial container and then blue and pink items wider and vertical items<br>
&lt;fantasai> una: theoretically same component<br>
&lt;fantasai> una: What I see is that you set containment once, on parent<br>
&lt;fantasai> una: each individual element querying?<br>
&lt;fantasai> miriam: matched with this code [other slide]<br>
&lt;Rossen_> ack una<br>
&lt;fantasai> miriam: containment on sidebar, main, grid-items<br>
&lt;fantasai> miriam: those 5 containers<br>
&lt;fantasai> miriam: single card component appears in each container<br>
&lt;fantasai> miriam: each one querying its most immediate container<br>
&lt;fantasai> una: so containment on immediate parent ,and cna nest<br>
&lt;fantasai> una: ancestor. You pick the closest ancestor with container<br>
&lt;fantasai> una: in theory, could you set containment on body?<br>
&lt;fantasai> una: and have on any child<br>
&lt;fantasai> miriam: it would act similar to a media query<br>
&lt;emilio> q+<br>
&lt;fantasai> miriam: main advantage would be responding to actual font size not environment font size<br>
&lt;fantasai> miriam: if ancestor ...<br>
&lt;bkardell_> "root container"<br>
&lt;fantasai> miriam: no container, maybe fall back too root to be smarter<br>
&lt;fantasai> una: is it necessary to set containment on children?<br>
&lt;fantasai> miriam: in order to query something's width, we have to set containment on it<br>
&lt;fantasai> miriam: in order to avoid the loops<br>
&lt;fantasai> miriam: if only set on body, we can't query the width of the grid item<br>
&lt;Rossen_> ack emilio<br>
&lt;fantasai> emilio: There were some versions of proposal that support selectors<br>
&lt;fantasai> emilio: what happens with Shadow DOM there is a bit weird<br>
&lt;fantasai> emilio: stuff like ancestors might not even be in rendering tree at all<br>
&lt;fantasai> emilio: but might be DOM ancestor, ancestor of shadow host<br>
&lt;fantasai> emilio: descendant combinators wouldn't work<br>
&lt;fantasai> emilio: that probably involves more complexity<br>
&lt;fantasai> emilio: we can probably come up with some reasonable thing to do, but...<br>
&lt;Rossen_> q?<br>
&lt;fantasai> Rossen_: hear a lot of support and excitement about this<br>
&lt;fantasai> Rossen_: anyone opposed to adopting it?<br>
&lt;fantasai> chrishtr: Would be new module, not addition to existing?<br>
&lt;leaverou> +1 from Chris and Lea<br>
&lt;argyle> q+<br>
&lt;fantasai> miriam: potential for it to happen in Containment and Conditional, or could be its own<br>
&lt;fantasai> argyle: pushback I've heard is that 1D doesn't sound as useful as 2D?<br>
&lt;fantasai> argyle: if I can't know the width and height of something together, how can I make a good decision?<br>
&lt;fantasai> miriam: you can, but would have to contain both<br>
&lt;fantasai> miriam: you have to contain whichever dimension you query<br>
&lt;Rossen_> ack argyle<br>
&lt;fantasai> miriam: but containing both dimensions doesn't address a lot of use cases<br>
&lt;fantasai> miriam: block-only containment is hard, we're unsure if we can do it<br>
&lt;fantasai> Rossen_: ...<br>
&lt;fantasai> florian: If we want to pursue this, need to pursue 1D containment on its own<br>
&lt;fantasai> florian: that goes in css-contain<br>
&lt;fantasai> florian: but needs further work<br>
&lt;fantasai> florian: rest of it [missed]<br>
&lt;fantasai> miriam: that's being worked on at Chrome<br>
&lt;fantasai> Rossen_: Spec-wise, where are we in 1D containment<br>
&lt;fantasai> florian: discussion in GH that it's likely to be possible, but that's as far as we got<br>
&lt;Rossen_> q?<br>
&lt;fantasai> bkardell_: 1 issue with some back and forth, that's all<br>
&lt;fantasai> bkardell_: I agree would make sense that it goes there, and is prerequisite for the rest<br>
&lt;fantasai> bkardell_: but no reason not to figure out where the rest of it goes<br>
&lt;fantasai> bkardell_: rest of it, if we put it in a spec, would be dependent on 1D containment<br>
&lt;TabAtkins> fantasai: My suggestion would be to put the whole thing as Contain 3, and we can figure out exactly where bits go later as we work on it.<br>
&lt;TabAtkins> fantasai: Either way, 1d-containment needs to be in Contain<br>
&lt;Rossen_> ack fantasai<br>
&lt;TabAtkins> fantasai: Draft as a diff spec for now, you can pull things back if you need, otherwise l3 will be all CQs<br>
&lt;bkardell_> is that where we would want to put switch too?<br>
&lt;nicole> It's so exciting that this is happening. :)<br>
&lt;fantasai> florian: Unsure if contain-2 is that close to CR, but also not opposed to what fantasai said<br>
&lt;una> +1 to the excitement :D<br>
&lt;bkardell_> +1 excitement<br>
&lt;jensimmons> +1<br>
&lt;argyle> 🎉<br>
&lt;leaverou> +1 excitement!<br>
&lt;fantasai> Rossen_: Proposal here is to add this to css-contain-3<br>
&lt;fantasai> Rossen_: Only question I have is, who works on this besides Miriam?<br>
&lt;tantek> +1 progress!<br>
&lt;fantasai> florian: I'm already editing level 1 and 2, so happy to tag along with 3<br>
&lt;fantasai> florian: will focus on containment rather than querying, but<br>
&lt;fantasai> Rossen_: so level 2 editors + Miriam<br>
&lt;bkardell_> q+<br>
&lt;una> WOOO!<br>
&lt;chrishtr> Excellent!!!!!<br>
&lt;fantasai> RESOLVED: Define container queries in css-contain-3, editors L2 editors + Miriam<br>
&lt;nicole> 🎉<br>
&lt;bkardell_> q- I guess if it is going to not happen, but my question above seems relevant<br>
</details>


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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 11 February 2021 22:54:47 UTC