SlideShare una empresa de Scribd logo
1 de 21
Polymer 1.0
Jason
What is Polymer?
●The Polymer library is designed to make it easier and faster for developers to
create great, reusable components for the modern web.
●With custom elements, you can extend the vocabulary of HTML with your own
elements. Elements that provide sophisticated UI.
Web Component
●HTML Template
●Custom Element
●Shadow DOM
●HTML Import
Installing with Bower
Project setup
> bower init
> bower install --save Polymer
> bower update
Quick tour of Polymer
● Register an element
● Add local DOM
● Compose with local DOM
● Use data binding
● Declare a property
● Bind to a property
Register an element
● To register a new element, call the Polymer function, which registers a new
element with the browser. Registering an element associates a tag name with a
prototype, so you can add properties and methods to your custom element.
The custom element’s name must contain a dash (-).
Register an element
Index.html
<html>
<head>
<script src="webcomponents-lite.min.js"></script>
<link rel="import" href="first-component.html">
</head>
<body>
<first-component></first-component>
</body>
</html>
first-component.html
<link rel="import"
href="bower_components/polymer/polymer.html">
<script>
Polymer({
is: "first-component",
ready: function() {
this.textContent = "I'm a proto-element."
}
});
</script>
Custom Element Lifecycle callbacks
● created instead of createdCallback
● attached instead of attachedCallback
● detached instead of detachedCallback
● attributeChanged instead of attributeChangedCallback
Custom Element Lifecycle callbacks
Polymer({
is: "polymer-lifecycle",
ready: function(){ },
created: function() {},
attached: function() {},
detached: function() {},
attributeChanged: function(name, type) {
console.log(this.localName + '#' + this.id + ' attribute ' + name + ' was changed to ' +
this.getAttribute(name));
}
});
created ready attached
Add local DOM
● Many elements include some internal DOM nodes to implement the element’s
UI and behavior. Polymer calls this local DOM, and it provides an easy way to
specify it.
● Local DOM is encapsulated inside the element.
Add local DOM
Index.html
<html>
<head>
<script src="webcomponents-lite.min.js"></script>
<link rel="import" href="dom-element.html">
</head>
<body>
<dom-element></dom-element>
</body>
</html>
dom-element.html
<link rel="import"
href="bower_components/polymer/polymer.html">
<dom-module id="dom-element">
<template>
<p>I'm a DOM element. </p>
</template>
<script>
Polymer({
is: "dom-element"
});
</script>
</dom-module>
Compose with local DOM
● Local DOM lets you control composition. The element’s children can be
distributed so they render as if they were inserted into the local DOM tree.
Compose with local DOM
Index.html
<html>
<head>
<script src="webcomponents-lite.min.js"></script>
<link rel="import" href="picture-frame.html">
</head>
<body>
<picture-frame>
<img src=”image1.jpg” alt=”” />
</picture-frame>
</body>
</html>
picture-frame.html
<link rel="import" href="polymer/polymer.html">
<dom-module id="picture-frame">
<template>
<style>
div { background-color: #ccc; }
</style>
<div>
<content></content>
</div>
</template>
<script>
Polymer({ is: "picture-frame" });
</script>
</dom-module>
Use data binding
● Data binding is a great way to quickly propagate changes in your element and
reduce boilerplate code. You can bind properties in your component using the
“double-mustache” syntax ({{}}). The {{}} is replaced by the value of the
property referenced between the brackets.
Use data binding
Index.html
<html>
<head>
<script src="webcomponents-lite.min.js"></script>
<link rel="import" href="name-tag.html">
</head>
<body>
<name-tag></name-tag>
</body>
</html>
name-tag.html
<link rel="import" href="polymer.html">
<dom-module id="name-tag">
<template>
This is <b>{{owner}}</b>'s name-tag element.
</template>
<script>
Polymer({
is: "name-tag",
ready: function() {
this.owner = "Daniel";
} });
</script>
</dom-module>
Declare a property
● Properties are an important part of an element’s public API. Polymer declared
properties support a number of common patterns for properties — setting
default values, configuring properties from markup, observing property
changes, and more..
Declare a property
Index.html
<html>
<head>
<script src="webcomponents-lite.min.js"></script>
<link rel="import" href="configurable-name-tag.html">
</head>
<body>
<configurable-name-tag
owner="Scott"></configurable-name-tag>
</body>
</html>
configurable-name-tag.html
<dom-module id="configurable-name-tag">
<template>
This is <b>{{owner}}</b>'s configurable-name-tag .
</template>
<script>
Polymer({
is: "configurable-name-tag",
properties: {
owner: {
type: String,
value: "Daniel"
}
}
});
</script>
</dom-module>
Bind to a property
● In addition to text content, you can bind to an element’s properties (using
property-name="{{binding}}"). Polymer properties can optionally support
two-way binding.
●This example uses two-way binding: binding the value of a custom input
element (iron-input) to the element’s owner property, so it’s updated as the user
types
Bind to a property
Index.html
<html>
<head>
<script src="webcomponents-lite.min.js"></script>
<link rel="import" href="editable-name-tag.html">
</head>
<body>
<editable-name-tag></editable-name-tag>
</body>
</html>
editable-name-tag.html
<link rel="import" href="polymer.html">
<link rel="import" href="iron-input/iron-input.html">
<dom-module id="editable-name-tag">
<template>
This is a <strong>{{owner}}</strong>'s editable-name-tag.
<input is="iron-input" bind-value="{{owner}}"/>
</template>
<script>
Polymer({
is: "editable-name-tag",
properties: {
owner: {
type: String,
value: "Daniel"
} } });
</script>
</dom-module>
Reference
Polymer 1.0 - https://www.polymer-project.org/1.0/docs/
Shadow - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Shadow
Html Import - http://www.html5rocks.com/en/tutorials/webcomponents/imports/
Custom Elements - http://www.html5rocks.com/en/tutorials/webcomponents/customelements/

Más contenido relacionado

La actualidad más candente

Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web ComponentsFu Cheng
 
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
 
Polymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill LibraryPolymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill Librarynaohito maeda
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web ComponentsRich Bradshaw
 
Web Components
Web ComponentsWeb Components
Web ComponentsFITC
 
Web Components and Modular CSS
Web Components and Modular CSSWeb Components and Modular CSS
Web Components and Modular CSSAndrew Rota
 
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:14mattsmcnulty
 
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
 
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 #econfpsu16John Riviello
 
Web Components
Web ComponentsWeb Components
Web ComponentsFITC
 
Levent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & PolymerLevent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & PolymerErik Isaksen
 
Reaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and PolymerReaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and PolymerFITC
 
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
 
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 cComponentsGil Fink
 
Polymer - Welcome to the Future @ PyGrunn 08/07/2014
Polymer - Welcome to the Future @ PyGrunn 08/07/2014Polymer - Welcome to the Future @ PyGrunn 08/07/2014
Polymer - Welcome to the Future @ PyGrunn 08/07/2014Spyros Ioakeimidis
 
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
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introductioncherukumilli2
 
Exploring Critical Rendering Path
Exploring Critical Rendering PathExploring Critical Rendering Path
Exploring Critical Rendering PathRaphael Amorim
 
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17GreeceJS
 

La actualidad más candente (20)

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)
 
Polymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill LibraryPolymer, A Web Component Polyfill Library
Polymer, A Web Component Polyfill Library
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web Components
 
Web Components
Web ComponentsWeb Components
Web Components
 
Web Components and Modular CSS
Web Components and Modular CSSWeb Components and Modular CSS
Web Components and Modular CSS
 
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
 
Web Components
Web ComponentsWeb Components
Web Components
 
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)
 
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
 
Web Components
Web ComponentsWeb Components
Web Components
 
Levent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & PolymerLevent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & Polymer
 
Reaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and PolymerReaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and Polymer
 
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
 
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
 
Polymer - Welcome to the Future @ PyGrunn 08/07/2014
Polymer - Welcome to the Future @ PyGrunn 08/07/2014Polymer - Welcome to the Future @ PyGrunn 08/07/2014
Polymer - Welcome to the Future @ PyGrunn 08/07/2014
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing Combination
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
 
Exploring Critical Rendering Path
Exploring Critical Rendering PathExploring Critical Rendering Path
Exploring Critical Rendering Path
 
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
 

Destacado

Conociendo Angular 2
Conociendo Angular 2Conociendo Angular 2
Conociendo Angular 2Sergio Brito
 
Progressive web apps with polymer
Progressive web apps with polymerProgressive web apps with polymer
Progressive web apps with polymerMarcus Hellberg
 
Web Components for Java Developers
Web Components for Java DevelopersWeb Components for Java Developers
Web Components for Java DevelopersJoonas Lehtinen
 
Creating HTML Pages
Creating HTML PagesCreating HTML Pages
Creating HTML PagesMike Crabb
 

Destacado (7)

Booting up with polymer
Booting up with polymerBooting up with polymer
Booting up with polymer
 
Conociendo Angular 2
Conociendo Angular 2Conociendo Angular 2
Conociendo Angular 2
 
Web apps con angular y material design
Web apps con angular y material designWeb apps con angular y material design
Web apps con angular y material design
 
PostCss
PostCssPostCss
PostCss
 
Progressive web apps with polymer
Progressive web apps with polymerProgressive web apps with polymer
Progressive web apps with polymer
 
Web Components for Java Developers
Web Components for Java DevelopersWeb Components for Java Developers
Web Components for Java Developers
 
Creating HTML Pages
Creating HTML PagesCreating HTML Pages
Creating HTML Pages
 

Similar a Polymer

Polytechnic 1.0 Granada
Polytechnic 1.0 GranadaPolytechnic 1.0 Granada
Polytechnic 1.0 GranadaIsrael Blancas
 
Polymer - Una bella historia de amor
Polymer - Una bella historia de amorPolymer - Una bella historia de amor
Polymer - Una bella historia de amorIsrael Blancas
 
Intro to polymer-Devfest Yaoundé 2013
Intro to polymer-Devfest Yaoundé 2013Intro to polymer-Devfest Yaoundé 2013
Intro to polymer-Devfest Yaoundé 2013gdgyaounde
 
Web components
Web componentsWeb components
Web componentsGil Fink
 
Web components
Web componentsWeb components
Web componentsNoam Kfir
 
Web Components - The Future is Here
Web Components - The Future is HereWeb Components - The Future is Here
Web Components - The Future is HereGil Fink
 
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 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 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 2014jskvara
 
Rawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web ComponentsRawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web ComponentsRawnet
 
Up & Running with Polymer
Up & Running with PolymerUp & Running with Polymer
Up & Running with PolymerFiyaz Hasan
 
Introduction to web components
Introduction to web componentsIntroduction to web components
Introduction to web componentsMarc Bächinger
 
Polymer-Powered Design Systems - DevFest Florida
Polymer-Powered Design Systems - DevFest FloridaPolymer-Powered Design Systems - DevFest Florida
Polymer-Powered Design Systems - DevFest FloridaJohn Riviello
 
The Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has ArrivedThe Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has ArrivedGil Fink
 
Angular View Encapsulation
Angular View EncapsulationAngular View Encapsulation
Angular View EncapsulationJennifer Estrada
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...Horacio Gonzalez
 
Александр Кашеверов - Polymer
Александр Кашеверов - PolymerАлександр Кашеверов - Polymer
Александр Кашеверов - PolymerDataArt
 

Similar a Polymer (20)

Polytechnic 1.0 Granada
Polytechnic 1.0 GranadaPolytechnic 1.0 Granada
Polytechnic 1.0 Granada
 
Polymer - Una bella historia de amor
Polymer - Una bella historia de amorPolymer - Una bella historia de amor
Polymer - Una bella historia de amor
 
Intro to polymer-Devfest Yaoundé 2013
Intro to polymer-Devfest Yaoundé 2013Intro to polymer-Devfest Yaoundé 2013
Intro to polymer-Devfest Yaoundé 2013
 
Web components
Web componentsWeb components
Web components
 
Web components
Web componentsWeb components
Web components
 
Web Components - The Future is Here
Web Components - The Future is HereWeb Components - The Future is Here
Web Components - The Future is Here
 
Polymer - Lego for the web!
Polymer - Lego for the web!Polymer - Lego for the web!
Polymer - Lego for the web!
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the future
 
Polymer Web Framework - Swecha Boot Camp
Polymer Web Framework - Swecha Boot CampPolymer Web Framework - Swecha Boot Camp
Polymer Web Framework - Swecha Boot Camp
 
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...
 
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
 
Rawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web ComponentsRawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web Components
 
Up & Running with Polymer
Up & Running with PolymerUp & Running with Polymer
Up & Running with Polymer
 
Introduction to web components
Introduction to web componentsIntroduction to web components
Introduction to web components
 
Polymer-Powered Design Systems - DevFest Florida
Polymer-Powered Design Systems - DevFest FloridaPolymer-Powered Design Systems - DevFest Florida
Polymer-Powered Design Systems - DevFest Florida
 
The Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has ArrivedThe Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has Arrived
 
Angular View Encapsulation
Angular View EncapsulationAngular View Encapsulation
Angular View Encapsulation
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
 
Александр Кашеверов - Polymer
Александр Кашеверов - PolymerАлександр Кашеверов - Polymer
Александр Кашеверов - Polymer
 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
 

Más de LearningTech

Más de LearningTech (20)

vim
vimvim
vim
 
ReactJs
ReactJsReactJs
ReactJs
 
Docker
DockerDocker
Docker
 
Semantic ui
Semantic uiSemantic ui
Semantic ui
 
node.js errors
node.js errorsnode.js errors
node.js errors
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejs
 
Expression tree
Expression treeExpression tree
Expression tree
 
SQL 效能調校
SQL 效能調校SQL 效能調校
SQL 效能調校
 
flexbox report
flexbox reportflexbox report
flexbox report
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
 
Reflection &amp; activator
Reflection &amp; activatorReflection &amp; activator
Reflection &amp; activator
 
Peggy markdown
Peggy markdownPeggy markdown
Peggy markdown
 
Node child process
Node child processNode child process
Node child process
 
20160415ken.lee
20160415ken.lee20160415ken.lee
20160415ken.lee
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Expression tree
Expression treeExpression tree
Expression tree
 
Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
git command
git commandgit command
git command
 
Asp.net MVC DI
Asp.net MVC DIAsp.net MVC DI
Asp.net MVC DI
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
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...DianaGray10
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
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, ...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
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 FMESafe Software
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 

Último (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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, ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
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
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

Polymer

  • 2. What is Polymer? ●The Polymer library is designed to make it easier and faster for developers to create great, reusable components for the modern web. ●With custom elements, you can extend the vocabulary of HTML with your own elements. Elements that provide sophisticated UI.
  • 3.
  • 4. Web Component ●HTML Template ●Custom Element ●Shadow DOM ●HTML Import
  • 5. Installing with Bower Project setup > bower init > bower install --save Polymer > bower update
  • 6. Quick tour of Polymer ● Register an element ● Add local DOM ● Compose with local DOM ● Use data binding ● Declare a property ● Bind to a property
  • 7. Register an element ● To register a new element, call the Polymer function, which registers a new element with the browser. Registering an element associates a tag name with a prototype, so you can add properties and methods to your custom element. The custom element’s name must contain a dash (-).
  • 8. Register an element Index.html <html> <head> <script src="webcomponents-lite.min.js"></script> <link rel="import" href="first-component.html"> </head> <body> <first-component></first-component> </body> </html> first-component.html <link rel="import" href="bower_components/polymer/polymer.html"> <script> Polymer({ is: "first-component", ready: function() { this.textContent = "I'm a proto-element." } }); </script>
  • 9. Custom Element Lifecycle callbacks ● created instead of createdCallback ● attached instead of attachedCallback ● detached instead of detachedCallback ● attributeChanged instead of attributeChangedCallback
  • 10. Custom Element Lifecycle callbacks Polymer({ is: "polymer-lifecycle", ready: function(){ }, created: function() {}, attached: function() {}, detached: function() {}, attributeChanged: function(name, type) { console.log(this.localName + '#' + this.id + ' attribute ' + name + ' was changed to ' + this.getAttribute(name)); } }); created ready attached
  • 11. Add local DOM ● Many elements include some internal DOM nodes to implement the element’s UI and behavior. Polymer calls this local DOM, and it provides an easy way to specify it. ● Local DOM is encapsulated inside the element.
  • 12. Add local DOM Index.html <html> <head> <script src="webcomponents-lite.min.js"></script> <link rel="import" href="dom-element.html"> </head> <body> <dom-element></dom-element> </body> </html> dom-element.html <link rel="import" href="bower_components/polymer/polymer.html"> <dom-module id="dom-element"> <template> <p>I'm a DOM element. </p> </template> <script> Polymer({ is: "dom-element" }); </script> </dom-module>
  • 13. Compose with local DOM ● Local DOM lets you control composition. The element’s children can be distributed so they render as if they were inserted into the local DOM tree.
  • 14. Compose with local DOM Index.html <html> <head> <script src="webcomponents-lite.min.js"></script> <link rel="import" href="picture-frame.html"> </head> <body> <picture-frame> <img src=”image1.jpg” alt=”” /> </picture-frame> </body> </html> picture-frame.html <link rel="import" href="polymer/polymer.html"> <dom-module id="picture-frame"> <template> <style> div { background-color: #ccc; } </style> <div> <content></content> </div> </template> <script> Polymer({ is: "picture-frame" }); </script> </dom-module>
  • 15. Use data binding ● Data binding is a great way to quickly propagate changes in your element and reduce boilerplate code. You can bind properties in your component using the “double-mustache” syntax ({{}}). The {{}} is replaced by the value of the property referenced between the brackets.
  • 16. Use data binding Index.html <html> <head> <script src="webcomponents-lite.min.js"></script> <link rel="import" href="name-tag.html"> </head> <body> <name-tag></name-tag> </body> </html> name-tag.html <link rel="import" href="polymer.html"> <dom-module id="name-tag"> <template> This is <b>{{owner}}</b>'s name-tag element. </template> <script> Polymer({ is: "name-tag", ready: function() { this.owner = "Daniel"; } }); </script> </dom-module>
  • 17. Declare a property ● Properties are an important part of an element’s public API. Polymer declared properties support a number of common patterns for properties — setting default values, configuring properties from markup, observing property changes, and more..
  • 18. Declare a property Index.html <html> <head> <script src="webcomponents-lite.min.js"></script> <link rel="import" href="configurable-name-tag.html"> </head> <body> <configurable-name-tag owner="Scott"></configurable-name-tag> </body> </html> configurable-name-tag.html <dom-module id="configurable-name-tag"> <template> This is <b>{{owner}}</b>'s configurable-name-tag . </template> <script> Polymer({ is: "configurable-name-tag", properties: { owner: { type: String, value: "Daniel" } } }); </script> </dom-module>
  • 19. Bind to a property ● In addition to text content, you can bind to an element’s properties (using property-name="{{binding}}"). Polymer properties can optionally support two-way binding. ●This example uses two-way binding: binding the value of a custom input element (iron-input) to the element’s owner property, so it’s updated as the user types
  • 20. Bind to a property Index.html <html> <head> <script src="webcomponents-lite.min.js"></script> <link rel="import" href="editable-name-tag.html"> </head> <body> <editable-name-tag></editable-name-tag> </body> </html> editable-name-tag.html <link rel="import" href="polymer.html"> <link rel="import" href="iron-input/iron-input.html"> <dom-module id="editable-name-tag"> <template> This is a <strong>{{owner}}</strong>'s editable-name-tag. <input is="iron-input" bind-value="{{owner}}"/> </template> <script> Polymer({ is: "editable-name-tag", properties: { owner: { type: String, value: "Daniel" } } }); </script> </dom-module>
  • 21. Reference Polymer 1.0 - https://www.polymer-project.org/1.0/docs/ Shadow - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Shadow Html Import - http://www.html5rocks.com/en/tutorials/webcomponents/imports/ Custom Elements - http://www.html5rocks.com/en/tutorials/webcomponents/customelements/

Notas del editor

  1. http://bbs.logdown.com/posts/210337-introduce-web-component-of-beginners-mind
  2. http://bbs.logdown.com/posts/210337-introduce-web-component-of-beginners-mind https://blog.othree.net/log/2013/11/27/web-component/ https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Shadow
  3. https://www.polymer-project.org/1.0/docs/start/quick-tour.html
  4. https://www.polymer-project.org/1.0/docs/devguide/registering-elements.html