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

What about defining a _switch_ function:

`switch(<integer [1,∞]>, <toggle-value>#)
`

If the first argument is not positive, the value becomes invalid (yes it could start from zero too). The other arguments (I chose the [_toggle-value_](https://drafts.csswg.org/css-values-4/#typedef-toggle-value) from the `toggle()` function, not sure if there is something more general) are selected according to the first: `1` means the first _toggle-value_ is returned, `2` the second, etc.

If the first argument evaluates to _N_ and there are _M_ toggle-values, with _M_<_N_, then the last toggle-value is used. The toggle-values could also contain `var()` functions, if the switch is resolved before the vars are substituted/evaluated.

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

Received on Tuesday, 28 April 2020 18:05:03 UTC