SlideShare una empresa de Scribd logo
1 de 23
Descargar para leer sin conexión
Web Components
Diwakar Cherukumilli
Oswald Campesato
What are Web Components?
Web Components are a set of emerging standards that change the way web apps
are developed by reusing components in a much more efficient way
“A web app is a large collection of web components composed of many subelements,
known as custom elements” - Eric Bidelman
Why Web Components?
HTML at the beginning of the web
Small set of tags like:
● <select>
● <form>
● ….
These elements provided:
● Declarative
● Encapsulation
● Default UI
● Events
...
<select>
<option>One</option>
<option disabled>Two</option>
<option disabled>Three</option>
<option>Four</option>
<li>Five</li>
</select>
…
● Declarative
● Encapsulated
● Default UI
● NO JS :)
Modern Web apps without Web
Components
● Copy & paste chunks of HTML from CSS
libraries like Bootstrap
● All sorts of Javascript frameworks and plugins
● Reusing components from different frameworks
in the same page is not possible
○ Pages end up with bloated CSS and/or
Javascript
● Difficult to maintain
GMail code (in chrome developer tools)
Building a modern chart
Building a modern chart without web components
<head>
<!-- Load the google JS library to use the google visualization API -->
<script type=”text/javascript” src=”https://www.google.com/jsapi”></script>
</head>
<body>
<!-- Add the div tag as a placeholder for the chart -->
<div id=”char_div” style=”width:400; height: 300”></div>
</body>
Building a modern chart without web components
<!-- Using javascript -->
<!-- Load the visualization API -->
google.load(‘visualization’, ‘1.0’, {‘packages’: [‘corechart’]});
<!-- Set values and options on load callback -->
google.setOnLoadCallback(function() {
var data = new google.visualization.arrayToDataTable([[“Day”, “A”, “B”, “C”], [“Mon”, 20, 45, 28],
[“Tue”, 31, 66, 38], [“Wed”, 50, 80, 55], [“Thu”, 77, 50, 77], [“Fri”, 68, 15, 66]]);
var options =
{“seriesType”: “bars”, “series”: {“2”: {“type”: “line”}},
“width”: 400,
“height”: 300
};
<!-- Specify the dom element for the chart and draw it-->
var div = document.getElementById(‘chart_div’);
var chart = new google.visualization.ComboChart(div);
chart.draw(data, options);
});
Building a modern chart with web components
<head>
<!-- Load polyfill for cross browser support -->
<script src=”js/webcomponentjs.js”></script>
<!-- Import the google chart component -->
<link rel=”import” href=”components/google-chart.html”>
</head>
<body>
<!-- Add google chart tag and fill in the attributes -->
<google-chart
type=”combo”
height=”300px” width=”400px”
options=”{‘seriesType’: ‘bars’, ‘series’: {‘2’: {‘type’: ‘line’}}}”
data=”[[‘Day’, ‘A’, ‘B’, ‘C’], [‘Mon’, 20, 45, 28], [‘Tue’, 31, 66, 38], [‘Wed’, 50, 80, 55], [‘Thu’, 77, 50, 77], [‘Fri’, 68, 15, 66]]”>
</google-chart>
</body>
Declarative approach (with web
components)
<google-chart
type=”combo”
height=”300px”
width=”400px”
options=”{‘seriesType’: ‘bars’, ‘series’: {‘2’: {‘type’:
‘line’}}}”
data=”[[‘Day’, ‘A’, ‘B’, ‘C’], [‘Mon’, 20, 45, 28], [‘Tue’,
31, 66, 38], [‘Wed’, 50, 80, 55], [‘Thu’, 77, 50, 77], [‘Fri’,
68, 15, 66]]”>
</google-chart>
<!-- Easier to use -->
<!-- No need to know the underlying JS
API and CSS -->
Imperative Approach (without web
components)
google.load(‘visualization’, ‘1.0’, {‘packages’: [‘corechart’]});
google.setOnLoadCallback(function() {
var data = new google.visualization.
arrayToDataTable([[“Day”, “A”, “B”, “C”], [“Mon”, 20, 45,
28], [“Tue”, 31, 66, 38], [“Wed”, 50, 80, 55], [“Thu”, 77, 50,
77], [“Fri”, 68, 15, 66]]);
var options =
{“seriesType”: “bars”, “series”: {“2”: {“type”:
“line”}},
“width”: 400,
“height”: 300
};
var div = document.getElementById(‘chart_div’);
var chart = new google.visualization.ComboChart
(div);
chart.draw(data, options);
});
Scoped
Web components
● All mark up and CSS are scoped to the element
● Styles scoped to the element will not leak out to the parent
● Parent can’t style the web component accidentally
● Imported web components will not harm any part of your web page
Non Web Component based libraries
● Existing libraries that have same classes and id can cause styles to leak
Reusable
● Scoped and decoupled with the other parts of your web app
● Use same component in the other parts of your web app
● Use the component in another web app
● Publish your component as open source so that others can use it
Isolation
● Decouple development of web components from the rest of the web app as
they are scoped
● Maintenance of the web component is much easier due to isolation
Web Components is an umbrella term for four different
W3C specifications
● Custom Elements lets you define your own HTML tags
● HTML Templates enables you to define blocks of markup with the ability to
inject dynamic content into
● Shadow DOM gives you the ability to scope markup and styles in a separate
DOM tree
● HTML Imports provides a way to include and reuse HTML documents in other
HTML documents
Vanilla Web Component (svcc-component.html)
<template>
<p>This is svcc-component’s SHADOW DOM</p>
</template>
<script>
// 1. Register a custom element
var XElement = document.registerElement(‘svcc-component’, {
prototype: Object.create(HTMLElement.prototype, {
createCallback: {
value: function(){
// 2. Associate Shadow dom onto it
var root = this.createShadowRoot();
//3. Use templates to provide the contents of the shadow dom
var template = thisDoc.querySelector(‘#template’);
var content = thisDoc.importNode(template.content, true);
root.appendChild(content);
}
}
}
});
</script>
index.html
<html>
<head>
<!-- 4. Use HTML import to import the component-->
<link rel=”import” href=”svcc-component.html>
</head>
<body>
<svcc-component></svcc-component>
</body>
</html>
Polymer for buiding Web Components
Polymer lets you build
● encapsulated,
● re-usable elements
● that work just like HTML elements,
● to use in building web applications.
Polymer in 1 minute
/** * A not-very-useful inline element */
Polymer({
is: 'my-element'
});
Add markup to your element
<!-- define the markup that your element will use -->
<dom-module id="my-simple-namecard">
<template>
<div>
Hi! My name is <span>Jane</span>
</div>
</template>
<script>
Polymer({
is: 'my-simple-namecard'
});
</script>
</dom-module>
Configure properties on your element
// Create an element that takes a property
Polymer({
is: 'my-property-namecard',
properties: {
myName: {
type: String
}
},
ready: function() {
this.textContent = 'Hi! My name is ' + this.myName;
}
});
<!-- using the element -->
<my-property-namecard my-name="Jim"></my-property-namecard>
Hi! My name is Jim.
Bind data into your element using the
familiar mustache-syntax
<!-- define markup with bindings -->
<dom-module id="my-bound-namecard">
<template>
<div>
Hi! My name is <span>{{myName}}</span>
</div>
</template>
<script>
Polymer({
is: 'my-bound-namecard',
properties: {
myName: {
type: String
}
}
});
</script>
Hi! My name is Josh.
<!-- using the element -->
<my-bound-namecard my-name="Josh"></my-bound-namecard>
Bind data into your element using the
familiar mustache-syntax
<!-- define markup with bindings -->
<dom-module id="my-bound-namecard">
<template>
<div>
Hi! My name is <span>{{myName}}</span>
</div>
</template>
<script>
Polymer({
is: 'my-bound-namecard',
properties: {
myName: {
type: String
}
}
});
</script>
Hi! My name is Josh.
<!-- using the element -->
<my-bound-namecard my-name="Josh"></my-bound-namecard>
Style the internals of your element, without
the style leaking out
<!-- add style to your element -->
<dom-module id="my-styled-namecard">
<template>
<style>
/* This would be crazy in non webcomponents. */
span {font-weight: bold;}
</style>
<div>Hi! My name is <span>{{myName}}</span></div>
</template>
<script>
Polymer({
is: 'my-styled-namecard',
properties: {
myName: { type: String}
}
});
Hi! My name is Jesse.
<!-- using the element -->
<my-styled-namecard my-name="Jesse"></my-styled-namecard>
References...
Polymer - Chrome Dev Summit 2013 (Eric Bidelman)
Why Web Components (Zeno Rocha & Addy Osmani)?
DevBytes: Web Components - Overview (Eiji Katamura)
Polymer Github page (https://github.com/Polymer/polymer)

Más contenido relacionado

La actualidad más candente

ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsAviran Cohen
 
Web Components v1
Web Components v1Web Components v1
Web Components v1Mike Wilcox
 
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 talkImam Raza
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web ComponentsRich Bradshaw
 
Polymer vs other libraries (Devfest Ukraine 2015)
Polymer vs other libraries (Devfest Ukraine 2015)Polymer vs other libraries (Devfest Ukraine 2015)
Polymer vs other libraries (Devfest Ukraine 2015)jskvara
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012crokitta
 
Angular js presentation at Datacom
Angular js presentation at DatacomAngular js presentation at Datacom
Angular js presentation at DatacomDavid Xi Peng Yang
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJSInfragistics
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architectureMichael He
 
Building a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / SpringBuilding a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / Springsdeeg
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introductionLuigi De Russis
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JSAkshay Mathur
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular jsTamer Solieman
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components EverywhereIlia Idakiev
 
OpenCms Days 2015 Modern templates with nested containers
OpenCms Days 2015 Modern templates with nested containersOpenCms Days 2015 Modern templates with nested containers
OpenCms Days 2015 Modern templates with nested containersAlkacon Software GmbH & Co. KG
 
Angular View Encapsulation
Angular View EncapsulationAngular View Encapsulation
Angular View EncapsulationJennifer Estrada
 
Unlock the next era of UI design with Polymer
Unlock the next era of UI design with PolymerUnlock the next era of UI design with Polymer
Unlock the next era of UI design with PolymerRob Dodson
 

La actualidad más candente (20)

Web Components
Web ComponentsWeb Components
Web Components
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
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
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web Components
 
Polymer vs other libraries (Devfest Ukraine 2015)
Polymer vs other libraries (Devfest Ukraine 2015)Polymer vs other libraries (Devfest Ukraine 2015)
Polymer vs other libraries (Devfest Ukraine 2015)
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
 
Angular js presentation at Datacom
Angular js presentation at DatacomAngular js presentation at Datacom
Angular js presentation at Datacom
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
 
Angular js 1.3 basic tutorial
Angular js 1.3 basic tutorialAngular js 1.3 basic tutorial
Angular js 1.3 basic tutorial
 
Building a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / SpringBuilding a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / Spring
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components Everywhere
 
OpenCms Days 2015 Modern templates with nested containers
OpenCms Days 2015 Modern templates with nested containersOpenCms Days 2015 Modern templates with nested containers
OpenCms Days 2015 Modern templates with nested containers
 
Angular js
Angular jsAngular js
Angular js
 
Angular View Encapsulation
Angular View EncapsulationAngular View Encapsulation
Angular View Encapsulation
 
Unlock the next era of UI design with Polymer
Unlock the next era of UI design with PolymerUnlock the next era of UI design with Polymer
Unlock the next era of UI design with Polymer
 

Destacado

Red Hat - Sarangan Rangachari
Red Hat - Sarangan RangachariRed Hat - Sarangan Rangachari
Red Hat - Sarangan RangachariInside Analysis
 
Drive It Home: A Roadmap for Today's Data-Driven Culture
Drive It Home: A Roadmap for Today's Data-Driven CultureDrive It Home: A Roadmap for Today's Data-Driven Culture
Drive It Home: A Roadmap for Today's Data-Driven CultureInside Analysis
 
DisrupTech - Robin Bloor (2)
DisrupTech - Robin Bloor (2)DisrupTech - Robin Bloor (2)
DisrupTech - Robin Bloor (2)Inside Analysis
 
แบบสำรวจ
แบบสำรวจแบบสำรวจ
แบบสำรวจNaCk Wanasanan
 
IT used by terrorists
IT used by terroristsIT used by terrorists
IT used by terroristscpandey76
 
The Postulate of Human Ecology
The Postulate of Human EcologyThe Postulate of Human Ecology
The Postulate of Human EcologyErnst Satvanyi
 
The Maturity Model: Taking the Growing Pains Out of Hadoop
The Maturity Model: Taking the Growing Pains Out of HadoopThe Maturity Model: Taking the Growing Pains Out of Hadoop
The Maturity Model: Taking the Growing Pains Out of HadoopInside Analysis
 
Humanitarianism and volunteerism
Humanitarianism and volunteerismHumanitarianism and volunteerism
Humanitarianism and volunteerismDavid Hii
 
Big Data Refinery: Distilling Value for User-Driven Analytics
Big Data Refinery: Distilling Value for User-Driven AnalyticsBig Data Refinery: Distilling Value for User-Driven Analytics
Big Data Refinery: Distilling Value for User-Driven AnalyticsInside Analysis
 
Understanding What’s Possible: Getting Business Value from Big Data Quickly
Understanding What’s Possible: Getting Business Value from Big Data QuicklyUnderstanding What’s Possible: Getting Business Value from Big Data Quickly
Understanding What’s Possible: Getting Business Value from Big Data QuicklyInside Analysis
 
The Great Lakes: How to Approach a Big Data Implementation
The Great Lakes: How to Approach a Big Data ImplementationThe Great Lakes: How to Approach a Big Data Implementation
The Great Lakes: How to Approach a Big Data ImplementationInside Analysis
 
Anthropometry presentation on height and weight measurement
Anthropometry presentation on height and weight measurementAnthropometry presentation on height and weight measurement
Anthropometry presentation on height and weight measurementDavid Hii
 
Ford presentation
Ford presentationFord presentation
Ford presentationKaren Diaz
 
What is Bitcoin? How Bitcoin works in under 5 minutes.
What is Bitcoin? How Bitcoin works in under 5 minutes.What is Bitcoin? How Bitcoin works in under 5 minutes.
What is Bitcoin? How Bitcoin works in under 5 minutes.Ryan Shea
 

Destacado (17)

Red Hat - Sarangan Rangachari
Red Hat - Sarangan RangachariRed Hat - Sarangan Rangachari
Red Hat - Sarangan Rangachari
 
Drive It Home: A Roadmap for Today's Data-Driven Culture
Drive It Home: A Roadmap for Today's Data-Driven CultureDrive It Home: A Roadmap for Today's Data-Driven Culture
Drive It Home: A Roadmap for Today's Data-Driven Culture
 
DisrupTech - Robin Bloor (2)
DisrupTech - Robin Bloor (2)DisrupTech - Robin Bloor (2)
DisrupTech - Robin Bloor (2)
 
WebAction-Sami Abkay
WebAction-Sami AbkayWebAction-Sami Abkay
WebAction-Sami Abkay
 
Nava1
Nava1Nava1
Nava1
 
แบบสำรวจ
แบบสำรวจแบบสำรวจ
แบบสำรวจ
 
CV-MURUGAN PARAMASIVAM
CV-MURUGAN PARAMASIVAMCV-MURUGAN PARAMASIVAM
CV-MURUGAN PARAMASIVAM
 
IT used by terrorists
IT used by terroristsIT used by terrorists
IT used by terrorists
 
The Postulate of Human Ecology
The Postulate of Human EcologyThe Postulate of Human Ecology
The Postulate of Human Ecology
 
The Maturity Model: Taking the Growing Pains Out of Hadoop
The Maturity Model: Taking the Growing Pains Out of HadoopThe Maturity Model: Taking the Growing Pains Out of Hadoop
The Maturity Model: Taking the Growing Pains Out of Hadoop
 
Humanitarianism and volunteerism
Humanitarianism and volunteerismHumanitarianism and volunteerism
Humanitarianism and volunteerism
 
Big Data Refinery: Distilling Value for User-Driven Analytics
Big Data Refinery: Distilling Value for User-Driven AnalyticsBig Data Refinery: Distilling Value for User-Driven Analytics
Big Data Refinery: Distilling Value for User-Driven Analytics
 
Understanding What’s Possible: Getting Business Value from Big Data Quickly
Understanding What’s Possible: Getting Business Value from Big Data QuicklyUnderstanding What’s Possible: Getting Business Value from Big Data Quickly
Understanding What’s Possible: Getting Business Value from Big Data Quickly
 
The Great Lakes: How to Approach a Big Data Implementation
The Great Lakes: How to Approach a Big Data ImplementationThe Great Lakes: How to Approach a Big Data Implementation
The Great Lakes: How to Approach a Big Data Implementation
 
Anthropometry presentation on height and weight measurement
Anthropometry presentation on height and weight measurementAnthropometry presentation on height and weight measurement
Anthropometry presentation on height and weight measurement
 
Ford presentation
Ford presentationFord presentation
Ford presentation
 
What is Bitcoin? How Bitcoin works in under 5 minutes.
What is Bitcoin? How Bitcoin works in under 5 minutes.What is Bitcoin? How Bitcoin works in under 5 minutes.
What is Bitcoin? How Bitcoin works in under 5 minutes.
 

Similar a Web components - An Introduction

Polymer
Polymer Polymer
Polymer jskvara
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the futureDA-14
 
Web components are the future of the web - Take advantage of new web technolo...
Web components are the future of the web - Take advantage of new web technolo...Web components are the future of the web - Take advantage of new web technolo...
Web components are the future of the web - Take advantage of new web technolo...Marios Fakiolas
 
Polymer and web component
Polymer and web componentPolymer and web component
Polymer and web componentImam Raza
 
"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcher"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcherlottepitcher
 
Web Components for Java Developers
Web Components for Java DevelopersWeb Components for Java Developers
Web Components for Java DevelopersJoonas Lehtinen
 
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 ComponentsAndrew Rota
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven developmentGil Fink
 
Web Components: Web back to future.
Web Components: Web back to future.Web Components: Web back to future.
Web Components: Web back to future.GlobalLogic Ukraine
 
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Nidhi Sharma
 
Intro to MVC 3 for Government Developers
Intro to MVC 3 for Government DevelopersIntro to MVC 3 for Government Developers
Intro to MVC 3 for Government DevelopersFrank La Vigne
 
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 CombinationAndrew Rota
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsWebStackAcademy
 
Building and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextBuilding and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextSvilen Sabev
 
Understanding the Web Page Layout
Understanding the Web Page LayoutUnderstanding the Web Page Layout
Understanding the Web Page LayoutJhaun Paul Enriquez
 
Web components
Web componentsWeb components
Web componentsGil Fink
 

Similar a Web components - An Introduction (20)

Polymer
Polymer Polymer
Polymer
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the future
 
Web components are the future of the web - Take advantage of new web technolo...
Web components are the future of the web - Take advantage of new web technolo...Web components are the future of the web - Take advantage of new web technolo...
Web components are the future of the web - Take advantage of new web technolo...
 
Unit 2 - Data Binding.pptx
Unit 2 - Data Binding.pptxUnit 2 - Data Binding.pptx
Unit 2 - Data Binding.pptx
 
AngularJS
AngularJSAngularJS
AngularJS
 
Polymer and web component
Polymer and web componentPolymer and web component
Polymer and web component
 
Polymer
PolymerPolymer
Polymer
 
"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcher"Umbraco MVC - a journey of discovery" - Lotte Pitcher
"Umbraco MVC - a journey of discovery" - Lotte Pitcher
 
Web Components for Java Developers
Web Components for Java DevelopersWeb Components for Java Developers
Web Components for Java Developers
 
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 component driven development
Web component driven developmentWeb component driven development
Web component driven development
 
Web Components: Web back to future.
Web Components: Web back to future.Web Components: Web back to future.
Web Components: Web back to future.
 
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...
 
Intro to MVC 3 for Government Developers
Intro to MVC 3 for Government DevelopersIntro to MVC 3 for Government Developers
Intro to MVC 3 for Government Developers
 
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
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
 
Web components api + Vuejs
Web components api + VuejsWeb components api + Vuejs
Web components api + Vuejs
 
Building and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextBuilding and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and Context
 
Understanding the Web Page Layout
Understanding the Web Page LayoutUnderstanding the Web Page Layout
Understanding the Web Page Layout
 
Web components
Web componentsWeb components
Web components
 

Último

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 

Último (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 

Web components - An Introduction

  • 2. What are Web Components? Web Components are a set of emerging standards that change the way web apps are developed by reusing components in a much more efficient way “A web app is a large collection of web components composed of many subelements, known as custom elements” - Eric Bidelman
  • 3. Why Web Components? HTML at the beginning of the web Small set of tags like: ● <select> ● <form> ● …. These elements provided: ● Declarative ● Encapsulation ● Default UI ● Events
  • 5. Modern Web apps without Web Components ● Copy & paste chunks of HTML from CSS libraries like Bootstrap ● All sorts of Javascript frameworks and plugins ● Reusing components from different frameworks in the same page is not possible ○ Pages end up with bloated CSS and/or Javascript ● Difficult to maintain GMail code (in chrome developer tools)
  • 7. Building a modern chart without web components <head> <!-- Load the google JS library to use the google visualization API --> <script type=”text/javascript” src=”https://www.google.com/jsapi”></script> </head> <body> <!-- Add the div tag as a placeholder for the chart --> <div id=”char_div” style=”width:400; height: 300”></div> </body>
  • 8. Building a modern chart without web components <!-- Using javascript --> <!-- Load the visualization API --> google.load(‘visualization’, ‘1.0’, {‘packages’: [‘corechart’]}); <!-- Set values and options on load callback --> google.setOnLoadCallback(function() { var data = new google.visualization.arrayToDataTable([[“Day”, “A”, “B”, “C”], [“Mon”, 20, 45, 28], [“Tue”, 31, 66, 38], [“Wed”, 50, 80, 55], [“Thu”, 77, 50, 77], [“Fri”, 68, 15, 66]]); var options = {“seriesType”: “bars”, “series”: {“2”: {“type”: “line”}}, “width”: 400, “height”: 300 }; <!-- Specify the dom element for the chart and draw it--> var div = document.getElementById(‘chart_div’); var chart = new google.visualization.ComboChart(div); chart.draw(data, options); });
  • 9. Building a modern chart with web components <head> <!-- Load polyfill for cross browser support --> <script src=”js/webcomponentjs.js”></script> <!-- Import the google chart component --> <link rel=”import” href=”components/google-chart.html”> </head> <body> <!-- Add google chart tag and fill in the attributes --> <google-chart type=”combo” height=”300px” width=”400px” options=”{‘seriesType’: ‘bars’, ‘series’: {‘2’: {‘type’: ‘line’}}}” data=”[[‘Day’, ‘A’, ‘B’, ‘C’], [‘Mon’, 20, 45, 28], [‘Tue’, 31, 66, 38], [‘Wed’, 50, 80, 55], [‘Thu’, 77, 50, 77], [‘Fri’, 68, 15, 66]]”> </google-chart> </body>
  • 10. Declarative approach (with web components) <google-chart type=”combo” height=”300px” width=”400px” options=”{‘seriesType’: ‘bars’, ‘series’: {‘2’: {‘type’: ‘line’}}}” data=”[[‘Day’, ‘A’, ‘B’, ‘C’], [‘Mon’, 20, 45, 28], [‘Tue’, 31, 66, 38], [‘Wed’, 50, 80, 55], [‘Thu’, 77, 50, 77], [‘Fri’, 68, 15, 66]]”> </google-chart> <!-- Easier to use --> <!-- No need to know the underlying JS API and CSS --> Imperative Approach (without web components) google.load(‘visualization’, ‘1.0’, {‘packages’: [‘corechart’]}); google.setOnLoadCallback(function() { var data = new google.visualization. arrayToDataTable([[“Day”, “A”, “B”, “C”], [“Mon”, 20, 45, 28], [“Tue”, 31, 66, 38], [“Wed”, 50, 80, 55], [“Thu”, 77, 50, 77], [“Fri”, 68, 15, 66]]); var options = {“seriesType”: “bars”, “series”: {“2”: {“type”: “line”}}, “width”: 400, “height”: 300 }; var div = document.getElementById(‘chart_div’); var chart = new google.visualization.ComboChart (div); chart.draw(data, options); });
  • 11. Scoped Web components ● All mark up and CSS are scoped to the element ● Styles scoped to the element will not leak out to the parent ● Parent can’t style the web component accidentally ● Imported web components will not harm any part of your web page Non Web Component based libraries ● Existing libraries that have same classes and id can cause styles to leak
  • 12. Reusable ● Scoped and decoupled with the other parts of your web app ● Use same component in the other parts of your web app ● Use the component in another web app ● Publish your component as open source so that others can use it
  • 13. Isolation ● Decouple development of web components from the rest of the web app as they are scoped ● Maintenance of the web component is much easier due to isolation
  • 14. Web Components is an umbrella term for four different W3C specifications ● Custom Elements lets you define your own HTML tags ● HTML Templates enables you to define blocks of markup with the ability to inject dynamic content into ● Shadow DOM gives you the ability to scope markup and styles in a separate DOM tree ● HTML Imports provides a way to include and reuse HTML documents in other HTML documents
  • 15. Vanilla Web Component (svcc-component.html) <template> <p>This is svcc-component’s SHADOW DOM</p> </template> <script> // 1. Register a custom element var XElement = document.registerElement(‘svcc-component’, { prototype: Object.create(HTMLElement.prototype, { createCallback: { value: function(){ // 2. Associate Shadow dom onto it var root = this.createShadowRoot(); //3. Use templates to provide the contents of the shadow dom var template = thisDoc.querySelector(‘#template’); var content = thisDoc.importNode(template.content, true); root.appendChild(content); } } } }); </script> index.html <html> <head> <!-- 4. Use HTML import to import the component--> <link rel=”import” href=”svcc-component.html> </head> <body> <svcc-component></svcc-component> </body> </html>
  • 16. Polymer for buiding Web Components Polymer lets you build ● encapsulated, ● re-usable elements ● that work just like HTML elements, ● to use in building web applications.
  • 17. Polymer in 1 minute /** * A not-very-useful inline element */ Polymer({ is: 'my-element' });
  • 18. Add markup to your element <!-- define the markup that your element will use --> <dom-module id="my-simple-namecard"> <template> <div> Hi! My name is <span>Jane</span> </div> </template> <script> Polymer({ is: 'my-simple-namecard' }); </script> </dom-module>
  • 19. Configure properties on your element // Create an element that takes a property Polymer({ is: 'my-property-namecard', properties: { myName: { type: String } }, ready: function() { this.textContent = 'Hi! My name is ' + this.myName; } }); <!-- using the element --> <my-property-namecard my-name="Jim"></my-property-namecard> Hi! My name is Jim.
  • 20. Bind data into your element using the familiar mustache-syntax <!-- define markup with bindings --> <dom-module id="my-bound-namecard"> <template> <div> Hi! My name is <span>{{myName}}</span> </div> </template> <script> Polymer({ is: 'my-bound-namecard', properties: { myName: { type: String } } }); </script> Hi! My name is Josh. <!-- using the element --> <my-bound-namecard my-name="Josh"></my-bound-namecard>
  • 21. Bind data into your element using the familiar mustache-syntax <!-- define markup with bindings --> <dom-module id="my-bound-namecard"> <template> <div> Hi! My name is <span>{{myName}}</span> </div> </template> <script> Polymer({ is: 'my-bound-namecard', properties: { myName: { type: String } } }); </script> Hi! My name is Josh. <!-- using the element --> <my-bound-namecard my-name="Josh"></my-bound-namecard>
  • 22. Style the internals of your element, without the style leaking out <!-- add style to your element --> <dom-module id="my-styled-namecard"> <template> <style> /* This would be crazy in non webcomponents. */ span {font-weight: bold;} </style> <div>Hi! My name is <span>{{myName}}</span></div> </template> <script> Polymer({ is: 'my-styled-namecard', properties: { myName: { type: String} } }); Hi! My name is Jesse. <!-- using the element --> <my-styled-namecard my-name="Jesse"></my-styled-namecard>
  • 23. References... Polymer - Chrome Dev Summit 2013 (Eric Bidelman) Why Web Components (Zeno Rocha & Addy Osmani)? DevBytes: Web Components - Overview (Eiji Katamura) Polymer Github page (https://github.com/Polymer/polymer)