-
Notifications
You must be signed in to change notification settings - Fork 668
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-contain-3] Define a syntax for style-based container queries #6396
Comments
We can't do |
@andruud that's right, we have to work around features like |
Agenda+ to add style queries. Proposal:
Note: @mirisuzanne and I drafted this proposal into the ED at https://drafts.csswg.org/css-contain-3/#style-container in f209f6a |
Nice. So you opted to not have |
@andruud We absolutely need to think through the behavior we want here for future syntax. I think we also might want to consider defaulting queries without a function to be |
@andruud |
@fantasai My point was that as currently proposed, the browser would "choke on it". 🙂 |
I am generally happy with the proposal, but was wondering:
This would allow to use custom properties that are space-separated lists of toggles, then use Just food for thought. |
The CSS Working Group just discussed
The full IRC log of that discussion<dael> Topic: [css-contain-3] Define a syntax for style-based container queries<dael> github: https://github.com//issues/6396 <fantasai> i/Topic/astearns: Resolved, unless someone comes back with a strong opinion later <dael> miriam: style based container queries are idea we can look at container and check computed value of a property and query that and change things for desc for value of property <dael> miriam: Mostly used for high level custom prop where have set of values, check on parent, and based on query make changes <dael> miriam: Other use cases, that's main <dael> miriam: fantasai and I added proposed syntax to spec. <dael> miriam: At this point it uses normal property syntax so : between. Some issues about supporting range syntax or attribute selector syntax <dael> astearns: Opinions? <dael> TabAtkins: Defining equality as something we haven't done in css. Will require some work. Wait, we have equality for transition. Ignore me. On to fantasai <astearns> ack fantasai <astearns> s/TabAtkins.*$// <dael> fantasai: We talked about potentially having range. Was hesitant b/c if want to catch range of values for width you would not be able to do with style query b/c can only compare length but not auto or other keyword-based width values <smfr> q+ <dael> fantasai: Reason I didn't want to add range syntax for computed style is b/c will add confusion. Some point in future may have use cases to add but best for now to keep to equal or not <astearns> ack smfr <dael> fantasai: Mostly will do lengths and use container queries for things with sizes <dael> smfr: A bit confused. Understood container queries limited to elements with certain values on contain property. <dael> smfr: Feature here sounds like could be independant of contain property. Features here apply whe not using? <dael> miriam: Resolved earlier to use sytax to establish containers. Then browser establishes containement behind the scenes. This would rely on container type that doesn't apply containment in background <dael> smfr: Makes sense <dael> astearns: Other comments? <dael> astearns: My understanding is we're looking for resolution to accept what's in ED and leave range syntax and attributes to future issues <dael> miriam: wfm <dael> astearns: fremy it was your comment about attributes. Okay to ask you to open new issue? <dael> fremy: Isn't it same issue but delay to new level? I can open a new one if people prefer <dael> fantasai: Yes please <fremy> fantasai: ok, will do <dael> astearns: Prop: Accept proposal in ED. Split range syntax and attributes to new issue <dael> RESOLVED: Accept proposal in ED. Split range syntax and attributes to new issue |
Yeah, @fantasai, I think you misunderstood @andruud - we need In this context, I think we should use the three-value boolean that MQs does. |
@tabatkins Does this need to be re-opened and addressed? |
Will style-based container queries support elements styled with data-attributes please? |
No, that's just an arbitrary string as far as the browser is concerned. If you then manually apply that string to the |
My bad explanation sorry, I am currently using them as utility classes with media queries.
Would the new syntax recognise the data-attribute and its value as a style?*
*not sure if this would be the correct syntax? |
for it to respond to your style you'd have to query the style like so: .feature__menu {
& .feature-layout__group {
container-type: style;
...
@container style(justify-content: space-between) {
/* add Extra Styles that only apply when this element has justify-content set to space-between */
...
}
}
} because your existing system is adding If you need to add more styes only based on the data attribute selector though, you can add more styles the same way you're already adding [1] unless something else will set justify-content to space-between too |
@JaneOri Finally got around to testing this but with no luck: |
@deanleigh no one has implemented style container queries at this point, even in a prototype - so there's no testing to be done. But |
Sorry @mirisuzanne I pasted as a reply to an old post where I mistakenly thought style would work like more like :where() |
no worries! |
Container Queries should allow us to write conditional rules based on the computed styles of an ancestor container, since, according to @andruud:
I'm branching this issue off from #5989 (What container features can be queried?) and #5624 (Higher level custom properties that control multiple declarations) – to specifically discuss syntax for querying a container's computed styles as part of css-contain-3.
Several of the use-cases mentioned so far (actual syntax TBD):
(background-color = red)
or(--pill = on)
(--is-small)
(50vw < 400px)
or(--small > 50vw)
And some of the issues to address:
@property
%
lengths) evaluate differently on different properties. What do they mean in a query?I'd like to get more use-cases and issues documented here, so that we can work through them in more detail.
The text was updated successfully, but these errors were encountered: