Re: [csswg-drafts] [css-values?] What is the MVP for inline conditionals on custom properties? (#10064)

Yeah, at least if we choose the path forwards carefully, it should be easy. That carefully chosen path could be something like:

 * When you see an `if()` in a declaration's value, you get the "assumed valid at parse time" behavior we currently get when there's a `var()` or `env()` in the value.
   * Substituting an `if()` then mostly just becomes an advanced `var()` substitution, with some conditionals built in to it.
 * The `if()` function can evaluate exactly what style CQs can evaluate, and nothing else (for now).
   * This means only custom properties are supported in practice. (Despite [style()](https://drafts.csswg.org/css-contain-3/#style-container) currently being specified with support for standard properties, implementations never picked it up.)

Of course we'll need to deal with cycles. e.g.:

```
div {
  --x: if(style(--y: 1), 0, 1);
  --y: var(--x);
}
```

But we should be well equipped to handle that.

So if the CSSWG determines that this is worthwhile, it should be quite doable overall.

---

I suppose it's worth thinking about [custom functions](https://css.oddbird.net/sasslike/mixins-functions/#intro) here as well, since they also kind of provide "inline" conditionals. It might not be ergonomic to use for the use-cases you have in mind, though.

-- 
GitHub Notification of comment by andruud
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10064#issuecomment-2158298904 using your GitHub account


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

Received on Monday, 10 June 2024 13:05:09 UTC