SlideShare uma empresa Scribd logo
1 de 75
Baixar para ler offline
Desbravando Web 
Components 
@mteusor)z
mateusor3z 
@mteusor3z
Como "criar" um componente 
hoje
Google! plugin jQuery
Copie e cole o código do plugin
Funcionou? Beleza
Web Components
<gdg-­‐recife> 
h"ps://github.com/mateusor3z/gdg-­‐light
googlewebcomponents.github.io
Live demo
<google-­‐map> 
h"ps://github.com/GoogleWebComponents/google-­‐map
<google-­‐chart> 
h"ps://github.com/GoogleWebComponents/google-­‐chart
Shadow DOM 
HTML Imports 
Web Components 
Template 
Custom Elements 
Decorators*
Custom Elements 
Define novos elementos HTML/DOM
Criar Novos Elementos
<script> 
(function() { 
// Creates an object based in the HTML Element prototype 
var element = Object.create(HTMLElement.prototype); 
// Fires when an instance of the element is created 
element.createdCallback = function() {}; 
// Fires when an instance was inserted into the document 
element.attachedCallback = function() {}; 
// Fires when an instance was removed from the document 
element.detachedCallback = function() {}; 
// Fires when an attribute was added, removed, or updated 
element.attributeChangedCallback = function(attr, oldVal, 
newVal) {}; 
document.registerElement('menu-tabs', { 
prototype: element 
}); 
}()); 
</script>
<!-- Define your custom element --> 
<polymer-element name="menu-tabs"> 
<script> 
Polymer('menu-tabs', { 
// Fires when an instance of the element is created 
created: function() {}, 
// Fires when the "<polymer-element>" has been fully prepared 
ready: function() {}, 
// Fires when the element was inserted into the document 
attached: function() {}, 
// Fires when the element was removed from the document 
detached: function() {}, 
// Fires when an attribute was added, removed, or updated 
attributeChanged: function(attr, oldVal, newVal) {} 
}); 
</script> 
</polymer-element>
Usando o elemento 
<menu-tabs></menu-tabs>
Estendendo elementos existes
<!-- Define your custom element --> 
<polymer-element name="menu-tabs" extends="nav"> 
<script> 
Polymer('menu-tabs', { 
// Fires when an instance of the element is created 
created: function() {}, 
// Fires when the "<polymer-element>" has been fully prepared 
ready: function() {}, 
// Fires when the element was inserted into the document 
attached: function() {}, 
// Fires when the element was removed from the document 
detached: function() {}, 
// Fires when an attribute was added, removed, or updated 
attributeChanged: function(attr, oldVal, newVal) {} 
}); 
</script> 
</polymer-element>
Lifecycle Callbacks Polymer 
created(); 
a"ached(); 
detached(); 
a"ributeChanged();
Template 
Template client-­‐side na3vo
HTML Templates 
parseado, não é renderizado 
conteúdo inerte 
Usa Dom como scaffold
<template> 
... 
</template>
<polymer-element name="menu-tabs" noscript 
attributes="selected"> 
<template> 
... 
</template> 
</polymer-element>
Shadow Dom 
Esconder Detalhes de implementação
<video src="video.mp4" controls></video>
Encapsula style, 
marcação e script
HTML Imports 
Carregar Web Components
exemplo 
<link rel="stylesheet" href="bootstrap.css"> 
<link rel="stylesheet" href="font.css"> 
<script src="jquery.js"></script> 
<script src="bootstrap.js"></script> 
<script src="bootstrap-tooltip.js"></script> 
<script src="bootstrap-dropdown.js"></script>
exemplo 
<link rel="import" href="bootstrap.html">
Suporte a 
Web Components
jonrimmer.github.io/are-­‐twe-­‐componen4zed-­‐yet/
polymer-­‐ptroject.org
Google
core-­‐elements
Visual 
<core-­‐toolbar> 
<core-­‐header-­‐panel> 
<core-­‐drawer-­‐panel> 
<core-­‐menu> 
<core-­‐icon> 
<core-­‐overlay> 
.... 
não Visual 
<core-­‐ajax> 
<core-­‐localstorage> 
<core-­‐range> 
<core-­‐shared-­‐lib> 
<core-­‐media-­‐query> 
<core-­‐iconset> 
....
hbp://goo.gl/5Tiy9U
paper-­‐elements
Polymer Paper Elements 
bubons 
inputs 
tabs 
cards 
panels 
....
Quem 
está 
Usando
Açúcar Sintá3co 
Custom Elements
vanilla 
document.registerElement('paper-tabs', { 
prototype: Object.create( 
HTMLElement.prototype 
) 
});
polymer 
<polymer-element name="paper-tabs"> 
... 
</polymer-element>
Usando 
<paper-tabs></paper-tabs> 
// document.createElement('paper-tabs');
Açúcar Sintá3co 
Template
vanilla 
<template> 
... 
</template>
polymer 
<polymer-element name="list-users" noscript> 
<template> 
<ul> 
<template repeat="{{user, i in users}}"> 
<li>{{user.name}}</li> 
</template> 
</ul> 
</template> 
</polymer-element>
Açúcar Sintá3co 
Shadow Dom
vanilla 
var shadow = el.createShadowRoot(); 
shadow.innerHTML = '<h2>I`m a profile-card</ 
h2>';
polymer 
<polymer-element name="profile-card" noscript> 
<template> 
<link rel="stylesheet" href="styles.css"> 
<h2>I'm a profile-card</h2> 
</template> 
</polymer-element>
Você ainda pode Estender 
elementos já existentes
polymer 
<polymer-element name="x-button" extends="button"> 
<template> 
</template> 
<script> 
Polymer('x-button', { 
}); 
</script> 
</polymer-element>
como não se 
tornar um zumbi
algumas coisas que podem 
Ajudar
h,p://webcomt ponents.org/
h,p://customt elements.io/
h,ps://github.com/mateusor)z/twebcomponents-­‐the-­‐right-­‐way
como começar um 
component
github.com/webcomponet nts/polymer-­‐boilerplate
h,ps://github.com/webcomtponents/generator-­‐element
Em poucas 
palavras...
encapsulamento e 
reaproveitamento de 
código de verdade
Inventa o Futuro
Obrigado 
TWITTER.COM/MTEUSORTIZ 
GITHUB.COM/MATEUSORTIZ

Mais conteúdo relacionado

Mais procurados

JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the Platform
Robert Nyman
 
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos AiresJavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
Robert Nyman
 
Cloud Endpoints _Polymer_ Material design by Martin Görner
Cloud Endpoints_Polymer_Material design by Martin GörnerCloud Endpoints_Polymer_Material design by Martin Görner
Cloud Endpoints _Polymer_ Material design by Martin Görner
European Innovation Academy
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
Yehuda Katz
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Events
dmethvin
 
JavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
JavaScript APIs - The Web is the Platform - MDN Hack Day, MontevideoJavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
Robert Nyman
 
JavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires
JavaScript APIs - The Web is the Platform - MozCamp, Buenos AiresJavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires
JavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires
Robert Nyman
 

Mais procurados (20)

JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the Platform
 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017
 
Dart and AngularDart
Dart and AngularDartDart and AngularDart
Dart and AngularDart
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0
 
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos AiresJavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
 
Gae
GaeGae
Gae
 
Webapps without the web
Webapps without the webWebapps without the web
Webapps without the web
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.js
 
Cloud Endpoints _Polymer_ Material design by Martin Görner
Cloud Endpoints_Polymer_Material design by Martin GörnerCloud Endpoints_Polymer_Material design by Martin Görner
Cloud Endpoints _Polymer_ Material design by Martin Görner
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play Nice
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
 
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
 
Drupal point of vue
Drupal point of vueDrupal point of vue
Drupal point of vue
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Events
 
JavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
JavaScript APIs - The Web is the Platform - MDN Hack Day, MontevideoJavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
 
Arquitetura de Front-end em Aplicações de Larga Escala
Arquitetura de Front-end em Aplicações de Larga EscalaArquitetura de Front-end em Aplicações de Larga Escala
Arquitetura de Front-end em Aplicações de Larga Escala
 
JavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires
JavaScript APIs - The Web is the Platform - MozCamp, Buenos AiresJavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires
JavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & Vuex
 

Destaque (13)

Sistemas operativos da microsoft imc
Sistemas operativos da microsoft imcSistemas operativos da microsoft imc
Sistemas operativos da microsoft imc
 
Para reflectir/Limites
Para reflectir/LimitesPara reflectir/Limites
Para reflectir/Limites
 
Ahistoriadolapis
AhistoriadolapisAhistoriadolapis
Ahistoriadolapis
 
一个Les的七年真实同性爱体验
一个Les的七年真实同性爱体验一个Les的七年真实同性爱体验
一个Les的七年真实同性爱体验
 
As Portas do Futuro e as Chaves do Presente
As Portas do Futuro e as Chaves do PresenteAs Portas do Futuro e as Chaves do Presente
As Portas do Futuro e as Chaves do Presente
 
Pais e filhos definitiva
Pais e filhos definitivaPais e filhos definitiva
Pais e filhos definitiva
 
Web Semántica
Web SemánticaWeb Semántica
Web Semántica
 
Aula 2 3 4 redes perfil e mensuracao
Aula 2 3 4 redes perfil e mensuracaoAula 2 3 4 redes perfil e mensuracao
Aula 2 3 4 redes perfil e mensuracao
 
暮雨潇潇
暮雨潇潇暮雨潇潇
暮雨潇潇
 
暮雨潇潇
暮雨潇潇暮雨潇潇
暮雨潇潇
 
Aula09 - ad words
Aula09 - ad wordsAula09 - ad words
Aula09 - ad words
 
大梦浮华录
大梦浮华录大梦浮华录
大梦浮华录
 
Passo a Passo para a criação de Domínio e uma hospedagem gratuito
Passo a Passo para a criação de Domínio e uma hospedagem gratuitoPasso a Passo para a criação de Domínio e uma hospedagem gratuito
Passo a Passo para a criação de Domínio e uma hospedagem gratuito
 

Semelhante a Desbravando Web Components

Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
fool2nd
 
Александр Кашеверов - Polymer
Александр Кашеверов - PolymerАлександр Кашеверов - Polymer
Александр Кашеверов - Polymer
DataArt
 
От экспериментов с инфраструктурой до внедрения в продакшен
От экспериментов с инфраструктурой до внедрения в продакшенОт экспериментов с инфраструктурой до внедрения в продакшен
От экспериментов с инфраструктурой до внедрения в продакшен
Dmitry Makhnev
 

Semelhante a Desbravando Web Components (20)

Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept Implementation
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
 
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
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
Why you should be using Web Components. And How - DevWeek 2015
Why you should be using Web Components. And How - DevWeek 2015Why you should be using Web Components. And How - DevWeek 2015
Why you should be using Web Components. And How - DevWeek 2015
 
实战Ecos
实战Ecos实战Ecos
实战Ecos
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2
 
Introduction to Polymer
Introduction to PolymerIntroduction to Polymer
Introduction to Polymer
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
 
Academy PRO: HTML5 API Introduction
Academy PRO: HTML5 API IntroductionAcademy PRO: HTML5 API Introduction
Academy PRO: HTML5 API Introduction
 
Александр Кашеверов - Polymer
Александр Кашеверов - PolymerАлександр Кашеверов - Polymer
Александр Кашеверов - Polymer
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 
The Future of the Web
The Future of the WebThe Future of the Web
The Future of the Web
 
«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​
 
От экспериментов с инфраструктурой до внедрения в продакшен
От экспериментов с инфраструктурой до внедрения в продакшенОт экспериментов с инфраструктурой до внедрения в продакшен
От экспериментов с инфраструктурой до внедрения в продакшен
 
Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento Extension
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Desbravando Web Components