SlideShare uma empresa Scribd logo
1 de 65
Baixar para ler offline
Maintainable Frontend
Development with BEM


#b_

UI Framework Team Lead
Varvara Stepanova
It's me




3
Search
    Images   Video     Realty   Social

    Blogs    Apps      Jobs




    Maps             Mail       Marketplace   etc.




4
Next 30 minutes

    • Usual development cycle
    • Main problems it brings
    • BEM solutions to the problems
    • New development workflow
    • Recently happened in BEM world

5
Usually
Usual development cycle and problems




7
Usual development cycle and problems




    • decomposition – every time
    • every change starts from zero
    • cannot reuse your own work



8
BEM is a world on its own

     • methodology of modularity
     • file structure recommendations
     • reusable libraries
     • helpful tools & optimizers
     • template engine
10
Block • Element • Modifier

11
Block is an independent component




12
Page of blocks
                                          page.html
     <body class="page">

       <div class="header">
         <img class="logo" ... />
         <div class="search">...</div>
         <div class="menu">...</div>
       </div>

       <div class="layout">
         <div class="sidebar">...</div>
         <div class="menu">...</div>
       </div>

     </body>

13
Some blocks have elements




14
Block with elements
                                                  page.html

     <div class="tabbed-pane">
       <ul>
         <li class="tabbed-pane__tab">Tab1</li>
         <li class="tabbed-pane__tab">Tab2</li>
       </ul>
       <div class="tabbed-pane__panel">
         ...
       </div>
     </div>




15
Elements




16
Block of elements




17
Modifiers change blocks and elements

                    <div class="
                     tabbed-pane
                     tabbed-pane_theme_blue">
                      <!-- // -->
                    </div>


                    <div class="
                     tabbed-pane
                     tabbed-pane_to_bottom">
                      <!-- // -->
                    </div>

18
Block • Element • Modifier

19
What do we want?

1. Ever-changing layout
2. No copy-paste
3. Unified semantic
1. Ever-changing layout
Independent CSS blocks


     • are not affected by parents
     • do not affect children




22
Independent CSS blocks

     • a block has its name
      Not id but classname selectors
     • no tag selectors
     • avoid cascade

23
Cascade: a way to express dependency
                                                               CSS

     .header a {
        text-decoration: none;
     }
     .main .photo {              div.big_form .photo {
        width: 150px;              width: 250px;
        height: 150px;             height: 250px;
     }                           }
     .sidebar li {
        list-style: none;        .big_form .photo {
        display: inline-block;      width: 500px !important;
        padding: 0 0.5em;        }
     }

24
Improving rendering performance

     « The style system matches rules by starting with the key
      selector, then moving to the left (looking for any
      ancestors in the rule’s selector).
      David Hyatt, MDN




                         mzl.la/UuwZql


25
Who uses the method
     • Yandex
       bit.ly/bem-riga-2012
     • GitHub
       bit.ly/github-css
     • Harry Roberts
       inuitcss.com
     • OOCSS, SMACSS, etc.
26
2. No copy-paste
Each block is a separate CSS file

     blocks/

       search.css                 menu.css
       search__checkbox.css       menu__item.css
       search__autocomplete.css   menu_size_big.css

       tabbed-pane.css
       tabbed-pane__tab.css       book.css
       tabbed-pane__panel.css     book__title.css



28
...taken when you need it!
                                                   CSS

     @import url(blocks/header.css);
     @import url(blocks/search.css);
     @import url(blocks/tabbed-pane.css);
     @import url(blocks/tabbed-pane__tab.css);
     @import url(blocks/tabbed-pane__panel.css);
     @import url(blocks/book.css);
     @import url(blocks/book__image.css);
     @import url(blocks/menu.css);
     @import url(blocks/menu_size_big.css);
     @import url(blocks/menu__item.css);
     @import url(blocks/footer.css);

29
Easy to share


     • email to a friend
     • version control systems


30
Linking library to projects
          search         maps      market




31
Services are using two block levels
         search         maps           market




32
Project file structure with a library linked

     library/           # by linking a remote repo
        header.css
        footer.css
        menu.css
        ...

     blocks/
        header.css
        books.css
        vote.css


33
Redefining in CSS
                         library/header.css

     .header {

         color: red;

     }

                         blocks/header.css

     .header {

         color: green;

     }

34
Pick up from two levels
                                                           CSS

     @import url(library/blocks/header.css);

     @import url(library/blocks/search.css);
     @import url(blocks/search.css);

     @import url(library/blocks/tabbed-pane.css);
     @import url(library/blocks/tabbed-pane__tab.css);
     @import url(library/blocks/tabbed-pane__panel.css);
     @import url(blocks/book.css);
     @import url(blocks/book__image.css);
     @import url(library/blocks/menu.css);

35
Automation


     • Make
     • Rake
     • Grunt


36
BEM tools



     git.io/bem-tools


37
3. Unified semantic
Unified semantic
     Different implementations




39
Block: CSS + JavaScript


     blocks/

      book/                    search/
        book.css                 search.css

       menu/                   tabbed-pane/
        menu.css                 tabbed-pane.css
        menu.js                  tabbed-pane.js
        menu__item.css


40
Block: many technologies


     tabbed-pane/         search/
       tabbed-pane.css      search__autocomplete.css
       tabbed-pane.js       search__autocomplete.js
       tabbed-pane.xsl      search.css
                            search.js
     logo/                  search.xsl
       logo.png
       logo.css
       logo.xsl




41
Block: several templating solutions


     tabbed-pane/            search/
       tabbed-pane.css         search__autocomplete.css
       tabbed-pane.js          search__autocomplete.js
       tabbed-pane.xsl         search.css
       tabbed-pane.bemhtml     search.js
                               search.xsl
     logo/                     search.bemhtml
       logo.png
       logo.css
       logo.xsl
       logo.bemhtml

42
Block: documentation


     tabbed-pane/            search/
       tabbed-pane.css         search__autocomplete.css
       tabbed-pane.js          search__autocomplete.js
       tabbed-pane.bemhtml     search__autocomplete.md
       tabbed-pane.md          search.css
                               search.js
     logo/                     search.bemhtml
       logo.png                search.md
       logo.css
       logo.bemhtml
       logo.md

43
Services are using two block levels
         search         maps           market




44
New dev workflow
Breaking an interface into blocks




47
Fix. Grow. Improve.

     • single language
     • blocks are easy to add/move/remove
     • maintainability
     • non-stop refactoring ;-)


48
Do we like what robots like?
Nice development tools


     • BEM tools to build pages
     • Borschik to flatten the CSS and JS files
     • CSSO to optimize



50
CSS flattening with Borschik
                                                index.css

      @import url(blocks/header/header.css);
      @import url(blocks/menu/menu.css);
      ...

                                               _index.css

      .header {
        ...
      }
      .menu {
        ...
      }

51
JavaScript flattening with Borschik
                                                                  index.js

      /*borschik:include:blocks/menu/menu.js*/
      /*borschik:include:blocks/tabbed-pane/tabbed-pane.js*/
      ...

                                                                 _index.js

      /* Menu block begins */
      (function($) {
          $('.menu__item').on('click', function(e) {
              $(this).toggleClass('menu__item_state_current');
          });
      })(jQuery);

52
Nice development tools


     • BEM tools to build pages
     • Borschik to flatten the CSS and JS files
     • CSSO to optimize



53
Optimizing with CSSO
                            DEVELOPMENT

      .header {
        color: red;
      }

      .header {
        color: green;
      }

                             PRODUCTION

      .header {
        color: green;
      }

54
bem.info/tools
55
Recently in BEM world
The evolution of BEM
     by Max Shirshin and Vitaly Harisov




             bit.ly/bem-history


57
Several block libraries

     • common library of 100+ blocks
     • distinct libraries
        – search services
        – map services
        – image services
            ...

58
Linking several libraries to a project

     common-lib/             maps-lib/
       header/                map/
       footer/                map-point/
       layout/                ...
       ...

     search-lib/             blocks/
       header/                 books/
       search-form/            header/
       ...                     map-point/
                               ...

59
Any library needs...

     • web site
        – documentation
        – block examples
     • release workflow
        – changelogs
        – unit tests

60
Docs generating tool



     git.io/bem-gen-doc


61
What to do with BEM?
     • follow recommendations
       – modular everything (CSS, JS, etc.)
       – file structure
       – building projects
     • participate
     • write your own libraries
62
http://bem.info
63
Varvara Stepanova
     UI Framework Team Lead
     toivonen@yandex-team.ru
     @toivonens
     @bem_tw




Thank you
#b_

        Sunday, 24th Feb
     MeetUp onword.co/3002

65

Mais conteúdo relacionado

Mais procurados

DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...Jer Clarke
 
Responsive & Responsible Web Design in DNN
Responsive & Responsible Web Design in DNNResponsive & Responsible Web Design in DNN
Responsive & Responsible Web Design in DNNgravityworksdd
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionIn a Rocket
 
Decoupling the Front-end with Modular CSS
Decoupling the Front-end with Modular CSSDecoupling the Front-end with Modular CSS
Decoupling the Front-end with Modular CSSJulie Cameron
 
OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?Michael Posso
 
Component Driven Design and Development
Component Driven Design and DevelopmentComponent Driven Design and Development
Component Driven Design and DevelopmentCristina Chumillas
 
Doing More with LESS for CSS
Doing More with LESS for CSSDoing More with LESS for CSS
Doing More with LESS for CSSTodd Anglin
 
Modern Front-End Development
Modern Front-End DevelopmentModern Front-End Development
Modern Front-End Developmentmwrather
 
Front End Tooling and Performance - Codeaholics HK 2015
Front End Tooling and Performance - Codeaholics HK 2015Front End Tooling and Performance - Codeaholics HK 2015
Front End Tooling and Performance - Codeaholics HK 2015Holger Bartel
 
What is Object Oriented CSS?
What is Object Oriented CSS?What is Object Oriented CSS?
What is Object Oriented CSS?Nicole Sullivan
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation joilrahat
 
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017Morten Rand-Hendriksen
 
Twitter bootstrap
Twitter bootstrapTwitter bootstrap
Twitter bootstrapVeck Hsiao
 
Battle of the Front-End Frameworks: Bootstrap vs. Foundation
Battle of the Front-End Frameworks: Bootstrap vs. FoundationBattle of the Front-End Frameworks: Bootstrap vs. Foundation
Battle of the Front-End Frameworks: Bootstrap vs. FoundationRachel Cherry
 

Mais procurados (19)

DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
 
Responsive & Responsible Web Design in DNN
Responsive & Responsible Web Design in DNNResponsive & Responsible Web Design in DNN
Responsive & Responsible Web Design in DNN
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
Wordpress as a CMS
Wordpress as a CMSWordpress as a CMS
Wordpress as a CMS
 
Decoupling the Front-end with Modular CSS
Decoupling the Front-end with Modular CSSDecoupling the Front-end with Modular CSS
Decoupling the Front-end with Modular CSS
 
OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?
 
Bootstrap [part 2]
Bootstrap [part 2]Bootstrap [part 2]
Bootstrap [part 2]
 
Component Driven Design and Development
Component Driven Design and DevelopmentComponent Driven Design and Development
Component Driven Design and Development
 
Doing More with LESS for CSS
Doing More with LESS for CSSDoing More with LESS for CSS
Doing More with LESS for CSS
 
Bootstrap 3 Basic - Bangkok WordPress Meetup
Bootstrap 3 Basic - Bangkok WordPress MeetupBootstrap 3 Basic - Bangkok WordPress Meetup
Bootstrap 3 Basic - Bangkok WordPress Meetup
 
Modern Front-End Development
Modern Front-End DevelopmentModern Front-End Development
Modern Front-End Development
 
Ashish
AshishAshish
Ashish
 
Front End Tooling and Performance - Codeaholics HK 2015
Front End Tooling and Performance - Codeaholics HK 2015Front End Tooling and Performance - Codeaholics HK 2015
Front End Tooling and Performance - Codeaholics HK 2015
 
What is Object Oriented CSS?
What is Object Oriented CSS?What is Object Oriented CSS?
What is Object Oriented CSS?
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
 
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
 
Twitter bootstrap
Twitter bootstrapTwitter bootstrap
Twitter bootstrap
 
Battle of the Front-End Frameworks: Bootstrap vs. Foundation
Battle of the Front-End Frameworks: Bootstrap vs. FoundationBattle of the Front-End Frameworks: Bootstrap vs. Foundation
Battle of the Front-End Frameworks: Bootstrap vs. Foundation
 

Destaque

Сайт с нуля на полном стеке БЭМ-технологий
Сайт с нуля на полном стеке БЭМ-технологийСайт с нуля на полном стеке БЭМ-технологий
Сайт с нуля на полном стеке БЭМ-технологийYandex
 
bem-components — от методологии до full stack платформы
bem-components — от методологии до full stack платформыbem-components — от методологии до full stack платформы
bem-components — от методологии до full stack платформыYandex
 
Преимущества компонентной разработки для тестирования интерфейсов
Преимущества компонентной разработки для тестирования интерфейсовПреимущества компонентной разработки для тестирования интерфейсов
Преимущества компонентной разработки для тестирования интерфейсовYandex
 
От БЭМ-методологии до Мануфактуры проектов
От БЭМ-методологии до Мануфактуры проектовОт БЭМ-методологии до Мануфактуры проектов
От БЭМ-методологии до Мануфактуры проектовCodeFest
 
BEM for Javascript at CampJS III
BEM for Javascript at CampJS IIIBEM for Javascript at CampJS III
BEM for Javascript at CampJS IIIYandex
 
БЭМ в Мануфактуре
БЭМ в МануфактуреБЭМ в Мануфактуре
БЭМ в МануфактуреYandex
 
Тестирование CSS-регрессий с gemini – OdessaJS
Тестирование CSS-регрессий с gemini – OdessaJSТестирование CSS-регрессий с gemini – OdessaJS
Тестирование CSS-регрессий с gemini – OdessaJSSevInf
 
Вебинар по БЭМ: верстаем веб-страницу
Вебинар по БЭМ: верстаем веб-страницуВебинар по БЭМ: верстаем веб-страницу
Вебинар по БЭМ: верстаем веб-страницуYandex
 
Вебинар по БЭМ: сборка и оптимизация проекта
Вебинар по БЭМ: сборка и оптимизация проектаВебинар по БЭМ: сборка и оптимизация проекта
Вебинар по БЭМ: сборка и оптимизация проектаYandex
 
Beminar js
Beminar jsBeminar js
Beminar jsYandex
 
Bem presentation
Bem presentationBem presentation
Bem presentationFeCEAV
 
Mobile web-debug
Mobile web-debugMobile web-debug
Mobile web-debugFINN.no
 
Formularis - Post/Redirect/Get (ca)
Formularis - Post/Redirect/Get (ca)Formularis - Post/Redirect/Get (ca)
Formularis - Post/Redirect/Get (ca)Carlos Campderrós
 
A3 examen et corrige anglais 2012 1 am t2
A3 examen et corrige anglais 2012 1 am t2A3 examen et corrige anglais 2012 1 am t2
A3 examen et corrige anglais 2012 1 am t2Ahmed Mesellem
 
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamuk
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamukPemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamuk
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamukMuhammad Syahida
 
A1 examen et corrige his geo 2010 1-am t2
A1 examen et corrige his geo 2010 1-am t2A1 examen et corrige his geo 2010 1-am t2
A1 examen et corrige his geo 2010 1-am t2Ahmed Mesellem
 
Extracting ruby gem
Extracting ruby gemExtracting ruby gem
Extracting ruby gemYura Tolstik
 

Destaque (20)

Сайт с нуля на полном стеке БЭМ-технологий
Сайт с нуля на полном стеке БЭМ-технологийСайт с нуля на полном стеке БЭМ-технологий
Сайт с нуля на полном стеке БЭМ-технологий
 
bem-components — от методологии до full stack платформы
bem-components — от методологии до full stack платформыbem-components — от методологии до full stack платформы
bem-components — от методологии до full stack платформы
 
Преимущества компонентной разработки для тестирования интерфейсов
Преимущества компонентной разработки для тестирования интерфейсовПреимущества компонентной разработки для тестирования интерфейсов
Преимущества компонентной разработки для тестирования интерфейсов
 
От БЭМ-методологии до Мануфактуры проектов
От БЭМ-методологии до Мануфактуры проектовОт БЭМ-методологии до Мануфактуры проектов
От БЭМ-методологии до Мануфактуры проектов
 
BEM for Javascript at CampJS III
BEM for Javascript at CampJS IIIBEM for Javascript at CampJS III
BEM for Javascript at CampJS III
 
БЭМ в Мануфактуре
БЭМ в МануфактуреБЭМ в Мануфактуре
БЭМ в Мануфактуре
 
Тестирование CSS-регрессий с gemini – OdessaJS
Тестирование CSS-регрессий с gemini – OdessaJSТестирование CSS-регрессий с gemini – OdessaJS
Тестирование CSS-регрессий с gemini – OdessaJS
 
Вебинар по БЭМ: верстаем веб-страницу
Вебинар по БЭМ: верстаем веб-страницуВебинар по БЭМ: верстаем веб-страницу
Вебинар по БЭМ: верстаем веб-страницу
 
Вебинар по БЭМ: сборка и оптимизация проекта
Вебинар по БЭМ: сборка и оптимизация проектаВебинар по БЭМ: сборка и оптимизация проекта
Вебинар по БЭМ: сборка и оптимизация проекта
 
Beminar js
Beminar jsBeminar js
Beminar js
 
실전 Html5 guide
실전 Html5 guide실전 Html5 guide
실전 Html5 guide
 
Bem presentation
Bem presentationBem presentation
Bem presentation
 
Mobile web-debug
Mobile web-debugMobile web-debug
Mobile web-debug
 
Dia-logic
Dia-logicDia-logic
Dia-logic
 
Formularis - Post/Redirect/Get (ca)
Formularis - Post/Redirect/Get (ca)Formularis - Post/Redirect/Get (ca)
Formularis - Post/Redirect/Get (ca)
 
A3 examen et corrige anglais 2012 1 am t2
A3 examen et corrige anglais 2012 1 am t2A3 examen et corrige anglais 2012 1 am t2
A3 examen et corrige anglais 2012 1 am t2
 
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamuk
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamukPemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamuk
Pemanfaatan ekstrak serai(sitronela) sebagai pengusir nyamuk
 
Modular development
Modular developmentModular development
Modular development
 
A1 examen et corrige his geo 2010 1-am t2
A1 examen et corrige his geo 2010 1-am t2A1 examen et corrige his geo 2010 1-am t2
A1 examen et corrige his geo 2010 1-am t2
 
Extracting ruby gem
Extracting ruby gemExtracting ruby gem
Extracting ruby gem
 

Semelhante a Maintainable Frontend Development with BEM

BEM. What you can borrow from Yandex frontend dev
BEM. What you can borrow from Yandex frontend devBEM. What you can borrow from Yandex frontend dev
BEM. What you can borrow from Yandex frontend devVarya Stepanova
 
Css for Development
Css for DevelopmentCss for Development
Css for Developmenttsengsite
 
Advanced CSS Troubleshooting
Advanced CSS TroubleshootingAdvanced CSS Troubleshooting
Advanced CSS TroubleshootingDenise Jacobs
 
Stupid Index Block Tricks
Stupid Index Block TricksStupid Index Block Tricks
Stupid Index Block Trickshannonhill
 
Drupal Step-by-Step: How We Built Our Training Site, Part 2
Drupal Step-by-Step: How We Built Our Training Site, Part 2Drupal Step-by-Step: How We Built Our Training Site, Part 2
Drupal Step-by-Step: How We Built Our Training Site, Part 2Acquia
 
Build and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block PatternsBuild and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block PatternsPlasterdog Web Design
 
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...Modern Theming & The Future of WordPress- Working with Full Site Editing and ...
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...WP Engine
 
#2 - CSS Layouts Overview
#2 - CSS Layouts Overview#2 - CSS Layouts Overview
#2 - CSS Layouts Overviewiloveigloo
 
CSS workshop @ OutSystems
CSS workshop @ OutSystemsCSS workshop @ OutSystems
CSS workshop @ OutSystemsRuben Goncalves
 
Crash Course in Theme Surgery
Crash Course in Theme SurgeryCrash Course in Theme Surgery
Crash Course in Theme SurgeryRational Frank
 
Gutenberg (WidgiLabs Training Sessions)
Gutenberg  (WidgiLabs Training Sessions)Gutenberg  (WidgiLabs Training Sessions)
Gutenberg (WidgiLabs Training Sessions)Nuno Morgadinho
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflowPeter Kaizer
 
Untangling the web - fall2017 - class 4
Untangling the web - fall2017 - class 4Untangling the web - fall2017 - class 4
Untangling the web - fall2017 - class 4Derek Jacoby
 
Css week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandourCss week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandourOsama Ghandour Geris
 
Design Systems, Pattern Libraries & WordPress
Design Systems, Pattern Libraries & WordPressDesign Systems, Pattern Libraries & WordPress
Design Systems, Pattern Libraries & WordPressJesse James Arnold
 
Html and CSS 101 - hipages Group Friday talk
Html and CSS 101 - hipages Group Friday talkHtml and CSS 101 - hipages Group Friday talk
Html and CSS 101 - hipages Group Friday talkhipages
 
Be nice to your designers
Be nice to your designersBe nice to your designers
Be nice to your designersPai-Cheng Tao
 
Unic - frontend development-in-complex-projects
Unic - frontend development-in-complex-projectsUnic - frontend development-in-complex-projects
Unic - frontend development-in-complex-projectsUnic
 

Semelhante a Maintainable Frontend Development with BEM (20)

BEM. What you can borrow from Yandex frontend dev
BEM. What you can borrow from Yandex frontend devBEM. What you can borrow from Yandex frontend dev
BEM. What you can borrow from Yandex frontend dev
 
Css for Development
Css for DevelopmentCss for Development
Css for Development
 
Fewd week2 slides
Fewd week2 slidesFewd week2 slides
Fewd week2 slides
 
Advanced CSS Troubleshooting
Advanced CSS TroubleshootingAdvanced CSS Troubleshooting
Advanced CSS Troubleshooting
 
Stupid Index Block Tricks
Stupid Index Block TricksStupid Index Block Tricks
Stupid Index Block Tricks
 
Drupal Step-by-Step: How We Built Our Training Site, Part 2
Drupal Step-by-Step: How We Built Our Training Site, Part 2Drupal Step-by-Step: How We Built Our Training Site, Part 2
Drupal Step-by-Step: How We Built Our Training Site, Part 2
 
Build and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block PatternsBuild and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block Patterns
 
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...Modern Theming & The Future of WordPress- Working with Full Site Editing and ...
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...
 
#2 - CSS Layouts Overview
#2 - CSS Layouts Overview#2 - CSS Layouts Overview
#2 - CSS Layouts Overview
 
CSS workshop @ OutSystems
CSS workshop @ OutSystemsCSS workshop @ OutSystems
CSS workshop @ OutSystems
 
Crash Course in Theme Surgery
Crash Course in Theme SurgeryCrash Course in Theme Surgery
Crash Course in Theme Surgery
 
Gutenberg (WidgiLabs Training Sessions)
Gutenberg  (WidgiLabs Training Sessions)Gutenberg  (WidgiLabs Training Sessions)
Gutenberg (WidgiLabs Training Sessions)
 
Bootstrap [part 1]
Bootstrap [part 1]Bootstrap [part 1]
Bootstrap [part 1]
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflow
 
Untangling the web - fall2017 - class 4
Untangling the web - fall2017 - class 4Untangling the web - fall2017 - class 4
Untangling the web - fall2017 - class 4
 
Css week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandourCss week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandour
 
Design Systems, Pattern Libraries & WordPress
Design Systems, Pattern Libraries & WordPressDesign Systems, Pattern Libraries & WordPress
Design Systems, Pattern Libraries & WordPress
 
Html and CSS 101 - hipages Group Friday talk
Html and CSS 101 - hipages Group Friday talkHtml and CSS 101 - hipages Group Friday talk
Html and CSS 101 - hipages Group Friday talk
 
Be nice to your designers
Be nice to your designersBe nice to your designers
Be nice to your designers
 
Unic - frontend development-in-complex-projects
Unic - frontend development-in-complex-projectsUnic - frontend development-in-complex-projects
Unic - frontend development-in-complex-projects
 

Mais de Varya Stepanova

Design systems on the web
Design systems on the webDesign systems on the web
Design systems on the webVarya Stepanova
 
SC5 Style Guide Generator
SC5 Style Guide GeneratorSC5 Style Guide Generator
SC5 Style Guide GeneratorVarya Stepanova
 
Тема для WordPress в БЭМ
Тема для WordPress в БЭМТема для WordPress в БЭМ
Тема для WordPress в БЭМVarya Stepanova
 
Шаблонизатор BEMHTML
Шаблонизатор BEMHTMLШаблонизатор BEMHTML
Шаблонизатор BEMHTMLVarya Stepanova
 
Использование библиотеки bem-bl
Использование библиотеки bem-blИспользование библиотеки bem-bl
Использование библиотеки bem-blVarya Stepanova
 
JavaScript в БЭМ терминах
JavaScript в БЭМ терминахJavaScript в БЭМ терминах
JavaScript в БЭМ терминахVarya Stepanova
 
Использование библиотеки bem-bl
Использование библиотеки bem-blИспользование библиотеки bem-bl
Использование библиотеки bem-blVarya Stepanova
 

Mais de Varya Stepanova (8)

Design systems on the web
Design systems on the webDesign systems on the web
Design systems on the web
 
SC5 Style Guide Generator
SC5 Style Guide GeneratorSC5 Style Guide Generator
SC5 Style Guide Generator
 
The Thinking behind BEM
The Thinking behind BEMThe Thinking behind BEM
The Thinking behind BEM
 
Тема для WordPress в БЭМ
Тема для WordPress в БЭМТема для WordPress в БЭМ
Тема для WordPress в БЭМ
 
Шаблонизатор BEMHTML
Шаблонизатор BEMHTMLШаблонизатор BEMHTML
Шаблонизатор BEMHTML
 
Использование библиотеки bem-bl
Использование библиотеки bem-blИспользование библиотеки bem-bl
Использование библиотеки bem-bl
 
JavaScript в БЭМ терминах
JavaScript в БЭМ терминахJavaScript в БЭМ терминах
JavaScript в БЭМ терминах
 
Использование библиотеки bem-bl
Использование библиотеки bem-blИспользование библиотеки bem-bl
Использование библиотеки bem-bl
 

Último

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Último (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Maintainable Frontend Development with BEM

  • 1.
  • 2. Maintainable Frontend Development with BEM #b_ UI Framework Team Lead Varvara Stepanova
  • 4. Search Images Video Realty Social Blogs Apps Jobs Maps Mail Marketplace etc. 4
  • 5. Next 30 minutes • Usual development cycle • Main problems it brings • BEM solutions to the problems • New development workflow • Recently happened in BEM world 5
  • 7. Usual development cycle and problems 7
  • 8. Usual development cycle and problems • decomposition – every time • every change starts from zero • cannot reuse your own work 8
  • 9.
  • 10. BEM is a world on its own • methodology of modularity • file structure recommendations • reusable libraries • helpful tools & optimizers • template engine 10
  • 11. Block • Element • Modifier 11
  • 12. Block is an independent component 12
  • 13. Page of blocks page.html <body class="page"> <div class="header"> <img class="logo" ... /> <div class="search">...</div> <div class="menu">...</div> </div> <div class="layout"> <div class="sidebar">...</div> <div class="menu">...</div> </div> </body> 13
  • 14. Some blocks have elements 14
  • 15. Block with elements page.html <div class="tabbed-pane"> <ul> <li class="tabbed-pane__tab">Tab1</li> <li class="tabbed-pane__tab">Tab2</li> </ul> <div class="tabbed-pane__panel"> ... </div> </div> 15
  • 18. Modifiers change blocks and elements <div class=" tabbed-pane tabbed-pane_theme_blue"> <!-- // --> </div> <div class=" tabbed-pane tabbed-pane_to_bottom"> <!-- // --> </div> 18
  • 19. Block • Element • Modifier 19
  • 20. What do we want? 1. Ever-changing layout 2. No copy-paste 3. Unified semantic
  • 22. Independent CSS blocks • are not affected by parents • do not affect children 22
  • 23. Independent CSS blocks • a block has its name Not id but classname selectors • no tag selectors • avoid cascade 23
  • 24. Cascade: a way to express dependency CSS .header a { text-decoration: none; } .main .photo { div.big_form .photo { width: 150px; width: 250px; height: 150px; height: 250px; } } .sidebar li { list-style: none; .big_form .photo { display: inline-block; width: 500px !important; padding: 0 0.5em; } } 24
  • 25. Improving rendering performance « The style system matches rules by starting with the key selector, then moving to the left (looking for any ancestors in the rule’s selector). David Hyatt, MDN mzl.la/UuwZql 25
  • 26. Who uses the method • Yandex bit.ly/bem-riga-2012 • GitHub bit.ly/github-css • Harry Roberts inuitcss.com • OOCSS, SMACSS, etc. 26
  • 28. Each block is a separate CSS file blocks/ search.css menu.css search__checkbox.css menu__item.css search__autocomplete.css menu_size_big.css tabbed-pane.css tabbed-pane__tab.css book.css tabbed-pane__panel.css book__title.css 28
  • 29. ...taken when you need it! CSS @import url(blocks/header.css); @import url(blocks/search.css); @import url(blocks/tabbed-pane.css); @import url(blocks/tabbed-pane__tab.css); @import url(blocks/tabbed-pane__panel.css); @import url(blocks/book.css); @import url(blocks/book__image.css); @import url(blocks/menu.css); @import url(blocks/menu_size_big.css); @import url(blocks/menu__item.css); @import url(blocks/footer.css); 29
  • 30. Easy to share • email to a friend • version control systems 30
  • 31. Linking library to projects search maps market 31
  • 32. Services are using two block levels search maps market 32
  • 33. Project file structure with a library linked library/ # by linking a remote repo header.css footer.css menu.css ... blocks/ header.css books.css vote.css 33
  • 34. Redefining in CSS library/header.css .header { color: red; } blocks/header.css .header { color: green; } 34
  • 35. Pick up from two levels CSS @import url(library/blocks/header.css); @import url(library/blocks/search.css); @import url(blocks/search.css); @import url(library/blocks/tabbed-pane.css); @import url(library/blocks/tabbed-pane__tab.css); @import url(library/blocks/tabbed-pane__panel.css); @import url(blocks/book.css); @import url(blocks/book__image.css); @import url(library/blocks/menu.css); 35
  • 36. Automation • Make • Rake • Grunt 36
  • 37. BEM tools git.io/bem-tools 37
  • 39. Unified semantic Different implementations 39
  • 40. Block: CSS + JavaScript blocks/ book/ search/ book.css search.css menu/ tabbed-pane/ menu.css tabbed-pane.css menu.js tabbed-pane.js menu__item.css 40
  • 41. Block: many technologies tabbed-pane/ search/ tabbed-pane.css search__autocomplete.css tabbed-pane.js search__autocomplete.js tabbed-pane.xsl search.css search.js logo/ search.xsl logo.png logo.css logo.xsl 41
  • 42. Block: several templating solutions tabbed-pane/ search/ tabbed-pane.css search__autocomplete.css tabbed-pane.js search__autocomplete.js tabbed-pane.xsl search.css tabbed-pane.bemhtml search.js search.xsl logo/ search.bemhtml logo.png logo.css logo.xsl logo.bemhtml 42
  • 43. Block: documentation tabbed-pane/ search/ tabbed-pane.css search__autocomplete.css tabbed-pane.js search__autocomplete.js tabbed-pane.bemhtml search__autocomplete.md tabbed-pane.md search.css search.js logo/ search.bemhtml logo.png search.md logo.css logo.bemhtml logo.md 43
  • 44. Services are using two block levels search maps market 44
  • 46.
  • 47. Breaking an interface into blocks 47
  • 48. Fix. Grow. Improve. • single language • blocks are easy to add/move/remove • maintainability • non-stop refactoring ;-) 48
  • 49. Do we like what robots like?
  • 50. Nice development tools • BEM tools to build pages • Borschik to flatten the CSS and JS files • CSSO to optimize 50
  • 51. CSS flattening with Borschik index.css @import url(blocks/header/header.css); @import url(blocks/menu/menu.css); ... _index.css .header { ... } .menu { ... } 51
  • 52. JavaScript flattening with Borschik index.js /*borschik:include:blocks/menu/menu.js*/ /*borschik:include:blocks/tabbed-pane/tabbed-pane.js*/ ... _index.js /* Menu block begins */ (function($) { $('.menu__item').on('click', function(e) { $(this).toggleClass('menu__item_state_current'); }); })(jQuery); 52
  • 53. Nice development tools • BEM tools to build pages • Borschik to flatten the CSS and JS files • CSSO to optimize 53
  • 54. Optimizing with CSSO DEVELOPMENT .header { color: red; } .header { color: green; } PRODUCTION .header { color: green; } 54
  • 57. The evolution of BEM by Max Shirshin and Vitaly Harisov bit.ly/bem-history 57
  • 58. Several block libraries • common library of 100+ blocks • distinct libraries – search services – map services – image services ... 58
  • 59. Linking several libraries to a project common-lib/ maps-lib/ header/ map/ footer/ map-point/ layout/ ... ... search-lib/ blocks/ header/ books/ search-form/ header/ ... map-point/ ... 59
  • 60. Any library needs... • web site – documentation – block examples • release workflow – changelogs – unit tests 60
  • 61. Docs generating tool git.io/bem-gen-doc 61
  • 62. What to do with BEM? • follow recommendations – modular everything (CSS, JS, etc.) – file structure – building projects • participate • write your own libraries 62
  • 64. Varvara Stepanova UI Framework Team Lead toivonen@yandex-team.ru @toivonens @bem_tw Thank you
  • 65. #b_ Sunday, 24th Feb MeetUp onword.co/3002 65