-
Notifications
You must be signed in to change notification settings - Fork 682
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-values] Conditional syntax for if()
#8446
Comments
I think the syntax proposed by the unofficial draft makes sense. Where it matters, style queries, container range queries, and the proposed inline if all overlap in how they understand (or hope to understand) comparison operators, parenthesis, and logical combinators. From there, each has it's own constraints - and I don't see any reason the constraints of one should impact the functionality of another. |
Once we have style container queries with extended style query syntax, do we still need to have Web components always have a container and variables will be always applied to the container element. As far as I see, |
The inline
|
To add to what @mirisuzanne said above, even with web components, you often want to style the element itself. Not everything is done in shadow DOM. |
Would this proposed display: if(--hidden: 1, none, flex); |
@benface yes, except the syntax would look more like |
Great, thank you @LeaVerou. So it sounds like this will allow us to control the value of multiple properties (including custom properties) from a single property... effectively replacing the "space toggle" hack? If so, I'm all in. |
Yes. |
Over the years there have been several issues and proposals on an inline
if()
function:My understanding is that we generally have consensus that we need this, but the devil is in the details.
Now that style container queries are shipping, inline
if()
is the only missing piece for being able to use higher level custom properties to customize web components, and it would be nice if they could ship somewhat close to each other.It seems that one of the primary blockers for
if()
is syntax, and especially the syntax of the condition itself.Condition
I see two directions for this:
a) We adopt the style container query syntax wholesale, and accept
<style-query>
as the condition.b) We define a new syntax in terms of comparing values, similar to what css-conditional-values unofficial draft was trying to do.
The upside of (a) is consistency and learnability, it's much easier for authors to learn one conditional syntax for both places.
The upside of (b) is that it's strictly more powerful. Since
if()
is used on a specific property, resolving all values is possible, so the constraints of the container query syntax don't really apply. Also, there are plans to extend<style-query>
to arbitrary properties, which may not be desirable forif()
.Other syntax considerations
What should we use to separate the condition from the iftrue and iffalse values? In my original design I used commas, but this means we cannot use any values that contain commas, so the direction
mix()
,first-supported()
have been going with semicolons as the separator seems preferable.cc @tabatkins @mirisuzanne
The text was updated successfully, but these errors were encountered: