Re: [csswg-drafts] [css-values-5] Introduce nth-item() (#11103)

That is essentially what I already wrote two days ago, no? 

It becomes more readable with a helper variable. 

It would become more flexible with a function that returned the number of entries in a pseudo list, say `n()`.

~~~~ css
@function --color(--which type(<custom-ident> | <integer>)) returns <color> {
--index: if(
    style(--which: lightest): 1 /* = first index */,
    style(--which: medium): calc(n(var(--color-accent)) / 2), /* = median index */
    style(--which: darkest): -1 /* = last index */,
    else: var(--which)
  );
  return: nth-item(var(--index), ...var(--color-accent));
}
~~~~


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


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

Received on Wednesday, 23 July 2025 07:44:50 UTC