Re: [csswg-drafts] Proposal: Custom CSS Functions & Mixins (#9350)

Two quick questions...

1) vars containing values with commas would spread across params on a call to a function, right?

```css
--args: 1, 2, 3;
--val: --custom-fn(var(--args)); /* called with 3 arguments? */
```

2) If my custom function only takes 1 param, is it okay to call it and still pass in 10 values where the last 9 are ignored?

if yes on q 1, (and helped along with a 'yes' on q 2) this opens the door to arrays which means CSS libraries (with minor restrictions) can begin providing shorthand properties in their API! That's gonna be sick!

```css
@function --at-0 (--p0) { result: var(--p0); }
@function --at-1 (--p0, --p1) { result: var(--p1); }
@function --at-2 (--p0, --p1, --p2) { result: var(--p2); }
...

.library-border {
  --size: --at-0(var(--api-shorthand, var(--api-size, 1px));
  --style: --at-1(var(--api-shorthand, _, var(--api-style, solid));
  --color: --at-2(var(--api-shorthand, _, _, var(--api-color, black));
  border: var(--size) var(--style) var(--color);
}
```

```html
<div class="library-border" style="--api-shorthand: 2px, solid, hotpink;">I have a 2px solid border that's hotpink!</div>
```


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


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

Received on Wednesday, 6 November 2024 00:29:52 UTC