SlideShare une entreprise Scribd logo
1  sur  50
BEM methodology overview
_by Oleksii Prohonnyi
DEFINITION
BEM (stands for Block, Element, Modifier)
It's a way of describing reality in code, a
range of patterns, and a way of thinking
about program entities regardless of
programming languages being used.
<bem.info>
HISTORY
From 2005
CSS classes for blocks got prefixes (b-, c-,
g-) to provide sort of a namespace
emulation in CSS.
Independent Block concept
was the basis of Yandex HTML layouts, was
featured at the ClientSide'2007 conference
in Moscow, Russia.
Absolutely Independept Block (AIB)
 Only classnames (not IDs) should be used to describe styles.
 Each block classname has a prefix.
 Any CSS rules except ones prefixed with g- must belong to a
block.
 Compound blocks were allowed (or sometimes, required) to have
nested blocks embedded.
 never match CSS to tagnames, use classnames for everything:
.b-user b -> .b-user .first-letter
 classnames for block elements must be prefixed with the parent
block name: .b-user .first-letter -> .b-user-first_letter
Prefixes and Modifications
Team invented four prefixes allowed for block names:
 b- common blocks
 h- holsters, used for gluing several elements together
 l- layout grids
 g- global styles
Modification can be defined as a specific state of a block, or as a
flag that holds some specific property.
Going open source
In 2010, team had published some code on
GitHub account to continue growing as an
open source project.
BEM: HOW IT WORKS?
BEM: HOW IT WORKS?
Mark out “blocks”
Definitions
Blocks
A block is an independent entity, a "building block" of an application.
A block can be either simple or compound (containing other blocks).
E.g. Search form block
Elements
An element is a part of a block that performs a certain function.
Elements are context-dependent: they only make sense in the
context of the block they belong to.
E.g. An input field and a button are elements of the Search Block
BEM: HOW IT WORKS?
Describe page layout in plain text
BEM: HOW IT WORKS?
Block independence
From the CSS point of view
 A block (or an element) must have a unique "name" (a CSS
class) that could be used in a CSS rule.
 HTML elements must not be used in CSS selectors (.menu td) as
such selectors are inherently not context-free.
 Cascading selectors should be avoided.
From the template engine perspective
 Blocks and elements must be described in the input data Blocks
(or elements) must have unique "names" to make things like
"Menu should be placed here" expressible in our templates.
 Blocks may appear anywhere in a BEM tree.
BEM: HOW IT WORKS?
Modifiers for blocks
BEM: HOW IT WORKS?
Subject-matter abstraction
BEM: HOW IT WORKS?
Blocks consistency
Blocks consistency
To have a block present on a page as a UI element it should be
implemented it in the following techs:
 Templates (XSL, TT2, JavaScript, etc), which turn block
declarations into HTML code
 CSS that describes appearance of the block
 A JavaScript implementation for the block, if a block has dynamic
behavior
 Images
 Documentation
Everything that constitutes a block is a block technology.
BEM: HOW IT WORKS?
Real examples
Real examples
All the services of Yandex have BEM in their CSS and JavaScript
code and XSL templates of the pages. E.g.
 Yandex.Maps
 Yandex.Images
 Yandex.Video
 Yandex.Auto
 Turkish Yandex
More examples:
 Rambler.News
 HeadHunter
 TNK Racing Team
LIBRARIES
BEM libraries
 bem-core is a core library required for starting your own BEM-
powered project. It provides sufficient number of blocks
necessary for client-side JavaScript coding and templating.
 bem-bl is an extended library that consists not only of basic
blocks but also of a number of generic solutions for displaying a
menu, text, logo, search tab, table and so on.
 bem-components is a library of web-forms management blocks.
It contains basic implementation techniques independent from
design and allows to apply optional themes such as new
Yandex.Islands design.
 More libraries
TOOLS
TOOLS
bem-tools
bem-tools
A toolkit for working with files based on BEM methodology.
It allows to:
 create entities
 build final runtime
 work with build declarations: merge, subtract and intersect them
 build the whole project using bem make command
 launch development server on the project source tree using bem
server command.
 Documentation: https://en.bem.info/tools/bem/bem-tools/
TOOLS
Testing
Testing
Gemini is the utility for regression testing of web pages appearance.
Its key features are:
 Compatibility with different browsers (see notes about IE);
 Ability to test separate sections of a web page;
 Position and size of an element are calculated including its box-shadow and
outline properties;
 Some special case differences between images (rendering artifacts, text
caret, etc.) are ignored;
 CSS test coverage statistics.
Documentation: https://en.bem.info/tools/testing/gemini/
html-differ
Documentation: https://en.bem.info/tools/testing/html-differ/
TOOLS
Optimizers
Optimizers
borschik is an extendable builder for text-based file formats. Its main
purpose is assembly of static files for web projects (CSS, JS, etc.).
Documentation: https://en.bem.info/tools/optimizers/borschik/
CSSO (CSS Optimizer) is a CSS minimizer unlike others. In
addition to usual minification techniques it can perform structural
optimization of CSS files, resulting in smaller file size compared to
other minifiers.
Documentation: https://en.bem.info/tools/optimizers/csso/
SVG Optimizer is a Nodejs-based tool for optimizing SVG vector
graphics files.
Documentation: https://en.bem.info/tools/optimizers/svgo/svgo/
TOOLS
Languages / Parsers
Languages / Parsers
OMetaJS is a JavaScript implementation of OMeta, an object-
oriented language for pattern matching.
Documentation: https://github.com/veged/ometa-js#ometajs
XJST is a DSL for universal data transformations with compiler
written on top of the node.js and ometajs and output code working
in any browser or on server-side.
Documentation: http://en.bem.info/tools/templating-engines/xjst/
Shmakowiki is yet another wiki dialect, inspired by WackoWiki and
WikiCreole.
Documentation: https://github.com/veged/shmakowiki
REFERENCES
References
 https://en.bem.info/
 http://getbem.com/
 https://github.com/bem
 https://css-tricks.com/bem-101/
 https://tech.yandex.ru/bem/
Oleksii Prohonnyi
facebook.com/oprohonnyi
linkedin.com/in/oprohonnyi

Contenu connexe

Tendances

Tendances (18)

Web Development - HTML, CSS, JavaScript
Web Development - HTML, CSS, JavaScriptWeb Development - HTML, CSS, JavaScript
Web Development - HTML, CSS, JavaScript
 
Rendering engine
Rendering engineRendering engine
Rendering engine
 
Extjs
ExtjsExtjs
Extjs
 
Dhtml sohaib ch
Dhtml sohaib chDhtml sohaib ch
Dhtml sohaib ch
 
Dhtml chapter2
Dhtml chapter2Dhtml chapter2
Dhtml chapter2
 
DHTML - Dynamic HTML
DHTML - Dynamic HTMLDHTML - Dynamic HTML
DHTML - Dynamic HTML
 
Html book2
Html book2Html book2
Html book2
 
Html viva questions
Html viva questionsHtml viva questions
Html viva questions
 
Dhtml
DhtmlDhtml
Dhtml
 
Web Design & Development Courses in Pune | 3DOT Technologies
Web Design & Development Courses  in Pune | 3DOT TechnologiesWeb Design & Development Courses  in Pune | 3DOT Technologies
Web Design & Development Courses in Pune | 3DOT Technologies
 
Dom structure
Dom structureDom structure
Dom structure
 
Xhtml
XhtmlXhtml
Xhtml
 
C language
C languageC language
C language
 
C language
C languageC language
C language
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
DHTML
DHTMLDHTML
DHTML
 
Web I - 02 - XHTML Introduction
Web I - 02 - XHTML IntroductionWeb I - 02 - XHTML Introduction
Web I - 02 - XHTML Introduction
 
Vskills certified css designer Notes
Vskills certified css designer NotesVskills certified css designer Notes
Vskills certified css designer Notes
 

En vedette

En vedette (11)

10 Commandments for efficient CSS architecture [CSSConf.Asia '14]
10 Commandments for efficient CSS architecture [CSSConf.Asia '14]10 Commandments for efficient CSS architecture [CSSConf.Asia '14]
10 Commandments for efficient CSS architecture [CSSConf.Asia '14]
 
Odnaleźć się w nanokosmosie
Odnaleźć się w nanokosmosieOdnaleźć się w nanokosmosie
Odnaleźć się w nanokosmosie
 
October 2014 - USG Rock Eagle - Sass 101
October 2014 - USG Rock Eagle - Sass 101October 2014 - USG Rock Eagle - Sass 101
October 2014 - USG Rock Eagle - Sass 101
 
BEVM ( block__element--variation -modifier)
BEVM ( block__element--variation -modifier)BEVM ( block__element--variation -modifier)
BEVM ( block__element--variation -modifier)
 
BEM : Block Element Modifier
BEM : Block Element ModifierBEM : Block Element Modifier
BEM : Block Element Modifier
 
The benefits of BEM CSS
The benefits of BEM CSSThe benefits of BEM CSS
The benefits of BEM CSS
 
BDD with JBehave and Selenium
BDD with JBehave and SeleniumBDD with JBehave and Selenium
BDD with JBehave and Selenium
 
Bem i SCSS na przykladzie inuit.css
Bem i SCSS na przykladzie inuit.cssBem i SCSS na przykladzie inuit.css
Bem i SCSS na przykladzie inuit.css
 
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
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
Enduring CSS
Enduring CSSEnduring CSS
Enduring CSS
 

Similaire à BEM methodology overview

Architecture Specification - Visual Modeling Tool
Architecture Specification - Visual Modeling ToolArchitecture Specification - Visual Modeling Tool
Architecture Specification - Visual Modeling Tool
Adriaan Venter
 
Feature and Solution Framework in SharePoint 2010, Ayman El-Hattab MVP
Feature and Solution Framework in SharePoint 2010, Ayman El-Hattab MVPFeature and Solution Framework in SharePoint 2010, Ayman El-Hattab MVP
Feature and Solution Framework in SharePoint 2010, Ayman El-Hattab MVP
Ayman El-Hattab
 
Site Templates in SP 13
Site Templates in SP 13Site Templates in SP 13
Site Templates in SP 13
Shahzad S
 

Similaire à BEM methodology overview (20)

BEM it!
BEM it!BEM it!
BEM it!
 
BEM It! for Brandwatch
BEM It! for BrandwatchBEM It! for Brandwatch
BEM It! for Brandwatch
 
BEM it! Introduction to BEM
BEM it! Introduction to BEMBEM it! Introduction to BEM
BEM it! Introduction to BEM
 
BEM
BEMBEM
BEM
 
Introduction to whats new in css3
Introduction to whats new in css3Introduction to whats new in css3
Introduction to whats new in css3
 
HTML and CSS Coding Standards
HTML and CSS Coding StandardsHTML and CSS Coding Standards
HTML and CSS Coding Standards
 
ASP.NET 06 - Customizing Your Sites Appearance
ASP.NET 06 - Customizing Your Sites AppearanceASP.NET 06 - Customizing Your Sites Appearance
ASP.NET 06 - Customizing Your Sites Appearance
 
Atomic design - Razvan Rosu
Atomic design - Razvan RosuAtomic design - Razvan Rosu
Atomic design - Razvan Rosu
 
Magento - Design Integration Guideline - Bysoft China
Magento - Design Integration Guideline - Bysoft ChinaMagento - Design Integration Guideline - Bysoft China
Magento - Design Integration Guideline - Bysoft China
 
Rock Solid CSS Architecture
Rock Solid CSS ArchitectureRock Solid CSS Architecture
Rock Solid CSS Architecture
 
Getting Started with Gutenberg Development
Getting Started with Gutenberg DevelopmentGetting Started with Gutenberg Development
Getting Started with Gutenberg Development
 
The Cascade is Dead
The Cascade is DeadThe Cascade is Dead
The Cascade is Dead
 
.NET Core, ASP.NET Core Course, Session 12
.NET Core, ASP.NET Core Course, Session 12.NET Core, ASP.NET Core Course, Session 12
.NET Core, ASP.NET Core Course, Session 12
 
Architecture Specification - Visual Modeling Tool
Architecture Specification - Visual Modeling ToolArchitecture Specification - Visual Modeling Tool
Architecture Specification - Visual Modeling Tool
 
Pem Overview20090130
Pem Overview20090130Pem Overview20090130
Pem Overview20090130
 
Feature and Solution Framework in SharePoint 2010, Ayman El-Hattab MVP
Feature and Solution Framework in SharePoint 2010, Ayman El-Hattab MVPFeature and Solution Framework in SharePoint 2010, Ayman El-Hattab MVP
Feature and Solution Framework in SharePoint 2010, Ayman El-Hattab MVP
 
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateBlog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
 
CSC103 Web Technologies: HTML, CSS, JS
CSC103 Web Technologies: HTML, CSS, JSCSC103 Web Technologies: HTML, CSS, JS
CSC103 Web Technologies: HTML, CSS, JS
 
Site Templates in SP 13
Site Templates in SP 13Site Templates in SP 13
Site Templates in SP 13
 
Wordpress workflow for an agency world
Wordpress workflow for an agency worldWordpress workflow for an agency world
Wordpress workflow for an agency world
 

Plus de Oleksii Prohonnyi

Plus de Oleksii Prohonnyi (20)

Utility libraries to make your life easier
Utility libraries to make your life easierUtility libraries to make your life easier
Utility libraries to make your life easier
 
Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 4: Angular 2.0Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 4: Angular 2.0
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
 
Dive into Angular, part 3: Performance
Dive into Angular, part 3: PerformanceDive into Angular, part 3: Performance
Dive into Angular, part 3: Performance
 
Dive into Angular, part 2: Architecture
Dive into Angular, part 2: ArchitectureDive into Angular, part 2: Architecture
Dive into Angular, part 2: Architecture
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: Introduction
 
Cycle.js overview
Cycle.js overviewCycle.js overview
Cycle.js overview
 
Moment.js overview
Moment.js overviewMoment.js overview
Moment.js overview
 
Bower introduction
Bower introductionBower introduction
Bower introduction
 
JavaScript Presentation Frameworks and Libraries
JavaScript Presentation Frameworks and LibrariesJavaScript Presentation Frameworks and Libraries
JavaScript Presentation Frameworks and Libraries
 
Introduction to D3.js
Introduction to D3.jsIntroduction to D3.js
Introduction to D3.js
 
Conference DotJS 2015 Paris review
Conference DotJS 2015 Paris reviewConference DotJS 2015 Paris review
Conference DotJS 2015 Paris review
 
Asm.js introduction
Asm.js introductionAsm.js introduction
Asm.js introduction
 
Code review process with JetBrains UpSource
Code review process with JetBrains UpSourceCode review process with JetBrains UpSource
Code review process with JetBrains UpSource
 
D3.JS Tips & Tricks (export to svg, crossfilter, maps etc.)
D3.JS Tips & Tricks (export to svg, crossfilter, maps etc.)D3.JS Tips & Tricks (export to svg, crossfilter, maps etc.)
D3.JS Tips & Tricks (export to svg, crossfilter, maps etc.)
 
OpenLayer's basics
OpenLayer's basicsOpenLayer's basics
OpenLayer's basics
 
Front-end rich JavaScript application creation (Backbone.js)
Front-end rich JavaScript application creation (Backbone.js)Front-end rich JavaScript application creation (Backbone.js)
Front-end rich JavaScript application creation (Backbone.js)
 
Как создать сайт за 2 часа? (Wordpress)
Как создать сайт за 2 часа? (Wordpress)Как создать сайт за 2 часа? (Wordpress)
Как создать сайт за 2 часа? (Wordpress)
 
Разработка веб-сайта. Сайт. Зачем он?
Разработка веб-сайта. Сайт. Зачем он?Разработка веб-сайта. Сайт. Зачем он?
Разработка веб-сайта. Сайт. Зачем он?
 
Google Chrome DevTools features overview
Google Chrome DevTools features overviewGoogle Chrome DevTools features overview
Google Chrome DevTools features overview
 

Dernier

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Dernier (20)

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 

BEM methodology overview

  • 1. BEM methodology overview _by Oleksii Prohonnyi
  • 3.
  • 4. BEM (stands for Block, Element, Modifier) It's a way of describing reality in code, a range of patterns, and a way of thinking about program entities regardless of programming languages being used. <bem.info>
  • 6. From 2005 CSS classes for blocks got prefixes (b-, c-, g-) to provide sort of a namespace emulation in CSS.
  • 7.
  • 8.
  • 9. Independent Block concept was the basis of Yandex HTML layouts, was featured at the ClientSide'2007 conference in Moscow, Russia.
  • 10. Absolutely Independept Block (AIB)  Only classnames (not IDs) should be used to describe styles.  Each block classname has a prefix.  Any CSS rules except ones prefixed with g- must belong to a block.  Compound blocks were allowed (or sometimes, required) to have nested blocks embedded.  never match CSS to tagnames, use classnames for everything: .b-user b -> .b-user .first-letter  classnames for block elements must be prefixed with the parent block name: .b-user .first-letter -> .b-user-first_letter
  • 11. Prefixes and Modifications Team invented four prefixes allowed for block names:  b- common blocks  h- holsters, used for gluing several elements together  l- layout grids  g- global styles Modification can be defined as a specific state of a block, or as a flag that holds some specific property.
  • 12. Going open source In 2010, team had published some code on GitHub account to continue growing as an open source project.
  • 13. BEM: HOW IT WORKS?
  • 14.
  • 15. BEM: HOW IT WORKS? Mark out “blocks”
  • 16.
  • 17. Definitions Blocks A block is an independent entity, a "building block" of an application. A block can be either simple or compound (containing other blocks). E.g. Search form block Elements An element is a part of a block that performs a certain function. Elements are context-dependent: they only make sense in the context of the block they belong to. E.g. An input field and a button are elements of the Search Block
  • 18.
  • 19. BEM: HOW IT WORKS? Describe page layout in plain text
  • 20.
  • 21.
  • 22. BEM: HOW IT WORKS? Block independence
  • 23.
  • 24. From the CSS point of view  A block (or an element) must have a unique "name" (a CSS class) that could be used in a CSS rule.  HTML elements must not be used in CSS selectors (.menu td) as such selectors are inherently not context-free.  Cascading selectors should be avoided.
  • 25. From the template engine perspective  Blocks and elements must be described in the input data Blocks (or elements) must have unique "names" to make things like "Menu should be placed here" expressible in our templates.  Blocks may appear anywhere in a BEM tree.
  • 26. BEM: HOW IT WORKS? Modifiers for blocks
  • 27.
  • 28.
  • 29.
  • 30. BEM: HOW IT WORKS? Subject-matter abstraction
  • 31.
  • 32. BEM: HOW IT WORKS? Blocks consistency
  • 33. Blocks consistency To have a block present on a page as a UI element it should be implemented it in the following techs:  Templates (XSL, TT2, JavaScript, etc), which turn block declarations into HTML code  CSS that describes appearance of the block  A JavaScript implementation for the block, if a block has dynamic behavior  Images  Documentation Everything that constitutes a block is a block technology.
  • 34. BEM: HOW IT WORKS? Real examples
  • 35. Real examples All the services of Yandex have BEM in their CSS and JavaScript code and XSL templates of the pages. E.g.  Yandex.Maps  Yandex.Images  Yandex.Video  Yandex.Auto  Turkish Yandex More examples:  Rambler.News  HeadHunter  TNK Racing Team
  • 37. BEM libraries  bem-core is a core library required for starting your own BEM- powered project. It provides sufficient number of blocks necessary for client-side JavaScript coding and templating.  bem-bl is an extended library that consists not only of basic blocks but also of a number of generic solutions for displaying a menu, text, logo, search tab, table and so on.  bem-components is a library of web-forms management blocks. It contains basic implementation techniques independent from design and allows to apply optional themes such as new Yandex.Islands design.  More libraries
  • 38. TOOLS
  • 40. bem-tools A toolkit for working with files based on BEM methodology. It allows to:  create entities  build final runtime  work with build declarations: merge, subtract and intersect them  build the whole project using bem make command  launch development server on the project source tree using bem server command.  Documentation: https://en.bem.info/tools/bem/bem-tools/
  • 42. Testing Gemini is the utility for regression testing of web pages appearance. Its key features are:  Compatibility with different browsers (see notes about IE);  Ability to test separate sections of a web page;  Position and size of an element are calculated including its box-shadow and outline properties;  Some special case differences between images (rendering artifacts, text caret, etc.) are ignored;  CSS test coverage statistics. Documentation: https://en.bem.info/tools/testing/gemini/ html-differ Documentation: https://en.bem.info/tools/testing/html-differ/
  • 44. Optimizers borschik is an extendable builder for text-based file formats. Its main purpose is assembly of static files for web projects (CSS, JS, etc.). Documentation: https://en.bem.info/tools/optimizers/borschik/ CSSO (CSS Optimizer) is a CSS minimizer unlike others. In addition to usual minification techniques it can perform structural optimization of CSS files, resulting in smaller file size compared to other minifiers. Documentation: https://en.bem.info/tools/optimizers/csso/ SVG Optimizer is a Nodejs-based tool for optimizing SVG vector graphics files. Documentation: https://en.bem.info/tools/optimizers/svgo/svgo/
  • 46. Languages / Parsers OMetaJS is a JavaScript implementation of OMeta, an object- oriented language for pattern matching. Documentation: https://github.com/veged/ometa-js#ometajs XJST is a DSL for universal data transformations with compiler written on top of the node.js and ometajs and output code working in any browser or on server-side. Documentation: http://en.bem.info/tools/templating-engines/xjst/ Shmakowiki is yet another wiki dialect, inspired by WackoWiki and WikiCreole. Documentation: https://github.com/veged/shmakowiki
  • 48. References  https://en.bem.info/  http://getbem.com/  https://github.com/bem  https://css-tricks.com/bem-101/  https://tech.yandex.ru/bem/
  • 49.