I have been following the BEM methodology and i am not sure if i am doing it right since i end up with quite a lot of classes sometimes. I wan to keep my code modular and reusable so i started to use mixins and placeholders. But in some cases i will end up with code like that :
to have the code reusable i have for example the following scss:
class specific scss file:
.l-page-width {
display: inline-block;
&_background_white {
@extend %background_white;
}
&_padding_bot-top {
@extend %padding_bot-top;
}
&_center_absolute {
@extend %center_absolute;
}
}
Placeholder:
%background {
&_white {
background: $white;
}
}
%padding {
&_bot-top {
padding-bottom: span(.35);
padding-top: span(.35);
}
}
%center {
&_absolute {
bottom: 0;
left: 0;
margin: auto;
overflow: auto;
position: absolute;
right: 0;
top: 0;
}
}
HTML
<div class="l-page-width l-page-width_background_white l-page-width_padding_bot-top l-page-width_center_absolute">
<div class="c-quote c-quote_padding_lr">
<h1 class="c-quote__title c-quote__title_outline_black">
Title Here
</h1>
<p class="c-quote__content">
content text here
</p>
</div>
</div>
i have been reading the bem info site again and came up with that and it makes much more sense now:
<div class="l-page-width">
<div class="l-page-width__c-quote c-quote">
<h1 class="c-quote__title c-quote__title_outline_black">
Title Here
</h1>
<p class="c-quote__content">
content text here
</p>
</div>
</div>
scss:
.l-page-width__c-quote {
@extend %background_white;
@extend %padding_bot-top;
@extend %padding_lr;
@extend %align_center;
}
I