Re: [csswg-drafts] [css-values] random() function (#2826)

> Instead of random-item(), should we instead introduce into calc() a way to select the nth item of a list?

As we [discussed at the f2f when this was brought up](https://github.com/w3c/csswg-drafts/issues/2826#issuecomment-1204425784), doing it like `nth-item(random(...); items....)` is essentially identical complexity (`nth-item()` is still gonna have to be var-like in the same way), but it also requires you to write in the length of the list, which limits the ability to do more dynamic lists. Aka it's equivalent in power but more annoying.

(We still want to do `nth-item()` *as well*, but having the `random-item()` convenience seemed worthwhile.)

> [Brandon's question]

Assuming you meant `random-item(--x; var(--multiple-items); var(--single-item))`, then it'll resolve to either `1, 2, 3, 4, 5` or `6`, with a 50% chance of each.

The items have to be semicolon-separated, so with the way things are specified right now it's actually *not possible* to put several items into a single variable. (Both custom properties and the fallback of var() use `<declaration-value>`, which excludes semicolons at the top level.)

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


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

Received on Wednesday, 25 January 2023 21:51:34 UTC