A
A
Artyom2020-02-18 17:20:28
Sass
Artyom, 2020-02-18 17:20:28

Does BEM require an element to have the block_el class in order to use the block_el_mod(scss) modifier?

Let's say here is the code

<div class="result-box">
  <div class="result-box__info">
    <span class="result-box__text">Name</span>
    <span class="result-box__text">Surname</span>
    <span class="result-box__text">Age</span>
  </div>

  <div class="result-box__description">
    <span class="result-box__text_gray">Know: js, sass</span>
  </div>
</div>


@mixin textStyle($size: $defaultFontSize, $color: black, $weigth:normal) {
  color:$color;
  font-size:$size;
  font-weight: $weigth;
   font-family: serif;
}
.result-box {
  overflow: hidden;
  display: grid;
  &__text {
    @include textStyle($weigth: bold)
  }
  &__text_gray {
    @include textStyle($size :1rem, $color: gray);
 }
}


Is it possible to do as I did? In the result-box__description block there is a span, to which I set
a purely class with the result-box__text_gray modifier, without the main result-box__text, because they have nothing in common. Or how to do in such cases.
And did I write a normal mixin?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ankhena, 2020-02-18
@danyvasnafig

The modifier cannot be the only class, it always accompanies the block or element class.
Otherwise, it will cease to be a modifier in the truest sense of the word.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question