getbem.github.io icon indicating copy to clipboard operation
getbem.github.io copied to clipboard

Can a modifier on an element affect other elements of the same block nested within it?

Open artinboghosian opened this issue 9 years ago • 3 comments

Let's say I have a calendar block with following markup

25

If i added modifier to calendar_cell, say calendar__cell--future, would BEM allow modifying the calendar__day element as a result?

artinboghosian avatar Aug 01 '16 22:08 artinboghosian

Hi @artinboghosian! I'm not sure if BEM says something about this but I prefer use the inherited as usual.

// --(Modifier) Future Calendar Cell
.calendar__cell--future {
  background-color: #aff;

  // --(Inherited modifier) Future Calendar Cell Day
  .calendar__day {
    background-color: #0aa;
    color: #fff;
  }
}

Here I created a visual example: http://codepen.io/unavezfui/pen/BzOrGZ

manumorante avatar Aug 03 '16 16:08 manumorante

Hey here Maxim Shirshin says in Smashing Magazine yes to use cascade like in my last example.

https://www.smashingmagazine.com/2014/07/bem-methodology-for-small-projects/#bye-bye-cascade

:)

manumorante avatar Aug 03 '16 17:08 manumorante

Thank you very much for responding manumorante. I took the inheritance approach you recommended. it's easier than having to apply modifier to each element individually within the cell.

artinboghosian avatar Aug 04 '16 20:08 artinboghosian