Re: [csswg-drafts] [css-values-5] What is the MVP for inline conditionals on custom properties? (#10064)

> @LeaVerou Is there already a CSS function in existence or in the works that could be used to check whether or not the matched element matches a specified selector, essentially selector narrowing?
> 
> For example…
> 
> BEFORE AFTER
> ```css
> /* without using if() */
> .item {
>   --symbol: "🩶";
>   &::before {
>     content: var(--symbol);
>   }
>   &.favorite {
>     --symbol: "🧡";
>   }
> }
> ```
> 
> ```css
> /* using if() */
> .item {
>   --symbol: if(matches(.favorite) ? "🧡" : "🩶");
>   &::before {
>     content: var(--symbol);
>   }
> }
> ```

Possibly, but I think this warrants a new issue, as it’s introducing a new type of condition, and the whole point of the `if()` MVP is to reuse existing conditionals.

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


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

Received on Sunday, 23 June 2024 12:32:47 UTC