Re: [csswg-drafts] [css-mixins] Improve ergonomics of `using` by allowing wildcards (#10954)

> I'm slightly against this. The use-case is reasonable, but I think we should solve it more directly.

I agree that we should, and there are several open issues to do so. However, even if we solve it for the common case, I think there will always be use cases where you want to pull in multiple properties with a shared prefix.

> Basically, a function knows exactly what variables _it_ is going to use. There's no need to import every single color; just write the ones you're _actually using_ in your `using` list.
> 
> The problem is that a function doesn't know what theming variables its _own_ called functions will want to use, and so pulling in the entire theme, as in your example, makes sense. 

Or we define that the using lists of each function are separate, a function calling another function doesn't need to specify a superset of using for the child call to work. It’s harder to implement, but much better ergonomics IMO.

> This means it would probably end up being common practice to just write `using (--*)` on all your functions, _just in case_, and that sucks.

Agreed. One solution could be to simply not allow that, specify that you need at least one character.


> We do want to make sure that an outer function can _override_ a theming variable for the functions it calls (and the functions they call, etc, if they're not further overriden). This sort of theming control is important.

I had assumed a function’s parameters shadow any custom properties in `using` already. If not, they should.

> Maybe `using` variables can crawl up the scope tree to find a valid declaration for the given variabale, bottoming out at the element it's used on? So if an outer function just _doesn't mention_ a given a variable, then an inner function with `using (--foo)` will look higher up the call tree for that variable. But if an outer function _does_ redefine --foo in its body, then the inner function will see that definition.

I like that.


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


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

Received on Thursday, 26 September 2024 19:28:10 UTC