Re: [csswg-drafts] [css-values]: Express conditional values in a more terse way (#5009)

Agreed with Miriam. Also, I know these names are pre-bikeshedding, but just saying, I think `switch()` is a fairly confusing name to non-programmers. And I'd avoid abbreviations like `cond()`. 

> Of course @LeaVerou's initial proposal was based on a much simpler ternary `if(<condition>, <true>, <false>)`… Simplifying the math function that dramatically, it might provide a more distinct/useful shortcut. That proposal makes more sense to me than the middle-ground `cond()`. Still, it's not _much_ simpler than using switch as a ternary:
> 
> ```css
> .example {
>   gap: if(100% > 500px, 2em, 1em);
>   gap: switch((100% > 500px) 2em; 1em);
> }
> ```

Just here to mention that I started an unofficial draft about this here: https://drafts.csswg.org/css-conditional-values-1/#if
It's very very very rough right now, and I would really welcome feedback for fleshing this out further. Especially from @tabatkins who has specced all the other math functions.

I've just re-read the entire thread, and I can't fully understand the difference between `if()`, `cond()` and `switch()` besides allowing for "else if" values, which is syntax sugar. Is it that `switch()` accepts MQ-style conditions? 
If so, we don't need three different functions for expressing conditionals, once we have a `<condition>` value, we can have different syntaxes/functions that return `<condition>` to be used in `if()`. So e.g. we could have a `media()` function that accepts a media query and returns a `<condition>` which can be used anywhere a `<condition>` is accepted.
Also, just like any other value type, conditions can be assigned to variables, to avoid repeating lengthy conditions in multiple places, which is another problem that was mentioned in the thread. 

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


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

Received on Thursday, 25 February 2021 00:00:41 UTC