Re: [csswg-drafts] [css-variables?] Higher level custom properties that control multiple declarations (#5624)

@isiahmeadows @bramus 

I was under the impression that these days there more or less is consensus for an inline `if()`/`cond()` function (see the issues I linked to in my first post), so this is exploring a block form. As @bramus pointed out, the closed proposal you point to could refer to other properties etc which is way harder to implement.

I did indeed initially propose limiting conditions to comparisons between `var()` references and values, but it seems that a more general form could perhaps be possible (see https://github.com/tabatkins by @tabatkins ).

> Edit: also read up on CSS mixins and the surrounding proposals related to that. The other half of this is basically that.

I thought I was up to date on these, but it's entirely possible I've missed a few, were there any specific discussions you'd like me to focus on?

> @bramus ~~Okay, now that I take a closer look, I think you're right.~~ Edit: If units are allowed in the comparison, one could define `font-size: if(var(--foo) > 2em, 2em, 1.5em)` - would this produce a cycle?

No because `em` in `font-size` points to the parent font-size. Otherwise even `font-size: 2em` would be a cycle šŸ˜„ 

> That would immediately also solve the ā€œPartial applicationā€ issue @LeaVerou [mentions](https://github.com/w3c/csswg-drafts/issues/5624#issuecomment-746339609), as it simply wouldn't be allowed.

I don't see how.
a) Custom properties can have different values in nested rules.
b) Consider e.g. `if(var(--foo) > 5%, ...)` with `var(--foo)` being e.g. `12px`. Percentages are resolved differently in different properties, so the condition could be true in one property and false in another.

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


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

Received on Monday, 28 December 2020 13:38:06 UTC