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

I see a lot of people bringing up the question of whether this is more like an `if`, `switch` or `match`.

Just my two cents, but these days, every language that's ever had an if-statement eventually realizes they want is pattern matching - an `if` statement generally implies branching, but CSS is declarative, so a `match` might be a better choice. 

Something like @Link2Twenty 's `switch` statement (above) but allowing expressions with comparison operators.

This would be much more readable than the ternary style syntax inside the if(...) - especially given that nesting ternaries is already frowned upon in other languages. 

It also solves the ambiguity problems and the case where you don't want a default - which, in addition, you make more readable, safer, and easier to parse by actually requiring a `default:` in the match/switch to indicate a fallback value when no condition is matched.

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


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

Received on Thursday, 11 July 2024 06:15:18 UTC