These are chat archives for bem/talk

6th
Sep 2016
Sten Hougaard
@netsi1964
Sep 06 2016 08:17

Hi - just wondered. If I have a block which has a modifier, should the modifier then be a part of element classes? Imagine Block: "block", Modifier:"dark" with element: "button".
Element class where modifier is used on elements:

<div class="block--dark block">
  <div class="block-button">

Element class where modifier is not used on elements:

<div class="block--dark block">
  <div class="block--dark-button">

Which one is best practice?

Alexej Yaroshevich
@zxqfox
Sep 06 2016 10:43
No, it shouldn't. Elements bound to blocks but you don't need to show modifiers in elements' classes.
The first sample is right.
Sten Hougaard
@netsi1964
Sep 06 2016 10:45
@zxqfox okay. Should I then write this code to address modifing changes to the button:
.block--dark .block-button { content: "DARK"; }
..or should I create a new block element?
(skipping the modifier for a new block..)
Alexej Yaroshevich
@zxqfox
Sep 06 2016 10:47
Yes, sure. It's a common case for modifying elements of modified blocks. You can do it because elements can't be used without blocks.
Sten Hougaard
@netsi1964
Sep 06 2016 10:48
Thanks @zxqfox
Alexej Yaroshevich
@zxqfox
Sep 06 2016 10:48
You are welcome. Btw, if you using telegram: https://telegram.me/bem_en
Sten Hougaard
@netsi1964
Sep 06 2016 10:49
Looks interesting - however I do not know/use telegram. Will look at it.
Sten Hougaard
@netsi1964
Sep 06 2016 10:57
@zxqfox Searching for "bem_en" on telegram has no hits...
Alexej Yaroshevich
@zxqfox
Sep 06 2016 12:19
Huh? But do the link work?