E
E
eugenedrvnk2020-09-26 15:15:11
css
eugenedrvnk, 2020-09-26 15:15:11

When to create a service block in BEM?

I have the following structure :

<div class="blog-hero-section__grid">
  <div class="blog-hero-section__grid-item"></div>
  <div class="blog-hero-section__grid-item"></div>
  <div class="blog-hero-section__grid-item"></div>
</div>


In this situation, there is just the moment when there is a desire to create something in the spirit of the element at the element ala blog-hero-section__grid__item.

Which way out of the situation is more correct? Make a blog-hero-section__grid-item or create a "service block" blog-hero-section-grid and put an item (blog-hero-section-grid__item) into it.

As I understand it, it’s more of a matter of convenience, but it’s just that until the current moment I would always choose the option with __grid-item, but today I came across a couple of articles and there, in the examples, it was said they say you need to create a service block. __grid-item (in my situation) looks confusing.

Although for me it seems that the blog-hero-section-grid block will look more incomprehensible than my version.
Actually, which side would be more correct to go?)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Solntsev, 2020-09-26
@vladdimir

I join the answer above - the design is easier.
You can do this:

<div class="hero-section__grid">
  ...
    <div class="hero-item hero-section__hero-item">
      <h2 class="hero-item__header">Hero Item 1</h2>
      ...
    </div>
</div>

Or like this:
<div class="hero-section__grid">
  ...
    <div class="hero-section__content">
      <div class="hero-item">...</div>
    </div>
    <div class="hero-section__pagination">...</div>
    <div class="hero-section__footer">...</div>
</div>

Or else how, choosing the best option for a particular project.
Considering that you want to make elements of elements, it is worth re-reading the manual, the methodology is well documented. Good articles about BEM talk about the experience and bumps of other developers, and imply that you already own the methodology. If you don't own, they will only confuse you. Introductory articles are a free and truncated retelling of official documentation, and often of much worse quality.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question