Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's a service block? #59

Open
skube opened this issue Aug 4, 2017 · 5 comments
Open

What's a service block? #59

skube opened this issue Aug 4, 2017 · 5 comments

Comments

@skube
Copy link

skube commented Aug 4, 2017

In the BEM documentation, they make reference to something called a "service block":

... In a case like this, instead of creating an element, you need to create a service block.

I can't find any mention of a service block. What does this actually mean?

@tadatuta
Copy link
Member

tadatuta commented Aug 4, 2017

@skube That's just a 'virtual' block which is not actually something really independent but serves the only reason — to split implementation into separate files.

For example consider block menu which has menu__item elements. Such elements may be quite complex so one may decide to create new block called menu-item and split its implementation into different elements: menu-item__icon, menu-item__text, etc.

@skube
Copy link
Author

skube commented Aug 4, 2017

Thanks for the quick reply!

Can you perhaps give a basic code example?

@tadatuta
Copy link
Member

tadatuta commented Aug 4, 2017

Something like this

<ul class="menu">
    <!-- each `li` should actually be `menu__item` but there won't be possibility to create its own elements in that case -->
    <li class="menu-item">
        <span class="menu-item__icon"></span>
        <span class="menu-item__text">The first item</span>
        <span class="menu-item__toggle"></span>
    </li>
    <li class="menu-item">
        <span class="menu-item__icon"></span>
        <span class="menu-item__text">The second item</span>
        <span class="menu-item__toggle"></span>
    </li>
</ul>

@skube
Copy link
Author

skube commented Aug 4, 2017

Interesting. I guess I would have simply created nested elements:

<ul class="menu">
    <!-- Is this alternate approach wrong ? -->
    <li class="menu__item">
        <span class="menu__icon"></span>
        <span class="menu__text">The first item</span>
        <span class="menu__toggle"></span>
    </li>
   ...
</ul>

Thanks!

@tadatuta
Copy link
Member

tadatuta commented Aug 4, 2017

You are right, that's just another way to solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants