SlideShare a Scribd company logo
Web Components and Modular CSS 
@AndrewRota | CSS Dev Conf 2014
Modularity
UI Libraries
CSS Features 
Encapsulation 
Scope 
Interfaces 
Modularity
Modular CSS Patterns 
BEM 
SMACSS 
Atomic CSS 
OOCSS
BEM 
/* Block */ 
.nav { } 
/* Element */ 
.nav__item { } 
/* Block with Modifier */ 
.nav--hidden { } 
/* Element with Modifier */ 
.nav__item--current { }
SMACSS 
/* Module */ 
.nav { } 
/* Module with State */ 
.nav.is-current { } 
/* Module with Semantic Element Selector */ 
.nav > h2 { } 
/* Layout Style */ 
.l-inline { }
Web Components 
Web Components usher in a 
new era of web development 
based on encapsulated and 
interoperable custom elements 
that extend HTML itself. - Polymer
Web Components APIs 
Custom Elements 
HTML Templates 
HTML Imports 
Shadow DOM
Custom Elements 
<my-element>Hello World.</my-element> 
var MyElement = document.registerElement('my-element', { 
prototype: Object.create(HTMLElement.prototype) 
});
HTML Templates 
<template id="my-template"> 
<p>Hello World.</p> 
<!-- This image won't be downloaded on page load --> 
<img src="example.jpg" alt="Example"> 
</template> 
document.importNode( 
document.getElementById('my-template').content, 
true 
);
HTML Imports 
<link rel="import" href="/imports/my-component.html">
Shadow DOM 
// Create Shadow Root 
document.getElementById('my-element').createShadowRoot(); 
// Access Shadow Root 
document.getElementById('my-element').shadowRoot;
User Agent Shadow DOM 
<video src="#" controls></video> 
0:00
User Agent Shadow DOM 
<input type="date"> 
mm/dd/yyyy
Shadow DOM 
Shadow DOM. 
Light DOM. 
<div id="my-first-element"></div><p>Light DOM.</p> 
// Create Shadow Root 
var s = document.getElementById('my-first-element').createShadowRoot 
// Add Styles and Text 
s.innerHTML += '<style>p { color: crimson; margin: 5px 0 5px 0;}</s.innerHTML += '<p>Shadow DOM.</p>';
Content Insertion Points 
<div id="my-second-element"> 
<content></content> 
</div>
Shadow DOM and <content> 
Shadow DOM Start. 
Hello! 
Shadow DOM End. 
<div id="my-second-element"><p>Hello!</p></div> 
var s = document.getElementById('my-second-element').createShadowRoot 
s.innerHTML += '<p>Shadow DOM Start.</p>'; 
s.innerHTML += '<style>p { color: crimson; margin: 5px 0; }</style>' 
s.innerHTML += '<content></content>'; 
s.innerHTML += '<p>Shadow DOM End.</p>';
Into the Light 
/* pseudo-class for host element*/ 
:host { } 
/* functional pseudo-class, for host if it matches the selector argument :host() { } 
/* functional pseudo-class, for host context that matches selector :host-context() { } 
/* pseudo-element, for distributed notes rendered via a <content> ::content { }
Into the Dark 
/* pseudo-element for shadow roots */ 
::shadow { } 
/* combinator for selecting through shadow boundaries */ 
body /deep/ p { } 
[/deep/] is basically a super-descendant 
combinator. 
- CSS Scoping Module Draft, Issue 6
Let's Write a Component 
Hello world, I am a web component. 
<link rel="import" href="../assets/hello-world.html"> 
<hello-world>I am a <strong>web component</strong></hello-world
Let's Write a Component 
Hello world, I am a web component. 
<template id="hw"> 
<style> 
::content strong { color: crimson; } 
p { margin: 2px 20px 2px 0; } 
:host { border: 1px solid FireBrick; display: block; margin-right 
.hello { color: #91D4D; } 
</style> 
<p><span class="hello">Hello world</span>, <content></content 
</template>
Let's Write a Component 
Hello world, I am a web component. 
var importedDoc = document.currentScript.ownerDocument; 
var elementPrototype = Object.create(HTMLElement.prototype); 
elementPrototype.createdCallback = function() { 
var template = importedDoc.getElementById('hw').content; 
var clone = document.importNode(template, true); 
this.createShadowRoot().appendChild(clone); 
}; 
document.registerElement('hello-world', {prototype: elementPrototype
Can I Use??? 
Custom 
Elements 
HTML 
Templates 
HTML 
Imports 
Shadow 
DOM 
- - - - 
- - - - 
Flag - Flag Flag 
X - X X 
X X X X
Polyfills
When To Use Web Components? 
Third Party Widgets? 
Third Party UI Libraries? 
Internal UI Libraries? 
Web Component All the Things!?
Third Party Widgets 
<google-map 
latitude="29.954356" 
longitude="-90.067863"> 
</google-map>
Third Party UI Libraries 
CSS HTML JS 
<paper-radio-group selected="css"> 
<paper-radio-button name="css" label="CSS"></paper-radio-button 
</paper-radio-group> 
<paper-slider value="10"></paper-slider>
Internal UI Libraries 
<acme-corp--menu> 
<acme-corp--menu-item>Home</acme-corp--menu-item> 
<acme-corp--menu-item selected>About</acme-corp--menu-item> 
<acme-corp--menu-item>Contact Us</acme-corp--menu-item> 
</acme-corp--menu> 
<acme-corp--login-form 
ajax 
url="login.php"> 
</acme-corp--login-form>
Web Component Everything?? 
<acme-corp--app> 
<acme-corp--menu></acme-corp--menu> 
<acme-corp--content></acme-corp--content> 
<acme-corp--footer></acme-corp--footer> 
</acme-corp--app>
Probably Not (and that's OK) 
I don't ever see us going all in 
on Custom Elements for every 
possible thing ... Use native 
elements and controls when 
possible and supplement with 
custom elements. 
- Joshua Peek, Github Programmer
Small 
Open for Extension 
Documented 
Unit Tested 
Accessible 
Responsive 
Best Practices
Tooling
Frameworks
Towards a Component Driven Web
Thanks! 
Resources 
- WebComponents.org 
- Web Components: A Tectonic Shift for Web Development by Eric Bidelman 
- Web Components by Jarrod Overson and Jason Strimpel 
- Ten Principles for Great General Purpose Web Components 
Colophon 
This presentation was built with Shadow DOM, HTML Templates, HTML 
Imports, and the Custom Elements <slide-show> and <slide-content> 
using Web Component Slides.
Web Components and Modular CSS
Web Components and Modular CSS
Web Components and Modular CSS
Web Components and Modular CSS
Web Components and Modular CSS
Web Components and Modular CSS
Web Components and Modular CSS
Web Components and Modular CSS
Web Components and Modular CSS
Web Components and Modular CSS
Ad

More Related Content

What's hot (20)

Google Polymer Framework
Google Polymer FrameworkGoogle Polymer Framework
Google Polymer Framework
Kostas Karolemeas
 
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
Andrew Rota
 
Polymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill LibraryPolymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill Library
naohito maeda
 
Polymer
Polymer Polymer
Polymer
jskvara
 
Polymer
PolymerPolymer
Polymer
LearningTech
 
Web Components
Web ComponentsWeb Components
Web Components
FITC
 
A brave new web - A talk about Web Components
A brave new web - A talk about Web ComponentsA brave new web - A talk about Web Components
A brave new web - A talk about Web Components
Michiel De Mey
 
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
GreeceJS
 
Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)
Hendrik Ebbers
 
HTML5 - Introduction
HTML5 - IntroductionHTML5 - Introduction
HTML5 - Introduction
Davy De Pauw
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talk
Imam Raza
 
Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14
mattsmcnulty
 
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
Andrew Rota
 
Web components
Web componentsWeb components
Web components
Gil Fink
 
Web Components
Web ComponentsWeb Components
Web Components
FITC
 
Build Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponentsBuild Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponents
Gil Fink
 
Intro to html 5
Intro to html 5Intro to html 5
Intro to html 5
Ian Jasper Mangampo
 
Web Components with Polymer (extra Polymer 2.0)
Web Components with Polymer (extra Polymer 2.0)Web Components with Polymer (extra Polymer 2.0)
Web Components with Polymer (extra Polymer 2.0)
Dhyego Fernando
 
Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16
John Riviello
 
Web components the future is here
Web components   the future is hereWeb components   the future is here
Web components the future is here
Gil Fink
 
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
Andrew Rota
 
Polymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill LibraryPolymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill Library
naohito maeda
 
Polymer
Polymer Polymer
Polymer
jskvara
 
Web Components
Web ComponentsWeb Components
Web Components
FITC
 
A brave new web - A talk about Web Components
A brave new web - A talk about Web ComponentsA brave new web - A talk about Web Components
A brave new web - A talk about Web Components
Michiel De Mey
 
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
GreeceJS
 
Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)Web Components & Polymer 1.0 (Webinale Berlin)
Web Components & Polymer 1.0 (Webinale Berlin)
Hendrik Ebbers
 
HTML5 - Introduction
HTML5 - IntroductionHTML5 - Introduction
HTML5 - Introduction
Davy De Pauw
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talk
Imam Raza
 
Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14
mattsmcnulty
 
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
Andrew Rota
 
Web components
Web componentsWeb components
Web components
Gil Fink
 
Web Components
Web ComponentsWeb Components
Web Components
FITC
 
Build Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponentsBuild Reusable Web Components using HTML5 Web cComponents
Build Reusable Web Components using HTML5 Web cComponents
Gil Fink
 
Web Components with Polymer (extra Polymer 2.0)
Web Components with Polymer (extra Polymer 2.0)Web Components with Polymer (extra Polymer 2.0)
Web Components with Polymer (extra Polymer 2.0)
Dhyego Fernando
 
Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16Custom Elements with Polymer Web Components #econfpsu16
Custom Elements with Polymer Web Components #econfpsu16
John Riviello
 
Web components the future is here
Web components   the future is hereWeb components   the future is here
Web components the future is here
Gil Fink
 

Viewers also liked (20)

Καβάφης Κωνσταντίνος
Καβάφης ΚωνσταντίνοςΚαβάφης Κωνσταντίνος
Καβάφης Κωνσταντίνος
nicolaidoumarina
 
ΟΙ ΖΟΥΛΟΥ Παναγιώτα
ΟΙ ΖΟΥΛΟΥ  ΠαναγιώταΟΙ ΖΟΥΛΟΥ  Παναγιώτα
ΟΙ ΖΟΥΛΟΥ Παναγιώτα
nicolaidoumarina
 
Mεσαιωνικο καστρο λεμεσου
Mεσαιωνικο καστρο λεμεσουMεσαιωνικο καστρο λεμεσου
Mεσαιωνικο καστρο λεμεσου
nicolaidoumarina
 
بحث د عهد حوري
بحث د عهد حوريبحث د عهد حوري
بحث د عهد حوري
محز اليسرى
 
Μάγια Ζαχαρίας
Μάγια ΖαχαρίαςΜάγια Ζαχαρίας
Μάγια Ζαχαρίας
nicolaidoumarina
 
49201940 schaffer-psihologia-copilului-partea-1
49201940 schaffer-psihologia-copilului-partea-149201940 schaffer-psihologia-copilului-partea-1
49201940 schaffer-psihologia-copilului-partea-1
Holhos Flavia
 
Το καστρο της λεμεσου
Το καστρο της λεμεσου Το καστρο της λεμεσου
Το καστρο της λεμεσου
nicolaidoumarina
 
What is a startup
What is a startupWhat is a startup
What is a startup
Mohammadreza Hosseini
 
Short film festivals
Short film festivalsShort film festivals
Short film festivals
pelboy123
 
Το μεσαιωνικό κάστρο λεμεσού
Το μεσαιωνικό κάστρο λεμεσούΤο μεσαιωνικό κάστρο λεμεσού
Το μεσαιωνικό κάστρο λεμεσού
nicolaidoumarina
 
Packpin SV2B presentation
Packpin SV2B presentationPackpin SV2B presentation
Packpin SV2B presentation
packpin
 
Passive voive
Passive voivePassive voive
Passive voive
I.U.P ¨Santiago Mariño¨
 
3d printing....science....
3d printing....science....3d printing....science....
3d printing....science....
ikbal ahmed
 
ΟΔΟΣ ΔΗΜΟΣΘΕΝΗ ΜΙΤΣΗ ΛΕΜΕΣΟΣ
ΟΔΟΣ ΔΗΜΟΣΘΕΝΗ ΜΙΤΣΗ ΛΕΜΕΣΟΣΟΔΟΣ ΔΗΜΟΣΘΕΝΗ ΜΙΤΣΗ ΛΕΜΕΣΟΣ
ΟΔΟΣ ΔΗΜΟΣΘΕΝΗ ΜΙΤΣΗ ΛΕΜΕΣΟΣ
nicolaidoumarina
 
Καβάφης Κωνσταντίνος
Καβάφης ΚωνσταντίνοςΚαβάφης Κωνσταντίνος
Καβάφης Κωνσταντίνος
nicolaidoumarina
 
Senarai nama tahun 1 (linus)
Senarai nama tahun 1 (linus)Senarai nama tahun 1 (linus)
Senarai nama tahun 1 (linus)
Ross Aaron
 
RENNIE COWAN - DIRECTOR REEL
RENNIE COWAN - DIRECTOR REEL RENNIE COWAN - DIRECTOR REEL
RENNIE COWAN - DIRECTOR REEL
Rennie_Cowan_Films_Art
 
ΟΔΟΣ Δ. ΜΙΤΣΗ ΛΕΜΕΣΟΣ
ΟΔΟΣ Δ. ΜΙΤΣΗ ΛΕΜΕΣΟΣΟΔΟΣ Δ. ΜΙΤΣΗ ΛΕΜΕΣΟΣ
ΟΔΟΣ Δ. ΜΙΤΣΗ ΛΕΜΕΣΟΣ
nicolaidoumarina
 
κάστρο του κολοσσιού
κάστρο του κολοσσιούκάστρο του κολοσσιού
κάστρο του κολοσσιού
nicolaidoumarina
 
RENNIE COWAN PHOTOGRAPHY
RENNIE COWAN PHOTOGRAPHYRENNIE COWAN PHOTOGRAPHY
RENNIE COWAN PHOTOGRAPHY
Rennie_Cowan_Films_Art
 
Καβάφης Κωνσταντίνος
Καβάφης ΚωνσταντίνοςΚαβάφης Κωνσταντίνος
Καβάφης Κωνσταντίνος
nicolaidoumarina
 
ΟΙ ΖΟΥΛΟΥ Παναγιώτα
ΟΙ ΖΟΥΛΟΥ  ΠαναγιώταΟΙ ΖΟΥΛΟΥ  Παναγιώτα
ΟΙ ΖΟΥΛΟΥ Παναγιώτα
nicolaidoumarina
 
Mεσαιωνικο καστρο λεμεσου
Mεσαιωνικο καστρο λεμεσουMεσαιωνικο καστρο λεμεσου
Mεσαιωνικο καστρο λεμεσου
nicolaidoumarina
 
Μάγια Ζαχαρίας
Μάγια ΖαχαρίαςΜάγια Ζαχαρίας
Μάγια Ζαχαρίας
nicolaidoumarina
 
49201940 schaffer-psihologia-copilului-partea-1
49201940 schaffer-psihologia-copilului-partea-149201940 schaffer-psihologia-copilului-partea-1
49201940 schaffer-psihologia-copilului-partea-1
Holhos Flavia
 
Το καστρο της λεμεσου
Το καστρο της λεμεσου Το καστρο της λεμεσου
Το καστρο της λεμεσου
nicolaidoumarina
 
Short film festivals
Short film festivalsShort film festivals
Short film festivals
pelboy123
 
Το μεσαιωνικό κάστρο λεμεσού
Το μεσαιωνικό κάστρο λεμεσούΤο μεσαιωνικό κάστρο λεμεσού
Το μεσαιωνικό κάστρο λεμεσού
nicolaidoumarina
 
Packpin SV2B presentation
Packpin SV2B presentationPackpin SV2B presentation
Packpin SV2B presentation
packpin
 
3d printing....science....
3d printing....science....3d printing....science....
3d printing....science....
ikbal ahmed
 
ΟΔΟΣ ΔΗΜΟΣΘΕΝΗ ΜΙΤΣΗ ΛΕΜΕΣΟΣ
ΟΔΟΣ ΔΗΜΟΣΘΕΝΗ ΜΙΤΣΗ ΛΕΜΕΣΟΣΟΔΟΣ ΔΗΜΟΣΘΕΝΗ ΜΙΤΣΗ ΛΕΜΕΣΟΣ
ΟΔΟΣ ΔΗΜΟΣΘΕΝΗ ΜΙΤΣΗ ΛΕΜΕΣΟΣ
nicolaidoumarina
 
Καβάφης Κωνσταντίνος
Καβάφης ΚωνσταντίνοςΚαβάφης Κωνσταντίνος
Καβάφης Κωνσταντίνος
nicolaidoumarina
 
Senarai nama tahun 1 (linus)
Senarai nama tahun 1 (linus)Senarai nama tahun 1 (linus)
Senarai nama tahun 1 (linus)
Ross Aaron
 
ΟΔΟΣ Δ. ΜΙΤΣΗ ΛΕΜΕΣΟΣ
ΟΔΟΣ Δ. ΜΙΤΣΗ ΛΕΜΕΣΟΣΟΔΟΣ Δ. ΜΙΤΣΗ ΛΕΜΕΣΟΣ
ΟΔΟΣ Δ. ΜΙΤΣΗ ΛΕΜΕΣΟΣ
nicolaidoumarina
 
κάστρο του κολοσσιού
κάστρο του κολοσσιούκάστρο του κολοσσιού
κάστρο του κολοσσιού
nicolaidoumarina
 
Ad

Similar to Web Components and Modular CSS (20)

Polymer 1.0
Polymer 1.0Polymer 1.0
Polymer 1.0
Cyril Balit
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
cherukumilli2
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon Gauvin
Simon Gauvin
 
Polymer - Lego for the web!
Polymer - Lego for the web!Polymer - Lego for the web!
Polymer - Lego for the web!
Codemotion
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the future
DA-14
 
Web components
Web componentsWeb components
Web components
Noam Kfir
 
Up & Running with Polymer
Up & Running with PolymerUp & Running with Polymer
Up & Running with Polymer
Fiyaz Hasan
 
Web Components: The future of Web Application Development
Web Components: The future of Web Application DevelopmentWeb Components: The future of Web Application Development
Web Components: The future of Web Application Development
Jermaine Oppong
 
Devoxx 2014-webComponents
Devoxx 2014-webComponentsDevoxx 2014-webComponents
Devoxx 2014-webComponents
Cyril Balit
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
Dmitry Buzdin
 
e-suap - client technologies- english version
e-suap - client technologies- english versione-suap - client technologies- english version
e-suap - client technologies- english version
Sabino Labarile
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
Vivek Rajan
 
Polytechnic 1.0 Granada
Polytechnic 1.0 GranadaPolytechnic 1.0 Granada
Polytechnic 1.0 Granada
Israel Blancas
 
Introduction to web compoents
Introduction to web compoentsIntroduction to web compoents
Introduction to web compoents
Ran Wahle
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
Mike Wilcox
 
Orchard Harvest 2014 - The Future of Widgets?
Orchard Harvest 2014 - The Future of Widgets?Orchard Harvest 2014 - The Future of Widgets?
Orchard Harvest 2014 - The Future of Widgets?
Steve Taylor
 
Front End Good Practices
Front End Good PracticesFront End Good Practices
Front End Good Practices
Hernan Mammana
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
Tudor Barbu
 
Polymer Code Lab in Dart - DevFest Kraków 2014
Polymer Code Lab in Dart - DevFest Kraków 2014Polymer Code Lab in Dart - DevFest Kraków 2014
Polymer Code Lab in Dart - DevFest Kraków 2014
jskvara
 
Web Components - The Future is Here
Web Components - The Future is HereWeb Components - The Future is Here
Web Components - The Future is Here
Gil Fink
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
cherukumilli2
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon Gauvin
Simon Gauvin
 
Polymer - Lego for the web!
Polymer - Lego for the web!Polymer - Lego for the web!
Polymer - Lego for the web!
Codemotion
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the future
DA-14
 
Web components
Web componentsWeb components
Web components
Noam Kfir
 
Up & Running with Polymer
Up & Running with PolymerUp & Running with Polymer
Up & Running with Polymer
Fiyaz Hasan
 
Web Components: The future of Web Application Development
Web Components: The future of Web Application DevelopmentWeb Components: The future of Web Application Development
Web Components: The future of Web Application Development
Jermaine Oppong
 
Devoxx 2014-webComponents
Devoxx 2014-webComponentsDevoxx 2014-webComponents
Devoxx 2014-webComponents
Cyril Balit
 
e-suap - client technologies- english version
e-suap - client technologies- english versione-suap - client technologies- english version
e-suap - client technologies- english version
Sabino Labarile
 
Polytechnic 1.0 Granada
Polytechnic 1.0 GranadaPolytechnic 1.0 Granada
Polytechnic 1.0 Granada
Israel Blancas
 
Introduction to web compoents
Introduction to web compoentsIntroduction to web compoents
Introduction to web compoents
Ran Wahle
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
Mike Wilcox
 
Orchard Harvest 2014 - The Future of Widgets?
Orchard Harvest 2014 - The Future of Widgets?Orchard Harvest 2014 - The Future of Widgets?
Orchard Harvest 2014 - The Future of Widgets?
Steve Taylor
 
Front End Good Practices
Front End Good PracticesFront End Good Practices
Front End Good Practices
Hernan Mammana
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
Tudor Barbu
 
Polymer Code Lab in Dart - DevFest Kraków 2014
Polymer Code Lab in Dart - DevFest Kraków 2014Polymer Code Lab in Dart - DevFest Kraków 2014
Polymer Code Lab in Dart - DevFest Kraków 2014
jskvara
 
Web Components - The Future is Here
Web Components - The Future is HereWeb Components - The Future is Here
Web Components - The Future is Here
Gil Fink
 
Ad

More from Andrew Rota (16)

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
Andrew Rota
 
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)
Andrew Rota
 
Getting Started with GraphQL && PHP
Getting Started with GraphQL && PHPGetting Started with GraphQL && PHP
Getting Started with GraphQL && PHP
Andrew Rota
 
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
Andrew Rota
 
Building a GraphQL API in PHP
Building a GraphQL API in PHPBuilding a GraphQL API in PHP
Building a GraphQL API in PHP
Andrew Rota
 
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
Andrew Rota
 
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
Andrew Rota
 
Client-Side Performance Monitoring (MobileTea, Rome)
Client-Side Performance Monitoring (MobileTea, Rome)Client-Side Performance Monitoring (MobileTea, Rome)
Client-Side Performance Monitoring (MobileTea, Rome)
Andrew Rota
 
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
Andrew Rota
 
Effectively Monitoring Client-Side Performance
Effectively Monitoring Client-Side PerformanceEffectively Monitoring Client-Side Performance
Effectively Monitoring Client-Side Performance
Andrew Rota
 
UI Rendering at Wayfair
UI Rendering at WayfairUI Rendering at Wayfair
UI Rendering at Wayfair
Andrew Rota
 
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
Andrew Rota
 
Tungsten.js: Building a Modular Framework
Tungsten.js: Building a Modular FrameworkTungsten.js: Building a Modular Framework
Tungsten.js: Building a Modular Framework
Andrew Rota
 
Why Static Type Checking is Better
Why Static Type Checking is BetterWhy Static Type Checking is Better
Why Static Type Checking is Better
Andrew Rota
 
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
Andrew Rota
 
Bem methodology
Bem methodologyBem methodology
Bem methodology
Andrew Rota
 
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
Andrew Rota
 
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)
Andrew Rota
 
Getting Started with GraphQL && PHP
Getting Started with GraphQL && PHPGetting Started with GraphQL && PHP
Getting Started with GraphQL && PHP
Andrew Rota
 
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
Andrew Rota
 
Building a GraphQL API in PHP
Building a GraphQL API in PHPBuilding a GraphQL API in PHP
Building a GraphQL API in PHP
Andrew Rota
 
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
Andrew Rota
 
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
Andrew Rota
 
Client-Side Performance Monitoring (MobileTea, Rome)
Client-Side Performance Monitoring (MobileTea, Rome)Client-Side Performance Monitoring (MobileTea, Rome)
Client-Side Performance Monitoring (MobileTea, Rome)
Andrew Rota
 
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
Andrew Rota
 
Effectively Monitoring Client-Side Performance
Effectively Monitoring Client-Side PerformanceEffectively Monitoring Client-Side Performance
Effectively Monitoring Client-Side Performance
Andrew Rota
 
UI Rendering at Wayfair
UI Rendering at WayfairUI Rendering at Wayfair
UI Rendering at Wayfair
Andrew Rota
 
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
Andrew Rota
 
Tungsten.js: Building a Modular Framework
Tungsten.js: Building a Modular FrameworkTungsten.js: Building a Modular Framework
Tungsten.js: Building a Modular Framework
Andrew Rota
 
Why Static Type Checking is Better
Why Static Type Checking is BetterWhy Static Type Checking is Better
Why Static Type Checking is Better
Andrew Rota
 
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
Andrew Rota
 

Recently uploaded (20)

Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 

Web Components and Modular CSS

  • 1. Web Components and Modular CSS @AndrewRota | CSS Dev Conf 2014
  • 4. CSS Features Encapsulation Scope Interfaces Modularity
  • 5. Modular CSS Patterns BEM SMACSS Atomic CSS OOCSS
  • 6. BEM /* Block */ .nav { } /* Element */ .nav__item { } /* Block with Modifier */ .nav--hidden { } /* Element with Modifier */ .nav__item--current { }
  • 7. SMACSS /* Module */ .nav { } /* Module with State */ .nav.is-current { } /* Module with Semantic Element Selector */ .nav > h2 { } /* Layout Style */ .l-inline { }
  • 8. Web Components Web Components usher in a new era of web development based on encapsulated and interoperable custom elements that extend HTML itself. - Polymer
  • 9. Web Components APIs Custom Elements HTML Templates HTML Imports Shadow DOM
  • 10. Custom Elements <my-element>Hello World.</my-element> var MyElement = document.registerElement('my-element', { prototype: Object.create(HTMLElement.prototype) });
  • 11. HTML Templates <template id="my-template"> <p>Hello World.</p> <!-- This image won't be downloaded on page load --> <img src="example.jpg" alt="Example"> </template> document.importNode( document.getElementById('my-template').content, true );
  • 12. HTML Imports <link rel="import" href="/imports/my-component.html">
  • 13. Shadow DOM // Create Shadow Root document.getElementById('my-element').createShadowRoot(); // Access Shadow Root document.getElementById('my-element').shadowRoot;
  • 14. User Agent Shadow DOM <video src="#" controls></video> 0:00
  • 15. User Agent Shadow DOM <input type="date"> mm/dd/yyyy
  • 16. Shadow DOM Shadow DOM. Light DOM. <div id="my-first-element"></div><p>Light DOM.</p> // Create Shadow Root var s = document.getElementById('my-first-element').createShadowRoot // Add Styles and Text s.innerHTML += '<style>p { color: crimson; margin: 5px 0 5px 0;}</s.innerHTML += '<p>Shadow DOM.</p>';
  • 17. Content Insertion Points <div id="my-second-element"> <content></content> </div>
  • 18. Shadow DOM and <content> Shadow DOM Start. Hello! Shadow DOM End. <div id="my-second-element"><p>Hello!</p></div> var s = document.getElementById('my-second-element').createShadowRoot s.innerHTML += '<p>Shadow DOM Start.</p>'; s.innerHTML += '<style>p { color: crimson; margin: 5px 0; }</style>' s.innerHTML += '<content></content>'; s.innerHTML += '<p>Shadow DOM End.</p>';
  • 19. Into the Light /* pseudo-class for host element*/ :host { } /* functional pseudo-class, for host if it matches the selector argument :host() { } /* functional pseudo-class, for host context that matches selector :host-context() { } /* pseudo-element, for distributed notes rendered via a <content> ::content { }
  • 20. Into the Dark /* pseudo-element for shadow roots */ ::shadow { } /* combinator for selecting through shadow boundaries */ body /deep/ p { } [/deep/] is basically a super-descendant combinator. - CSS Scoping Module Draft, Issue 6
  • 21. Let's Write a Component Hello world, I am a web component. <link rel="import" href="../assets/hello-world.html"> <hello-world>I am a <strong>web component</strong></hello-world
  • 22. Let's Write a Component Hello world, I am a web component. <template id="hw"> <style> ::content strong { color: crimson; } p { margin: 2px 20px 2px 0; } :host { border: 1px solid FireBrick; display: block; margin-right .hello { color: #91D4D; } </style> <p><span class="hello">Hello world</span>, <content></content </template>
  • 23. Let's Write a Component Hello world, I am a web component. var importedDoc = document.currentScript.ownerDocument; var elementPrototype = Object.create(HTMLElement.prototype); elementPrototype.createdCallback = function() { var template = importedDoc.getElementById('hw').content; var clone = document.importNode(template, true); this.createShadowRoot().appendChild(clone); }; document.registerElement('hello-world', {prototype: elementPrototype
  • 24. Can I Use??? Custom Elements HTML Templates HTML Imports Shadow DOM - - - - - - - - Flag - Flag Flag X - X X X X X X
  • 26. When To Use Web Components? Third Party Widgets? Third Party UI Libraries? Internal UI Libraries? Web Component All the Things!?
  • 27. Third Party Widgets <google-map latitude="29.954356" longitude="-90.067863"> </google-map>
  • 28. Third Party UI Libraries CSS HTML JS <paper-radio-group selected="css"> <paper-radio-button name="css" label="CSS"></paper-radio-button </paper-radio-group> <paper-slider value="10"></paper-slider>
  • 29. Internal UI Libraries <acme-corp--menu> <acme-corp--menu-item>Home</acme-corp--menu-item> <acme-corp--menu-item selected>About</acme-corp--menu-item> <acme-corp--menu-item>Contact Us</acme-corp--menu-item> </acme-corp--menu> <acme-corp--login-form ajax url="login.php"> </acme-corp--login-form>
  • 30. Web Component Everything?? <acme-corp--app> <acme-corp--menu></acme-corp--menu> <acme-corp--content></acme-corp--content> <acme-corp--footer></acme-corp--footer> </acme-corp--app>
  • 31. Probably Not (and that's OK) I don't ever see us going all in on Custom Elements for every possible thing ... Use native elements and controls when possible and supplement with custom elements. - Joshua Peek, Github Programmer
  • 32. Small Open for Extension Documented Unit Tested Accessible Responsive Best Practices
  • 35. Towards a Component Driven Web
  • 36. Thanks! Resources - WebComponents.org - Web Components: A Tectonic Shift for Web Development by Eric Bidelman - Web Components by Jarrod Overson and Jason Strimpel - Ten Principles for Great General Purpose Web Components Colophon This presentation was built with Shadow DOM, HTML Templates, HTML Imports, and the Custom Elements <slide-show> and <slide-content> using Web Component Slides.
  翻译: