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

Thinking about the syntax for arguments again, both type and default should be optional, and both are potentially complex values. How about:

```css
/* no annotations */
@function --foo(--arg1, --arg2) {
 @return calc(var(--arg1) * (var(--arg2) / 1turn));
}

/* all the annotations */
@function --foo(
 --arg1 type(<calc-length>) default(1em),
 --arg2 type(<angle>) default(90deg),
) returns type(<length>) {
 @return calc(var(--arg1) * (var(--arg2) / 1turn));
}

.foo {
    width: --foo(1em + 1px, 5rad);
}
```

(I'm imagining `<calc-length>` is a new term you can use on argument types, to indicate you want a length but allow a raw calculation, so users don't need to write `--foo(calc(1em + 1px), 5rad)`. It wouldn't be allowed for return types, as it's not meaningfully different from `<length>` there.

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


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

Received on Friday, 2 February 2024 20:33:23 UTC