Generated by SassMeister.com.
<h3>BEM Button - Helper klase</h3>
<a class="button" href="#">
<span class="button__label">
BEM button - normal
</span>
</a>
<!-- TODO: maknuti hover i pointer -->
<a class="button is_disabled" href="#">
<span class="button__label">
BEM button - is_disabled
</span>
</a>
<a class="button is_alert has_icon" href="#">
<span class="button__label">
BEM button - is_alert, has_icon
</span>
</a>
.button {
display: inline-block;
padding: 5px 10px;
color: white;
text-decoration: none;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
font-family: sans-serif;
background: LightSlateGray;
border-radius: 3px;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}
.button:hover {
box-shadow: none;
}
.button.is_disabled {
background: #ccc;
color: #aaa;
}
.button.has_icon {
padding-left: 5px;
}
.button__label {
font-weight: bold;
}
.button.is_alert .button__label {
color: gold;
}
.button.has_icon .button__label {
padding-left: 5px;
}
.button.has_icon .button__label:before {
content: "!";
color: gold;
}
// ----
// Sass (v3.3.9)
// Compass (v1.0.0.alpha.20)
// ----
// BEM Button - Helper klase
// $m je varijabla naziva modula / bloka
// koristimo ga jer je kraće nego uvijek pisati sam naziv
$m: button;
%#{$m} {
display: inline-block;
padding: 5px 10px;
color: white;
text-decoration: none;
text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
font-family: sans-serif;
background: LightSlateGray;
border-radius: 3px;
box-shadow: 0 0 2px rgba(0,0,0,0.5);
}
// START
.#{$m}{
@extend %#{$m};
&:hover {
box-shadow: none;
}
// stanje gumba je - disabled
&.is_disabled {
background: #ccc;
color: #aaa;
}
// gumb sadrži ikonu
&.has_icon{
padding-left: 5px;
}
// .button__label
&__label{
font-weight: bold;
// sve je na jednom mjestu odnosno - pod button__label
// vraća se u root, uzima prefix is_alert i has_icon
// a & vraća putanju selektora u kojem se nalazimo
@at-root {
.#{$m}.is_alert &{
color: gold;
}
.#{$m}.has_icon &{
padding-left: 5px;
&:before {
content:"!";
color: gold;
}
}
}
}
}
<h3>BEM Button - Helper klase</h3>
<a class="button" href="#">
<span class="button__label">
BEM button - normal
</span>
</a>
<!-- TODO: maknuti hover i pointer -->
<a class="button is_disabled" href="#">
<span class="button__label">
BEM button - is_disabled
</span>
</a>
<a class="button is_alert has_icon" href="#">
<span class="button__label">
BEM button - is_alert, has_icon
</span>
</a>