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

"btn-group" as BEM #79

Open
ghost opened this issue Apr 27, 2019 · 3 comments
Open

"btn-group" as BEM #79

ghost opened this issue Apr 27, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Apr 27, 2019

Hi,

I'm trying to understand all the scenarios to apply BEM and there is something I would like to clarify in my mindset about this method.

Ok, imagine that you need a btn-group to gather the button / anchor elements in a module. If the module is the father of all, then you might think this btn-group is a child so it would like this "module__btn-group" but what happen with the btn?, and what about if you need that btn-group styles to apply another module?, then you will need to copy the same css rules again and again?. I mean, all the inner elements must have a father block of his own?.

Thanks a lot for the help.

@tadatuta
Copy link
Member

If there's a chance to reuse btn-group elsewhere, make it a separate block and just you it inside module. And the same for btn. So your structure may look like this:

<div class="module">
    <div class="btn-group">
        <button class="btn">
        <button class="btn">
        <button class="btn">
    <div>
</div>

If you need to maintain the fact that this particular btn-group is the one that belongs to the module just mix an element to the same DOM node:

<div class="module">
    <div class="btn-group module__btn-group">
        <button class="btn">
        <button class="btn">
        <button class="btn">
    <div>
</div>

The same may be applied to the buttons:

<div class="module">
    <div class="btn-group module__btn-group">
        <button class="btn btn-group__btn">
        <button class="btn btn-group__btn">
        <button class="btn btn-group__btn">
    <div>
</div>

Now btn can have the styles for any abstract buttons. All the positioning styling and all the rest things the are special for buttons just inside btn-group should be added to .btn-group__btn element.

@ghost
Copy link
Author

ghost commented Apr 27, 2019

Hi!, first of all thanks a lot for the reply, very appreciated.

So, if I haven't got it wrong, you can have Block elements, inside another bigger one, with his own Elements and Modifiers, is it correct to do it so?.

Thnx again.

@tadatuta
Copy link
Member

tadatuta commented May 1, 2019

yes, that's right

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

No branches or pull requests

1 participant