• Mike BusbyMike Busby, over 6 years ago

    Why would you use this? Extra code for no reason

    2 points
    • Siamak Mokhtari, over 6 years ago

      All mixins are useful in suitable situation. I'm thinking about reason and find just one! Sometimes little functions or mixins can help and manage our works. Thanks for Comments ✌️

      0 points
      • Mike BusbyMike Busby, over 6 years ago (edited over 6 years ago )

        Writing more than necessary code is the opposite of managing work.

        Why would you write:

        @include element('button') { @include modifier('error') { background-color: red; } }

        When this is already built into SASS (3.3)

        &__button { &--red { background-color: red; } }

        Totally pointless to do

        3 points
  • Gilbert BagaoisanGilbert Bagaoisan, over 6 years ago


    1 point
  • Tim Knight, over 6 years ago (edited over 6 years ago )

    I think your concept here is well intentioned. When I've introduced new people to the principles of BEM sometimes it's hard for them to remember when to use __ and when to use -- so I've seen the benefits of the abstraction into a mixin. I think it would be safe to say though you could eliminate typing by just using 'e' and 'm' as your mixin names. This has been a practice I've followed in the past in creating a similar mixin.

    I think it's important though to understand there are both pros and cons to this concept and it could lead you into some trouble with parent referencing. Additionally, because of the nature of mixins you're not able to attribute multiple declarations to the same produced selector. For example:

    .well { @include e('header') { color: black; font-size: 2em; } @include e('description') { color: black; } }

    It's possible to modify the code to accept a list of selectors as a list, but you have to ask yourself if the complexity at that point becomes worth it.

    @mixin e($elements...) { $element-list: (); @each $element in $elements { $element-list: append($element-list, "&__#{$element}", comma) } #{$element-list} { @content; } }

    So, the moral of the story I guess is, I'm glad to see more people creating abstractions to simplify their code, just understand the limits and determine when it's okay to throw away the abstraction.

    0 points
  • Satyajit SahooSatyajit Sahoo, over 6 years ago

    Seems pointless and more typing.

    0 points