Re: [csswg-drafts] [css-values-5] Add `spread()` to CSS (#8391)

@tabatkins @Loirooriol It may even be worth including the functions `set()` and `nth()` in this proposal as all three go hand-in-hand. What do you think? I could write up separate proposals for them, but `set()` is rather fundamental to this ticket unless it's unneeded in which case I'll just omit that one.

`nth()` I'm not sure about — should that get its own ticket?

Also, relatedly, @Crissov had a pretty [interesting proposal](https://github.com/w3c/csswg-drafts/issues/2826#issuecomment-1405729740) in a comment on the `random()` ticket last week, proposing that instead of separate `nth()` and `random-item()` functions, introducing one new consolidated function like `select()` or `choose()`, though `nth()` would probably still work fine for naming.

For the sake of continuity, let's call this function `nth()`. `nth()` would support all the usual `nth` values include formulaic values:

```css
.foo {
  --items: set(1; 2; 3);

  /* spreading into dynamic `nth()` */
  --random-item: nth(random --x per-element; spread(--items)); /* random becomes a keyword here rather than a dedicated `random-pick` function */
  --first-item: nth(1; spread(--items));
  --also-first-item: nth(first; spread(--items));
  --last-item: nth(last; spread(--items));
  --odd-items: nth(odd; spread(--items)); /* returns filtered list: list(1; 3) */
  --even-items: nth(even; spread(--items)); /* returns filtered list: list(2) */
  --range-of-items: nth(3 to 5; spread(--items)); /* returns filtered list: list(3) */
  --two-and-down-items: nth(-n + 2; spread(--items)); /* returns filtered list: list(1; 2) */
  --all-items: nth(n; spread(--items)); /* essentially copies the list, pointless but valid */
}
```

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


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

Received on Thursday, 2 February 2023 21:29:57 UTC