marcohamersma / react-bem-helper

react-bem-helper allows you to easily add BEM-style element and modifier classes to React elements, while hopefully making it easier to scan.
MIT License
90 stars 5 forks source link

Parameterized modifier #4

Closed monolithed closed 8 years ago

monolithed commented 8 years ago

Hi, could you add a parameterized modifier? In the original of BEM methodology modifier is _.

My proposal:

let classes = new BEMHelper({
    modifier: '_'
});
marcohamersma commented 8 years ago

Hmm, not a bad idea. I didn't realise the -- style was considered an alternative.

After your message I considered making _ the default to be more in line with the spec, but I did some basic research found the majority of the documentation on BEM to use the double-dashes style. It seems pragmatic to stick with -- as the default, so I'll make it an option like you proposed.

we could also make it a boolean option like originalModifier, which will then use _ if true. What do you think about that?

monolithed commented 8 years ago

It seems pragmatic to stick with -- as the default

As you said the -- is an alternative, but I think you should save backward compatibility.

we could also make it a boolean option like originalModifier, which will then use _ if true. What do you think about that?

_ is the first version of BEM modifiers, but in my opinion -- is more popular

The BEM methodology provides an idea for creating naming rules and implements that idea in its canonical CSS selector naming convention. However, a number of alternative schemes based on the BEM principles also exist in the world of web development.

By default, bem-naming is configured to use the naming convention according to the methodology, but it allows you to add rules so you can use alternative schemes.

So originalModifier does not any sense

marcohamersma commented 8 years ago

I've created a branch for this feature. I'm still not 100% sure about the configuration key's name, but for now I've named it underscoreDelimiter. I think a boolean is the right choice for this, though.

If you have a better idea on how to call the feature, let me know. I'll probably merge it in later this week otherwise.

monolithed commented 8 years ago

I'm still not 100% sure about the configuration key's name, but for now I've named it underscoreDelimiter.

I'm pretty sure we have to use modifier or mod, because underscore is no regulated and can be replaced with a new version of specification. Another examples:

bemto modifier b_ — mod bem-cn — mod bem-classnames — modifiers

marcohamersma commented 8 years ago

I've decided to make it a non-boolean option as you proposed. It's called modifierDelimiter.