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

The main intent with my _switch_ function is, precisely, to be able to somehow 'centralize' the switch at the place where the author is naturally putting the declarations, as @tabatkins mentions (_"clustered at point-of-use_"), reducing the verbosity of media rules.

So in a media rule you set an index-like property (there is also the possibility to mix it with some `calc()` tricks), and also add all the rules that are really specific for that media query.

Then, you may want to put the _switch_ at the "main" sheet, and for example if you have three index levels you do not need to always specify three values:
```
margin: switch(var(--mq-level); 50px 25px; 25px 12.5px; 12.5px);
font-size: switch(var(--mq-level); 24px; 20px);
```
Which also means that if you add another level and forget to update some declaration(s), things keep working.

Your suggestion (which is somewhat similar to the original proposal in this issue), instead, implicitly builds something similar to a matrix of values, that in principle have to be always fulfilled.

Finally, my _switch_ allows for invalidating the declaration, which may sometimes be useful.

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

Received on Thursday, 7 May 2020 22:15:26 UTC