Skip to content

[css-mixins] Add CSS Functions and Mixins specification #10367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 25, 2024

Conversation

andruud
Copy link
Member

@andruud andruud commented May 24, 2024

To begin with, only @function is described.

#9350

Copy link
Member

@tabatkins tabatkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got one question, but it's probably better as an issue anyway. Looks good, imo!

@tabatkins
Copy link
Member

Unless @mirisuzanne has any complaints, I think we should merge this and then bring it up to the WG for review.

andruud added 3 commits May 27, 2024 13:59
There's apparently no right answer to "an at-foo" vs "a foo",
but we can at least stay consistent within the same spec.
<pre class="prod def" nohighlight>
@function <<function-name>> [( <<parameter-list>> )]?
[using (<<dependency-list>>)]?
[returns type(<<string>>)]?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mirisuzanne Can we drop these type() functions? Both in the return value, and the param lists. Right now, the full abomination looks like e.g.:

@function --abcd(--a type("<length>") : 10px,
                 --b type("<length>") : 20px)
          using (--c type("<length>") : 30px,
                 --d type("<length>") : 40px)
          returns type("<length>")
{
  --ab: var(--a) + var(--b);
  --cd: var(--c) + var(--d);
  result: calc(var(--ab) + var(--cd));
}

Whereas if we drop type(), we get "just":

@function --abcd(--a "<length>" : 10px,
                 --b "<length>" : 20px)
          using (--c "<length>" : 30px,
                 --d "<length>" : 40px)
          returns "<length>"
{
  --ab: var(--a) + var(--b);
  --cd: var(--c) + var(--d);
  result: calc(var(--ab) + var(--cd));
}

As far as I can tell, there's no reason why we couldn't just parse an optional plain <string> after the param name / returns keyword.

@tabatkins and I also have a plan to spec that we don't need to use strings to specify the types:

@function --abcd(--a <length> : 10px,
                 --b <length> : 20px)
          using (--c <length> : 30px,
                 --d <length> : 40px)
          returns <length>
{
  --ab: var(--a) + var(--b);
  --cd: var(--c) + var(--d);
  result: calc(var(--ab) + var(--cd));
}

(We could require a string for complex types such as <length> | <color>).

I'm not going to attempt the unstringification in this PR, but I would like to kill type(), if possible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, maybe we can keep type(), but make it optional if there's a single syntax component. For example:

Valid:

@function (--a <length>) { ... }
@function (--a <color>) { ... }
@function (--a <color>+) { ... }

Not valid:

@function (--a <number> | <percentage>) { ... }

However, valid:

@function (--a type(<number> | <percentage>)) { ... }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, something like: andruud#2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm fine with any of these approaches to simplifying the types. The linked PR makes sense to me.

@svgeesus
Copy link
Contributor

@mirisuzanne does this look good to merge?

Copy link
Contributor

@mirisuzanne mirisuzanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good start to me, setting aside the tangential/theoretical nature of @nest. Thank, @andruud!

<pre class="prod def" nohighlight>
@function <<function-name>> [( <<parameter-list>> )]?
[using (<<dependency-list>>)]?
[returns type(<<string>>)]?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm fine with any of these approaches to simplifying the types. The linked PR makes sense to me.

@tabatkins tabatkins merged commit e4ba280 into w3c:main Jun 25, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants