Re: [csswg-drafts] [selectors] New selector to facilitate utility classes (`[name~^=value]`? `.prefix-*`?) (#10001)

There is #1010, but that is about regular expressions and element selectors, not simpler wildcard class selectors, which were also not covered in #354. 

For what it’s worth, I believe utility classes for atomic design tokens – i.e. usually with a name that roughly matches its single style rule like `.font-sm {font-size: 0.8rem}` – are very much an anti-pattern for production-level CSS. They should be a tool for early-stage development only, which are then grouped into patterns. However, I’m probably in the minority with that view nowadays. 

That is partially why I suggested, in #3714, to introduce something like this:

~~~~ css
$fg-green {color: var(--my-green);}
$bg-white {background: white;}
~~~~
which could then be applied verbosely in HTML as
~~~~ html
<a style="@include $fg-green $bg-white">dev</a>
~~~~
and if that is found to establish a common pattern, it would be moved back to CSS:
~~~~ css
.pattern {@include $fg-green $bg-white;}
~~~~
and the HTML could become more readable and semantic again. 
~~~~ html
<a class="pattern">prod</a>
~~~~

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


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

Received on Monday, 26 February 2024 20:32:16 UTC