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

Thinking about this some more, I think we should go with `if ([cond ? iftrue : iffalse ]+)`

- `?:` is a well-established pair for ternaries, and even though having *both* a function *and* `?:` does not have a precedent, I think it’s an ergonomics improvement as it makes the conditional far easier to read (I’ve seen beginners struggle with understanding `?:` ternaries way too often).
- Having *both* `?` to separate the condition from the values and `,` to separate the values from each other seems like a very weird halfway pattern. 

Also, given the author need, this should not be held up by syntax. If we don’t have consensus on how to represent an empty value, or whether the last else value should be optional, let’s just spec a version of `if()` where the last argument is mandatory, and cannot be empty while we figure this out. Worst case, authors can always do this as a workaround:

```css
--empty: ;
background: if(style(--variant: primary), var(--color-primary), var(--empty));
```

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


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

Received on Tuesday, 18 June 2024 13:27:33 UTC