I find the c-button c-button--primary a bit annoying. Why not just c-button primary and define them like this?
.c-button.primary {
…
}
Or namespace it: .c-button.m-primary {
…
}I find the c-button c-button--primary a bit annoying. Why not just c-button primary and define them like this?
.c-button.primary {
…
}
Or namespace it: .c-button.m-primary {
…
}Obviously this is a fairly basic example, but with more chaining comes more levels of specificity which makes for increasingly difficult changes and worse productivity.
One thing bothers me though. Isn't this very WET? You have to repeat the `.primary` rules in every `--primary` thing?
I'm still torn apart about `.button.primary` and `.button--primary`. Also semantic classes vs style bound classes. I'm not completely convinced by any methology.
What's the difference between
.c-button.primary { … }
.c-button.large { … }
and .c-button--primary { … }
.c-button--large { … }
?Like mentioned above, this keeps things simple and prevents the snowball effect of people continually adding classes or selectors to override styles.
<section class="frogs">
<h1 class="headline frogs__headline">Frogs</h1>
</section>
or <section class="frogs">
<h1 class="headline">Frogs</h1>
</section>
So in the second one some sadness happening possibilities of a developer being a jerk:1. Removes the "frogs" class from section. Now the baseline headline applies to the h1
2. Buries this joy somewhere
.frogs h1 { sadness: here; }
3. Wraps the h1 in a div or something clever for some effect or whatever <section class="frogs">
<div class="sweet-slider-plugin">
<h1 class="headline">Frogs</h1>
...
</div>
</section>
and someone wrote the rule as .frogs > .headline
because further down in the section someone else used the .headline class nested in a "frog of the day" sub section.I'm definitely not trying to say BEM is what you have to use. Or if it is good or bad. Just trying to explain that there is an actual point to it.
Here's a good article explaining the idea:
http://csswizardry.com/2013/01/mindbemding-getting-your-head...
How would you enforce that when working in a big project with many contributors? I don't want to risk breaking my component if someone all of a sudden declares a global .primary class. When using --primary I know that won't happen since it's completely bound to my component.
So what you're saying is that BEM is the Java of CSS? Because that explains a lot.