SlideShare ist ein Scribd-Unternehmen logo
1 von 65
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Component Driven Design and Development
Component Driven Design and DevelopmentComponent Driven Design and Development
Component Driven Design and Development
Cristina Chumillas
 

Was ist angesagt? (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
 

Andere mochten auch

bem-components — от методологии до full stack платформы
bem-components — от методологии до full stack платформыbem-components — от методологии до full stack платформы
bem-components — от методологии до full stack платформы
Yandex
 
BEM for Javascript at CampJS III
BEM for Javascript at CampJS IIIBEM for Javascript at CampJS III
BEM for Javascript at CampJS III
Yandex
 
Тестирование CSS-регрессий с gemini – OdessaJS
Тестирование CSS-регрессий с gemini – OdessaJSТестирование CSS-регрессий с gemini – OdessaJS
Тестирование CSS-регрессий с gemini – OdessaJS
SevInf
 
Beminar js
Beminar jsBeminar js
Beminar js
Yandex
 
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
Ahmed Mesellem
 
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
Ahmed Mesellem
 

Andere mochten auch (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
 

Ähnlich wie Maintainable Frontend Development with BEM

Css for Development
Css for DevelopmentCss for Development
Css for Development
tsengsite
 
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
Acquia
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflow
Peter Kaizer
 
Be nice to your designers
Be nice to your designersBe nice to your designers
Be nice to your designers
Pai-Cheng Tao
 

Ähnlich wie 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
 

Mehr von 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
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

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