SlideShare uma empresa Scribd logo
1 de 37
Baixar para ler offline
BBEEMM MMEETTHHOODDOOLLOOGGYY
WHO AM I? 
ANDREW ROTA 
Interactive Developer at Sapient Global Markets 
I build HTML5 / JavaScript web applications 
I was a philosophy major 
I'm an avid sea kayaker
WHAT IS BEM? 
Block 
Element 
Modifier 
History 
tl;dr: Developed by Yandex, Russia's largest search engine 
company, in 2006/2007 to bring structure to web pages. 
Source: BEM
DDIISSOORRGGAANNIIZZEEDD 
Image by Source: davidd (CC BY 2.0
OOVVEERR SSPPEECCIIFFIICC
LLOOCCAATTIIOONN DDEEPPEENNDDEENNTT 
Image by Source: Guma89 (CC BY-SA 3.0)
ECOSYSTEM 
OOCSS 
.media {margin:10px;} 
.media, .bd {overflow:hidden; _overflow:visible; zoom:1;} 
.media .img {float:left; margin-right: 10px;} 
SMACSS 
.pod-callout { width: 200px; } 
.pod-callout input[type=text] { width: 180px; } 
Atomic CSS 
.M-1 {margin: 1px;} 
.M-2 {margin: 2px;} 
.M-4 {margin: 4px;}
BLOCK 
block /blɒk/ n : A block is an independent 
entity, a "building block" of an application. A 
block can be either simple or compound 
(containing other blocks). 
Source: BEM
BLOCKS 
Source: BEM
ELEMENT 
el•e•ment /ˈɛləmənt/ n : 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. 
Source: BEM
MODIFIER 
mod•i•fi•er /ˈmɒdəˌfaɪər/ n : A modifier is a 
property of a block or an element that alters its 
look or behavior. 
Source: BEM
MODIFIERS 
Source: BEM
BACK TO BLOCKS 
Source: BEM
MMAAPPPPIINNGG TTHHEE UUII
DEMO APP
DEMO APP
CSS PRINCIPLES 
Avoid descendent or other cascading selectors 
Element selectors must not be used 
CSS ID selectors must not be used
WRITING BLOCKS 
<nav> 
<ul> 
<li><a href="#">Breaking</a></li> 
<li><a href="#">World</a></li> 
<li><a href="#">U.S.</a></li> 
<li><a href="#">Business</a></li> 
<li><a href="#">Politics</a></li> 
<li><a href="#">Entertainment</a></li> 
<li><a href="#">Technology</a></li> 
<li><a href="#">Sports</a></li> 
</ul> 
</nav>
WRITING BLOCKS 
<nav class="nav-menu"> 
<ul> 
<li><a href="#">Breaking</a></li> 
<li><a href="#">World</a></li> 
<li><a href="#">U.S.</a></li> 
<li><a href="#">Business</a></li> 
<li><a href="#">Politics</a></li> 
<li><a href="#">Entertainment</a></li> 
<li><a href="#">Technology</a></li> 
<li><a href="#">Sports</a></li> 
</ul> 
</nav>
WRITING BLOCKS 
<nav class="nav-menu"> 
<ul class="nav-menu--items"> 
<li class="nav-menu--item"><a href="#">Breaking</a></li> 
<li class="nav-menu--item"><a href="#">World</a></li> 
<li class="nav-menu--item"><a href="#">U.S.</a></li> 
<li class="nav-menu--item"><a href="#">Business</a></li> 
<li class="nav-menu--item"><a href="#">Politics</a></li> 
<li class="nav-menu--item"><a href="#">Entertainment</a></li> 
<li class="nav-menu--item"><a href="#">Technology</a></li> 
<li class="nav-menu--item"><a href="#">Sports</a></li> 
</ul> 
</nav>
WRITING BLOCKS 
.nav-menu { 
display: block; 
margin: 0; 
padding: 0; 
width: 100%; 
float: right; 
} 
.nav-menu--items { 
margin: 0; 
padding: 0; 
} 
.nav-menu--item { 
float: left; 
list-style-type: none; 
margin-left: 0.5%; 
text-align: center; 
width: 12%; 
& > a { 
background: $primaryColor; 
color: white; 
display: block; 
font-size: .9em; 
line-height: 3.2; 
text-decoration: none; 
&:hover { 
background: $primaryColorLighter; 
-webkit-transform: rotate(10deg); 
transform: rotate(10deg);
DEFINE MODIFIERS 
.nav-menu--item__simple { 
@extend .nav-menu; 
display: inline; 
float: none; 
& > a { 
line-height: 1; 
text-decoration: none; 
} 
&:after { 
content: " | "; 
} 
&:last-child:after { 
content: ""; 
} 
}
BUILDING YOUR APPLICATION 
├── blocks 
│ ├── navMenu 
│ │ ├── navMenu.css 
│ │ ├── navMenuItem.css 
│ ├── logo 
│ │ └── logo.css 
│ ├── header 
│ │ └── header.css 
│ └── search 
│ │ ├── search.css 
│ │ └── search_autocomplete.css
DISADVANTAGES 
Repititive code 
Ugly 
Fighting the platform? 
Classitis
ADVANTAGE: NAMESPACING 
.my-component-name__title 
vs 
.my-component .title
OORRGGAANNIIZZAATTIIOONN 
Image by Stewart (CC BY 2.0)
ADVANTAGE: PROGRAMMATIC CONTROL 
block('navMenu').elem('item').click( ... ); 
block('navMenu').elem('item').setModifier('current'); 
Reference: BEM
ADVANTAGE: SHARED UI LANGUAGE 
There are only two hard things in Computer 
Science: cache invalidation and naming things.
PREPROCESSORS: LESS 
.block_name { 
&__element { 
color: #f00; 
&--modifier { 
font-weight: bold; 
} 
} 
} 
Produces 
.block_name__element { 
color: #f00; 
} .block_name__element--modifier { 
font-weight: bold; 
}
PREPROCESSORS: SASS 
$b: ".block_name"; 
#{$b}__element { 
color: #f00; 
} 
#{$b}__element--modifier { 
font-weight: bold; 
} 
Produces 
.block_name__element { 
color: #f00; 
} .block_name__element--modifier { 
font-weight: bold; 
}
PREPROCESSORS: STYLUS 
.block_name 
&__element 
color: #f00 
&--modifier 
font-weight: bold 
Produces 
.block_name__element { 
color: #f00; 
} .block_name__element--modifier { 
font-weight: bold; 
}
TOOLS AND FRAMEWORKS: BEMHTML 
{ 
block: 'navigation', 
content: [ 
{ 
elem: 'item', 
content: 'News' 
} 
] 
}
TOOLS AND FRAMEWORKS: CSSO 
.primary-navigation { 
font-size: 12px; 
color: red; 
font-weight: bold; 
} 
.secondary-navigation { 
color: red; 
font-weight: bold; 
} 
To... 
.primary-navigation{ 
font-size:12px 
} .primary-navigation, .secondary-navigation{ 
color:red; 
font-weight:bold 
}
TOOLS AND FRAMEWORKS: EMMET 
Rather than writing 
ul.primary-navigation>li.primary-navigation__item*5 
Instead write: 
ul.primary-navigation>li.-item*5|bem 
Results in: 
<ul class="primary-navigation"> 
<li class="primary-navigation__item"></li> 
<li class="primary-navigation__item"></li> 
<li class="primary-navigation__item"></li> 
<li class="primary-navigation__item"></li> 
<li class="primary-navigation__item"></li> 
</ul>
TOOLS AND FRAMEWORKS: INUIT.CSS 
Example: 
.pagination { 
text-align:center; 
letter-spacing:-0.31em; 
word-spacing:-0.43em; 
} [...] 
.pagination__first a:before { 
content:"00AB" "00A0"; 
} .pagination__last a:after { 
content:"00A0" "00BB"; 
}
THE FUTURE (?) 
mm/dd/yyyy 
Image by Sam Howzit (CC BY 2.0)

Mais conteúdo relacionado

Mais procurados

1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
apnwebdev
 

Mais procurados (20)

Automation Testing using Selenium Webdriver
Automation Testing using Selenium WebdriverAutomation Testing using Selenium Webdriver
Automation Testing using Selenium Webdriver
 
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOM
 
CSS
CSSCSS
CSS
 
Modern JS with ES6
Modern JS with ES6Modern JS with ES6
Modern JS with ES6
 
Webinar: Selenium WebDriver - Automation Uncomplicated
Webinar: Selenium WebDriver - Automation UncomplicatedWebinar: Selenium WebDriver - Automation Uncomplicated
Webinar: Selenium WebDriver - Automation Uncomplicated
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
 
Html n CSS
Html n CSSHtml n CSS
Html n CSS
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
 
HTML Fundamentals
HTML FundamentalsHTML Fundamentals
HTML Fundamentals
 
Sightly - Part 2
Sightly - Part 2Sightly - Part 2
Sightly - Part 2
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 
CSS Layouting #2 : Dimensi & Overflow
CSS Layouting #2 : Dimensi & OverflowCSS Layouting #2 : Dimensi & Overflow
CSS Layouting #2 : Dimensi & Overflow
 
Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
 
Laravel
LaravelLaravel
Laravel
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1
 
Front End Best Practices
Front End Best PracticesFront End Best Practices
Front End Best Practices
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 

Destaque

Destaque (20)

X ray detector
X ray detectorX ray detector
X ray detector
 
Antena array
Antena arrayAntena array
Antena array
 
Μάγια Ζαχαρίας
Μάγια ΖαχαρίαςΜάγια Ζαχαρίας
Μάγια Ζαχαρίας
 
Καβάφης Κωνσταντίνος
Καβάφης ΚωνσταντίνοςΚαβάφης Κωνσταντίνος
Καβάφης Κωνσταντίνος
 
Οδός στρατηγού μακρυγιάννη
Οδός στρατηγού μακρυγιάννηΟδός στρατηγού μακρυγιάννη
Οδός στρατηγού μακρυγιάννη
 
Το μεσαιωνικό κάστρο λεμεσού
Το μεσαιωνικό κάστρο λεμεσούΤο μεσαιωνικό κάστρο λεμεσού
Το μεσαιωνικό κάστρο λεμεσού
 
Οι διδυμοι πυργοι της Λεμεσου
Οι διδυμοι πυργοι της ΛεμεσουΟι διδυμοι πυργοι της Λεμεσου
Οι διδυμοι πυργοι της Λεμεσου
 
Καβάφης Κωνσταντίνος
Καβάφης ΚωνσταντίνοςΚαβάφης Κωνσταντίνος
Καβάφης Κωνσταντίνος
 
ΟΔΟΣ ΑΡΧΙΕΠΙΣΚΟΠΟΥ ΚΥΠΡΟΥ ΛΕΟΝΤΙΟΥ Α΄
ΟΔΟΣ ΑΡΧΙΕΠΙΣΚΟΠΟΥ ΚΥΠΡΟΥ ΛΕΟΝΤΙΟΥ Α΄ΟΔΟΣ ΑΡΧΙΕΠΙΣΚΟΠΟΥ ΚΥΠΡΟΥ ΛΕΟΝΤΙΟΥ Α΄
ΟΔΟΣ ΑΡΧΙΕΠΙΣΚΟΠΟΥ ΚΥΠΡΟΥ ΛΕΟΝΤΙΟΥ Α΄
 
RENNIE COWAN PHOTOGRAPHY
RENNIE COWAN PHOTOGRAPHYRENNIE COWAN PHOTOGRAPHY
RENNIE COWAN PHOTOGRAPHY
 
Hafil krk 2013
Hafil krk 2013Hafil krk 2013
Hafil krk 2013
 
RENNIE COWAN - COMMERCIAL REEL
RENNIE COWAN - COMMERCIAL REEL RENNIE COWAN - COMMERCIAL REEL
RENNIE COWAN - COMMERCIAL REEL
 
Οδός Χρυσανθου Επισκόπου Πάφου
Οδός Χρυσανθου Επισκόπου ΠάφουΟδός Χρυσανθου Επισκόπου Πάφου
Οδός Χρυσανθου Επισκόπου Πάφου
 
RENNIE COWAN - ART PIECES
RENNIE COWAN - ART PIECES RENNIE COWAN - ART PIECES
RENNIE COWAN - ART PIECES
 
Portugal x Brasil- No mercado de transferências de jogadores
Portugal x Brasil- No mercado de  transferências de jogadoresPortugal x Brasil- No mercado de  transferências de jogadores
Portugal x Brasil- No mercado de transferências de jogadores
 
Conventions of short films
Conventions of short filmsConventions of short films
Conventions of short films
 
Article
ArticleArticle
Article
 
Short film festivals
Short film festivalsShort film festivals
Short film festivals
 
Pecha Kucha -Ellie- ASSESSMENT 1 (Ophir/Lower Lewis Ponds Creek)
Pecha Kucha -Ellie- ASSESSMENT 1 (Ophir/Lower Lewis Ponds Creek)Pecha Kucha -Ellie- ASSESSMENT 1 (Ophir/Lower Lewis Ponds Creek)
Pecha Kucha -Ellie- ASSESSMENT 1 (Ophir/Lower Lewis Ponds Creek)
 
Καβάφης Κωνσταντίνος
Καβάφης ΚωνσταντίνοςΚαβάφης Κωνσταντίνος
Καβάφης Κωνσταντίνος
 

Semelhante a Bem methodology

Being a tweaker modern web performance techniques
Being a tweaker   modern web performance techniquesBeing a tweaker   modern web performance techniques
Being a tweaker modern web performance techniques
Chris Love
 
HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2
James Pearce
 

Semelhante a Bem methodology (20)

The Thinking behind BEM
The Thinking behind BEMThe Thinking behind BEM
The Thinking behind BEM
 
Building Web Hack Interfaces
Building Web Hack InterfacesBuilding Web Hack Interfaces
Building Web Hack Interfaces
 
Create Responsive Website Design with Bootstrap 3
Create Responsive Website Design with Bootstrap 3Create Responsive Website Design with Bootstrap 3
Create Responsive Website Design with Bootstrap 3
 
前端概述
前端概述前端概述
前端概述
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
 
Being a tweaker modern web performance techniques
Being a tweaker   modern web performance techniquesBeing a tweaker   modern web performance techniques
Being a tweaker modern web performance techniques
 
Slow kinda sucks
Slow kinda sucksSlow kinda sucks
Slow kinda sucks
 
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
 
Rapid HTML Prototyping with Bootstrap - Chris Griffith
Rapid HTML Prototyping with Bootstrap - Chris GriffithRapid HTML Prototyping with Bootstrap - Chris Griffith
Rapid HTML Prototyping with Bootstrap - Chris Griffith
 
HTML5 & CSS3 Flag
HTML5 & CSS3 FlagHTML5 & CSS3 Flag
HTML5 & CSS3 Flag
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
Diazo: Bridging Designers and Programmers
Diazo: Bridging Designers and ProgrammersDiazo: Bridging Designers and Programmers
Diazo: Bridging Designers and Programmers
 
Now you see me... Adaptive Web Design and Development
Now you see me... Adaptive Web Design and DevelopmentNow you see me... Adaptive Web Design and Development
Now you see me... Adaptive Web Design and Development
 
HTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.pptHTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.ppt
 
css.ppt
css.pptcss.ppt
css.ppt
 
css.ppt
css.pptcss.ppt
css.ppt
 
Semantic UI Introduction
Semantic UI IntroductionSemantic UI Introduction
Semantic UI Introduction
 
Web Projects: From Theory To Practice
Web Projects: From Theory To PracticeWeb Projects: From Theory To Practice
Web Projects: From Theory To Practice
 
Faster Frontends
Faster FrontendsFaster Frontends
Faster Frontends
 
HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2
 

Mais de Andrew Rota

Mais de Andrew Rota (18)

Integrating React.js Into a PHP Application: Dutch PHP 2019
Integrating React.js Into a PHP Application: Dutch PHP 2019Integrating React.js Into a PHP Application: Dutch PHP 2019
Integrating React.js Into a PHP Application: Dutch PHP 2019
 
Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Performant APIs with GraphQL and PHP (Dutch PHP 2019)Performant APIs with GraphQL and PHP (Dutch PHP 2019)
Performant APIs with GraphQL and PHP (Dutch PHP 2019)
 
Getting Started with GraphQL && PHP
Getting Started with GraphQL && PHPGetting Started with GraphQL && PHP
Getting Started with GraphQL && PHP
 
Tutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHPTutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHP
 
Building a GraphQL API in PHP
Building a GraphQL API in PHPBuilding a GraphQL API in PHP
Building a GraphQL API in PHP
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performance
 
Component Based UI Architectures for the Web
Component Based UI Architectures for the WebComponent Based UI Architectures for the Web
Component Based UI Architectures for the Web
 
Client-Side Performance Monitoring (MobileTea, Rome)
Client-Side Performance Monitoring (MobileTea, Rome)Client-Side Performance Monitoring (MobileTea, Rome)
Client-Side Performance Monitoring (MobileTea, Rome)
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
Effectively Monitoring Client-Side Performance
Effectively Monitoring Client-Side PerformanceEffectively Monitoring Client-Side Performance
Effectively Monitoring Client-Side Performance
 
UI Rendering at Wayfair
UI Rendering at WayfairUI Rendering at Wayfair
UI Rendering at Wayfair
 
Better PHP-Frontend Integration with Tungsten.js
Better PHP-Frontend Integration with Tungsten.jsBetter PHP-Frontend Integration with Tungsten.js
Better PHP-Frontend Integration with Tungsten.js
 
Tungsten.js: Building a Modular Framework
Tungsten.js: Building a Modular FrameworkTungsten.js: Building a Modular Framework
Tungsten.js: Building a Modular Framework
 
Why Static Type Checking is Better
Why Static Type Checking is BetterWhy Static Type Checking is Better
Why Static Type Checking is Better
 
An Exploration of Frameworks – and Why We Built Our Own
An Exploration of Frameworks – and Why We Built Our OwnAn Exploration of Frameworks – and Why We Built Our Own
An Exploration of Frameworks – and Why We Built Our Own
 
The Complementarity of React and Web Components
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web Components
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing Combination
 
Web Components and Modular CSS
Web Components and Modular CSSWeb Components and Modular CSS
Web Components and Modular CSS
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

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
 
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
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Bem methodology

  • 2. WHO AM I? ANDREW ROTA Interactive Developer at Sapient Global Markets I build HTML5 / JavaScript web applications I was a philosophy major I'm an avid sea kayaker
  • 3. WHAT IS BEM? Block Element Modifier History tl;dr: Developed by Yandex, Russia's largest search engine company, in 2006/2007 to bring structure to web pages. Source: BEM
  • 4.
  • 5. DDIISSOORRGGAANNIIZZEEDD Image by Source: davidd (CC BY 2.0
  • 7. LLOOCCAATTIIOONN DDEEPPEENNDDEENNTT Image by Source: Guma89 (CC BY-SA 3.0)
  • 8. ECOSYSTEM OOCSS .media {margin:10px;} .media, .bd {overflow:hidden; _overflow:visible; zoom:1;} .media .img {float:left; margin-right: 10px;} SMACSS .pod-callout { width: 200px; } .pod-callout input[type=text] { width: 180px; } Atomic CSS .M-1 {margin: 1px;} .M-2 {margin: 2px;} .M-4 {margin: 4px;}
  • 9. BLOCK block /blɒk/ n : A block is an independent entity, a "building block" of an application. A block can be either simple or compound (containing other blocks). Source: BEM
  • 11. ELEMENT el•e•ment /ˈɛləmənt/ n : 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. Source: BEM
  • 12. MODIFIER mod•i•fi•er /ˈmɒdəˌfaɪər/ n : A modifier is a property of a block or an element that alters its look or behavior. Source: BEM
  • 14. BACK TO BLOCKS Source: BEM
  • 18. CSS PRINCIPLES Avoid descendent or other cascading selectors Element selectors must not be used CSS ID selectors must not be used
  • 19. WRITING BLOCKS <nav> <ul> <li><a href="#">Breaking</a></li> <li><a href="#">World</a></li> <li><a href="#">U.S.</a></li> <li><a href="#">Business</a></li> <li><a href="#">Politics</a></li> <li><a href="#">Entertainment</a></li> <li><a href="#">Technology</a></li> <li><a href="#">Sports</a></li> </ul> </nav>
  • 20. WRITING BLOCKS <nav class="nav-menu"> <ul> <li><a href="#">Breaking</a></li> <li><a href="#">World</a></li> <li><a href="#">U.S.</a></li> <li><a href="#">Business</a></li> <li><a href="#">Politics</a></li> <li><a href="#">Entertainment</a></li> <li><a href="#">Technology</a></li> <li><a href="#">Sports</a></li> </ul> </nav>
  • 21. WRITING BLOCKS <nav class="nav-menu"> <ul class="nav-menu--items"> <li class="nav-menu--item"><a href="#">Breaking</a></li> <li class="nav-menu--item"><a href="#">World</a></li> <li class="nav-menu--item"><a href="#">U.S.</a></li> <li class="nav-menu--item"><a href="#">Business</a></li> <li class="nav-menu--item"><a href="#">Politics</a></li> <li class="nav-menu--item"><a href="#">Entertainment</a></li> <li class="nav-menu--item"><a href="#">Technology</a></li> <li class="nav-menu--item"><a href="#">Sports</a></li> </ul> </nav>
  • 22. WRITING BLOCKS .nav-menu { display: block; margin: 0; padding: 0; width: 100%; float: right; } .nav-menu--items { margin: 0; padding: 0; } .nav-menu--item { float: left; list-style-type: none; margin-left: 0.5%; text-align: center; width: 12%; & > a { background: $primaryColor; color: white; display: block; font-size: .9em; line-height: 3.2; text-decoration: none; &:hover { background: $primaryColorLighter; -webkit-transform: rotate(10deg); transform: rotate(10deg);
  • 23. DEFINE MODIFIERS .nav-menu--item__simple { @extend .nav-menu; display: inline; float: none; & > a { line-height: 1; text-decoration: none; } &:after { content: " | "; } &:last-child:after { content: ""; } }
  • 24. BUILDING YOUR APPLICATION ├── blocks │ ├── navMenu │ │ ├── navMenu.css │ │ ├── navMenuItem.css │ ├── logo │ │ └── logo.css │ ├── header │ │ └── header.css │ └── search │ │ ├── search.css │ │ └── search_autocomplete.css
  • 25. DISADVANTAGES Repititive code Ugly Fighting the platform? Classitis
  • 27. OORRGGAANNIIZZAATTIIOONN Image by Stewart (CC BY 2.0)
  • 28. ADVANTAGE: PROGRAMMATIC CONTROL block('navMenu').elem('item').click( ... ); block('navMenu').elem('item').setModifier('current'); Reference: BEM
  • 29. ADVANTAGE: SHARED UI LANGUAGE There are only two hard things in Computer Science: cache invalidation and naming things.
  • 30. PREPROCESSORS: LESS .block_name { &__element { color: #f00; &--modifier { font-weight: bold; } } } Produces .block_name__element { color: #f00; } .block_name__element--modifier { font-weight: bold; }
  • 31. PREPROCESSORS: SASS $b: ".block_name"; #{$b}__element { color: #f00; } #{$b}__element--modifier { font-weight: bold; } Produces .block_name__element { color: #f00; } .block_name__element--modifier { font-weight: bold; }
  • 32. PREPROCESSORS: STYLUS .block_name &__element color: #f00 &--modifier font-weight: bold Produces .block_name__element { color: #f00; } .block_name__element--modifier { font-weight: bold; }
  • 33. TOOLS AND FRAMEWORKS: BEMHTML { block: 'navigation', content: [ { elem: 'item', content: 'News' } ] }
  • 34. TOOLS AND FRAMEWORKS: CSSO .primary-navigation { font-size: 12px; color: red; font-weight: bold; } .secondary-navigation { color: red; font-weight: bold; } To... .primary-navigation{ font-size:12px } .primary-navigation, .secondary-navigation{ color:red; font-weight:bold }
  • 35. TOOLS AND FRAMEWORKS: EMMET Rather than writing ul.primary-navigation>li.primary-navigation__item*5 Instead write: ul.primary-navigation>li.-item*5|bem Results in: <ul class="primary-navigation"> <li class="primary-navigation__item"></li> <li class="primary-navigation__item"></li> <li class="primary-navigation__item"></li> <li class="primary-navigation__item"></li> <li class="primary-navigation__item"></li> </ul>
  • 36. TOOLS AND FRAMEWORKS: INUIT.CSS Example: .pagination { text-align:center; letter-spacing:-0.31em; word-spacing:-0.43em; } [...] .pagination__first a:before { content:"00AB" "00A0"; } .pagination__last a:after { content:"00A0" "00BB"; }
  • 37. THE FUTURE (?) mm/dd/yyyy Image by Sam Howzit (CC BY 2.0)