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

> I wonder if a better path forwards for Sass would be to simply deal with _fewer_ calculations: wrap inline calculations with `calc()` and pass them to CSS for the actual computation. Then it can wrap in `calc()` optimistically, and these function calls would not be affected at all. Plus, it means you can do things like `width: 1em + 100px;` without getting an error, which is a usability win for Sass itself. I understand this won't work for all cases, but I think it might work for enough to relegate any negative impact from this to edge cases. I'm likely missing something major, but the overall sentiment is, let's try and figure out a solution to this together, that doesn't involve making CSS less usable.

One of the critical issues here is that mathematical syntax isn't mutually exclusive with expression syntax elsewhere in CSS. What does `1 / 2` mean in a CSS property? The answer is "it depends on context"—within a calculation, it's equivalent to `0.5`, but in a `grid-template` property it separates rows from columns. So what is `--foo(1 / 2)`? If you allow `<calc-length>`s, we can't possibly know without seeing the definition of `--foo`, which may be in a totally different stylesheet.

I'd argue that this is a usability issue as well. It's valuable for humans, not just tools, to be able to see a function call and understand generally what it means without having to know all the definitions of everything.

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


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

Received on Monday, 5 February 2024 23:56:05 UTC