Open kizu opened 5 years ago
thank you very much for the proposal, I really like your points and I'm in 🙂
so it's time to unskip these tests and UNBLOCK THE BEM POWER 😄😄😄
the thing that I'd like to consider before the publishing this feature are elements:
<__element as="p" />
You were talking about attributes, but theoretically, this kind of elements declaration might be useful too, and it solves the elements ambiguity problem that reshadow has:
<__title as="h2" />
vs
<title as="h2" />
Hmm, I feel like it should be safe to allow underscores in the names, I'm not sure if I would use it, but I see how this can be useful for someone.
However, testing it with react: it actually supports components from variables named with a leading underscore, couldn't this be a potential problem?
In short: currently the only documented way to have BEM-style modifiers which are not based on rendered attributes is
use:foo
in HTML and[use|foo]
in CSS.There is an undocumented way to do the same with just
_prop
in HTML and[_foo]
in CSS.I think that should be an officially supported feature, available as a shortcut/alternative way to use the non-rendered props for conditional/targeted styling.
Pros:
[use:foo]
in CSS._foo
you would find the modifier both inside CSS and HTML, while when you'd haveuse:foo
and[use|foo]
, looking for justfoo
would return more messy result, and you'd need to use regex/multiple searches to find the modifier everywhere.use:
namespace is already taken, for example, in Svelte.<content as="p">
in HTML andcontent {}
in CSS you could write<p __content>
in HTML and[__content]
in CSS, making it harder to use default<div>
s and promoting the usage of semantic elements. This, of course, would be also entirely optional and just as one of the potential ways to use reshadow.Cons:
_
from rendering in HTML).Overall, I find the pros to overwhelm the cons, and I think we could have both ways of doing modifiers at the same time. The underscore props are implemented easily (and work already) and having multiple ways of doing things can make it easier for people to adopt reshadow, as they could choose the way that is closer to them.