Transcript
Page 1: BEM — Build ‘em Modular!

1

Page 2: BEM — Build ‘em Modular!

BEM — Building 'em modular

Yelena Jetpyspayeva, Vladimir Grinenko, Yandex

You Gotta Love FrontEnd 2015, June 8-9, Tel-Aviv2

Page 3: BEM — Build ‘em Modular!

Vladimir•  4 years at Yandex

•  Head of BEM Development Division at Yandex

•  HTML/CSS/JS/BEM 24/7

•  [email protected]

•  @tadatuta

•  github.com/tadatuta

3

Page 4: BEM — Build ‘em Modular!

Yelena•  4 years at Yandex

•  BEM Developer Relations Programm Manager

•  Techevents, marketing, devcommunity — come talk to me!

•  [email protected]

•  @mursya

•  github.com/mursya

4

Page 5: BEM — Build ‘em Modular!
Page 6: BEM — Build ‘em Modular!

Agenda•  What's BEM historically?

•  What's BEM technically?

•  Methodology

•  Tools, frameworks and template engines

•  Block libraries

•  What BEM can do that others can't?

•  How to start?

6

Page 7: BEM — Build ‘em Modular!

What's BEM historically?

7

Page 8: BEM — Build ‘em Modular!
Page 9: BEM — Build ‘em Modular!
Page 10: BEM — Build ‘em Modular!
Page 11: BEM — Build ‘em Modular!
Page 12: BEM — Build ‘em Modular!
Page 13: BEM — Build ‘em Modular!
Page 14: BEM — Build ‘em Modular!
Page 15: BEM — Build ‘em Modular!
Page 16: BEM — Build ‘em Modular!

Problems we faced•  Low speed of rendering

•  Naming that does not help

•  Any interaction with code was dangerous because of 0 in capsulation

•  and made it possible not only for maintainment but for re-use too

16

Page 17: BEM — Build ‘em Modular!
Page 18: BEM — Build ‘em Modular!

Problems → Solution•  Long cascade affected speed of rendering...

•  ... so, BEM helped us eliminate cascade

•  by using block__element_modifier naming system

18

Page 19: BEM — Build ‘em Modular!

Problems → Solution•  CSS classes forced us to reinvent names everyday...

•  ... so, with BEM we get a naming convention!

19

Page 20: BEM — Build ‘em Modular!

Problems → Solution•  0 incapsulation...

•  ...so, BEM helped us incapsulate code on block level

•  and made possible to re-use

20

Page 21: BEM — Build ‘em Modular!

Problems → Solution•  More demand on interactive interfaces...

•  ...was not longer a threat

•  BEM file structure gave an option to separate code according to

technologies

21

Page 22: BEM — Build ‘em Modular!
Page 23: BEM — Build ‘em Modular!
Page 24: BEM — Build ‘em Modular!

What is BEM now?•  methodology

•  libraries

•  tools

•  JS-framework

•  templating engine

•  engine for building docs and samples

•  tests for blocks

•  the community 24

Page 25: BEM — Build ‘em Modular!

What is BEM now?•  a development division at Yandex with 30+ frontenders

•  400+ frontenders at Yandex.Services

•  1500+ community developers

•  a standard for frontender's CV in CIS

25

Page 26: BEM — Build ‘em Modular!
Page 27: BEM — Build ‘em Modular!
Page 28: BEM — Build ‘em Modular!
Page 29: BEM — Build ‘em Modular!

What's BEM technically?

29

Page 30: BEM — Build ‘em Modular!

What's BEM technically?•  Methodology

•  Tools, frameworks and template engines

•  Block libraries

30

Page 31: BEM — Build ‘em Modular!

Web development is...

31

Page 32: BEM — Build ‘em Modular!

Web development is a pain.

32

Page 33: BEM — Build ‘em Modular!

BEM methodology•  Teachs how to relieve that pain.

•  Just a bunch of best practicies

33

Page 34: BEM — Build ‘em Modular!

Where pain comes from•  Support someone's else code

•  Your own in a month

•  #foot div div *

34

Page 35: BEM — Build ‘em Modular!

Where pain comes from•  Support someone's else code

•  Refactoring

•  Reuse

•  Copy/paste doen't work

•  Hard to tell what to copy

•  Useless code

•  Update is a nightmare

35

Page 36: BEM — Build ‘em Modular!

Where pain comes from•  Support someone's else code

•  Refactoring

•  Reuse

•  A lot of different frameworks &apm; libs

36

Page 37: BEM — Build ‘em Modular!

What BEM can do that others can't

37

Page 38: BEM — Build ‘em Modular!

Abstraction•  speak the same terms

•  code becomes self-documented

•  possibility to update components appear

38

Page 39: BEM — Build ‘em Modular!

In shortBlock

E lem

Modifier

39

Page 40: BEM — Build ‘em Modular!

Block

Page 41: BEM — Build ‘em Modular!

Block,        elements

Page 42: BEM — Build ‘em Modular!

Block,        elements,        modifiers

Page 43: BEM — Build ‘em Modular!
Page 44: BEM — Build ‘em Modular!
Page 45: BEM — Build ‘em Modular!

Naming conventionBlock__E lement_Modifier

45

Page 46: BEM — Build ‘em Modular!

Some of BEM principles•  Map document to BEM blocks — no tag or id selectors

•  No CSS outside of blocks

•  Independent blocks -> no global reset

•  Avoid cascade

46

Page 47: BEM — Build ‘em Modular!

File systemprj/

blocks/

header/

header.css

header.js

header.tmpl

header.svg

header.md 47

Page 48: BEM — Build ‘em Modular!

File systemprj/

blocks/

header/

_theme/

header_theme_simple.css

header_theme_full.css

__logo/

header__logo.css 48

Page 49: BEM — Build ‘em Modular!

BEM treeBefore:

div > div > span

After:

block1 > block2 > block2__elem

49

Page 50: BEM — Build ‘em Modular!

What is BEM now?•  methodology

•  libraries

•  tools

•  JS-framework

•  templating engine

•  engine for building docs and samples

•  tests for blocks

•  the community 50

Page 51: BEM — Build ‘em Modular!

BEM Platform: How to start?

51

Page 52: BEM — Build ‘em Modular!

Quick start•  bem.info

•  git clone https://github.com/bem/project-stub.git

52

Page 53: BEM — Build ‘em Modular!

bem.info

Page 54: BEM — Build ‘em Modular!