SlideShare a Scribd company logo
1 of 23
Polymer 3.0
A simple Polymer 3.0 project structure
Copyright 2011 - 2018, ThinkOpen S.r.l.
What’s Polymer
3.0?
Polymer 3.0 is the latest version of the
Polymer library for building web
components. It is developed by
Google.
For docs and resources visit
https://www.polymer-project.org/
Copyright 2011 - 2018, ThinkOpen S.r.l.
Basics
Copyright 2011 - 2018, ThinkOpen S.r.l.
Basics
What is a Web Component?
Web components are a set of web platfor
APIs that allow you to create new custom
reusable, encapsulated HTML tags to use
web pages and web apps. Custom
components and widgets build on the We
Component standards, will work across
modern browsers, and can be used with a
JavaScript library or framework that work
with HTML. [1]
[1] https://www.webcomponents.org/introduction
Copyright 2011 - 2018, ThinkOpen S.r.l.
Basics
What is a Custom Element?
Custom elements provide a component model for
the web. The custom elements specification
provides:
● A mechanism for associating a class with a
custom element name.
● A set of lifecycle callbacks invoked when an
instance of the custom element changes
state (for example, added or removed from
the document).
● A callback invoked whenever one of a
specified set of attributes changes on the
instance.
Copyright 2011 - 2018, ThinkOpen S.r.l.
What is a Customer Element?
<html>
<head></head>
<body>
<my-custom-element></my-custom-element>
</body>
</html>
export class MyCustomElement extends PolymerElement {
...
}
customElements.define('my-custom-element',
MyCustomElement);
<div class="MyElement">
<div class="MyElement__title"></div>
<div class="MyElement__body"></div>
</div>
<html>
<head></head>
<body>
#ShadowDOM
<div class="MyElement">
<div class="MyElement__title"></div>
<div class="MyElement__body"></div>
</div>
</body>
</html>
Copyright 2011 - 2018, ThinkOpen S.r.l.
constructor
Custom Element Lyfecycle
connectedCallback
disconnectedCallback
attributeChangedCallback
Copyright 2011 - 2018, ThinkOpen S.r.l.
constructor
Custom Element Lyfecycle
connectedCallback
disconnectedCallback
attributeChangedCallback
ready
Copyright 2011 - 2018, ThinkOpen S.r.l.
Basics
What is the Shadow DOM?
The DOM a component author
writes. Shadow DOM is local to the
component and defines its
internal structure, scoped CSS,
and encapsulates your
implementation details. It can also
define how to render markup
that's authored by the consumer
of your component.
Copyright 2011 - 2018, ThinkOpen S.r.l.
What is the Shadow DOM?
<div>
#shadow-root
<style>...</style>
<slot name="icon"></slot>
<span id="wrapper">
<slot>Button</slot>
</span>
</div>
A shadow root is a document fragment that gets attached to a “host” element. The act of attaching a shadow root is how the element
gains its shadow DOM.
let div = document.createElement('div');
let shadowRoot = header.attachShadow({mode: 'open'});
Copyright 2011 - 2018, ThinkOpen S.r.l.
What is the Shadow DOM?
➢ DOM encapsulation
➢ Scoped CSS
➢ Composition
➢ Simplifies CSS
Copyright 2011 - 2018, ThinkOpen S.r.l.
What is the Shadow DOM?
<better-button>
<!-- the image and span are better-button's light
DOM -->
<img src="gear.svg" slot="icon">
<span>Settings</span>
</better-button>
#shadow-root
<style>...</style>
<slot name="icon"></slot>
<span id="wrapper">
<slot>Button</slot>
</span>
<better-button>
#shadow-root
<style>...</style>
<slot name="icon">
<img src="gear.svg" slot="icon">
</slot>
<span id="wrapper">
<slot>
<span>Settings</span>
</slot>
</span>
</better-button>
Example by: https://developers.google.com/web/fundamentals/web-components/shadowdom
Copyright 2011 - 2018, ThinkOpen S.r.l.
What is the Shadow DOM?
Example by: https://developers.google.com/web/fundamentals/web-components/shadowdom
#shadow-root
<div id="tabs">
<slot id="tabsSlot" name="title"></slot>
</div>
<div id="panels">
<slot id="panelsSlot"></slot>
</div>
<fancy-tabs>
<button slot="title">Title</button>
<button slot="title" selected>Title 2</button>
<button slot="title">Title 3</button>
<section>content panel 1</section>
<section>content panel 2</section>
<section>content panel 3</section>
</fancy-tabs>
<fancy-tabs>
#shadow-root
<div id="tabs">
<slot id="tabsSlot" name="title">
<button slot="title">Title</button>
<button slot="title" selected>Title 2</button>
<button slot="title">Title 3</button>
</slot>
</div>
<div id="panels">
<slot id="panelsSlot">
<section>content panel 1</section>
<section>content panel 2</section>
<section>content panel 3</section>
</slot>
</div>
</fancy-tabs>
Copyright 2011 - 2018, ThinkOpen S.r.l.
Basics
How Polymer 3.0 handles and
fires events?
Elements use events to communicate state
changes up the DOM tree to parent
elements. Polymer elements can use the
standard DOM APIs for creating,
dispatching, and listening for events.
Polymer also provides annotated event
listeners, which allow you to specify event
listeners declaratively as part of the
element's DOM template
Copyright 2011 - 2018, ThinkOpen S.r.l.
How Polymer 3.0 handles and fires events?
<multiselection-component(data='{{convertFromTableToMultiselection(config.table)}}' on-checked-
box='onCheckedBox')></multiselection-component>
(this as any).dispatchEvent(new CustomEvent('checked-box', {detail: {name: e.currentTarget.name, checked:
e.currentTarget.checked}}));
(this as any).dispatchEvent( new CustomEvent( 'on-change-page', <CustomEventInit> {bubbles:true,
cancelable:true, composed: true, detail: {}} ) );
(this as any).addEventListener('on-change-page', e => {
e.stopPropagation();
});
Copyright 2011 - 2018, ThinkOpen S.r.l.
Basics
Observers
Observers are methods invoked
when observable changes occur to
the element's data.
Copyright 2011 - 2018, ThinkOpen S.r.l.
Observers
static get observers() {
return [
'checkList(data.*)',
'getArraySize(array.length)',
'checkArray(array.splices)',
'isChange(data.change)'
]
}
static get properties() {
return {
configuration: {
type: Object,
observer: 'drawChart'
},
data: {
type: Object,
observer: 'drawChart'
}
};
}
Copyright 2011 - 2018, ThinkOpen S.r.l.
Basics
Data Binding
A data binding connects data from
a custom element (the host
element) to a property or attribute
of an element in its local DOM (the
child or target element). The host
element data can be a property or
sub-property represented by a
data path, or data generated
based on one or more paths.
Copyright 2011 - 2018, ThinkOpen S.r.l.
Data Binding
<table-component(data='[[data.table]]' config='{{config.table}}')></table-component>
<multiselection-component(data='{{convertFromTableToMultiselection(config.table)}}')></multiselection-component>
One-way Two-way
Copyright 2011 - 2018, ThinkOpen S.r.l.
Polyfill
In web development, a polyfill is code that
implements a feature on web browsers that
do not support the feature. Most often, it
refers to a JavaScript library that
implements an HTML5 web standard, either
an established standard (supported by
some browsers) on older browsers, or a
proposed standard (not supported by any
browsers) on existing browsers. Formally, "a
polyfill is a shim for a browser API".[1]
[1] Wikipedia EN
Copyright 2011 - 2018, ThinkOpen S.r.l.
Polymer-cli
Polymer CLI is the official command line tool
for Polymer projects and Web Components.
It includes a build pipeline, a boilerplate
generator for creating elements and apps, a
linter, a development server, and a test
runner.[1]
[1] https://polymer-library.polymer-project.org/3.0/docs/tools/polymer-cli
Copyright 2011 - 2018, ThinkOpen S.r.l.
The code
Copyright 2011 - 2018, ThinkOpen S.r.l.
Basic structure code:
https://github.com/Darbiel/polymer3-basic-typerscript-pug-project
Workshop example code:
https://github.com/Darbiel/polymer3-ts-workshop
Sources for the example

More Related Content

What's hot

Micronaut Http Client
Micronaut Http ClientMicronaut Http Client
Micronaut Http ClientJames Kleeh
 
Binding business data to vaadin components
Binding business data to vaadin componentsBinding business data to vaadin components
Binding business data to vaadin componentsPeter Lehto
 
Java Script and HTML.
Java Script and HTML.Java Script and HTML.
Java Script and HTML.Akshat Vig
 
MVVM & Data Binding Library
MVVM & Data Binding Library MVVM & Data Binding Library
MVVM & Data Binding Library 10Clouds
 

What's hot (6)

Micronaut Http Client
Micronaut Http ClientMicronaut Http Client
Micronaut Http Client
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 
Binding business data to vaadin components
Binding business data to vaadin componentsBinding business data to vaadin components
Binding business data to vaadin components
 
Java Script and HTML.
Java Script and HTML.Java Script and HTML.
Java Script and HTML.
 
Jquery 2
Jquery 2Jquery 2
Jquery 2
 
MVVM & Data Binding Library
MVVM & Data Binding Library MVVM & Data Binding Library
MVVM & Data Binding Library
 

Similar to Polymer 3.0 by Michele Gallotti

Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web DevelopmentRobert J. Stein
 
Build UI of the Future with React 360
Build UI of the Future with React 360Build UI of the Future with React 360
Build UI of the Future with React 360RapidValue
 
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...goodfriday
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Jonas Follesø
 
Silverlight Developer Introduction
Silverlight   Developer IntroductionSilverlight   Developer Introduction
Silverlight Developer IntroductionTomy Ismail
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5Mahmoud Ouf
 
Presentation about html5 css3
Presentation about html5 css3Presentation about html5 css3
Presentation about html5 css3Gopi A
 
Flex3 Deep Dive Final
Flex3 Deep Dive FinalFlex3 Deep Dive Final
Flex3 Deep Dive FinalRJ Owen
 
Ed presents JSF 2.2 and WebSocket to Gameduell.
Ed presents JSF 2.2 and WebSocket to Gameduell.Ed presents JSF 2.2 and WebSocket to Gameduell.
Ed presents JSF 2.2 and WebSocket to Gameduell.Edward Burns
 
Salesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web ComponentSalesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web ComponentAccenture Hungary
 
Django 1.10.3 Getting started
Django 1.10.3 Getting startedDjango 1.10.3 Getting started
Django 1.10.3 Getting startedMoniaJ
 
DHTML - Dynamic HTML
DHTML - Dynamic HTMLDHTML - Dynamic HTML
DHTML - Dynamic HTMLReem Alattas
 
Meteor + Ionic Introduction
Meteor + Ionic IntroductionMeteor + Ionic Introduction
Meteor + Ionic IntroductionLearningTech
 
Rawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web ComponentsRawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web ComponentsRawnet
 
Xml operations in odoo
Xml operations in odooXml operations in odoo
Xml operations in odooCeline George
 
PPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to serverPPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to servershivanichourasia01
 

Similar to Polymer 3.0 by Michele Gallotti (20)

Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web Development
 
Build UI of the Future with React 360
Build UI of the Future with React 360Build UI of the Future with React 360
Build UI of the Future with React 360
 
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 
Silverlight Developer Introduction
Silverlight   Developer IntroductionSilverlight   Developer Introduction
Silverlight Developer Introduction
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5
 
Presentation about html5 css3
Presentation about html5 css3Presentation about html5 css3
Presentation about html5 css3
 
Flex3 Deep Dive Final
Flex3 Deep Dive FinalFlex3 Deep Dive Final
Flex3 Deep Dive Final
 
Ed presents JSF 2.2 and WebSocket to Gameduell.
Ed presents JSF 2.2 and WebSocket to Gameduell.Ed presents JSF 2.2 and WebSocket to Gameduell.
Ed presents JSF 2.2 and WebSocket to Gameduell.
 
Actionview
ActionviewActionview
Actionview
 
Salesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web ComponentSalesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web Component
 
Django 1.10.3 Getting started
Django 1.10.3 Getting startedDjango 1.10.3 Getting started
Django 1.10.3 Getting started
 
DHTML - Dynamic HTML
DHTML - Dynamic HTMLDHTML - Dynamic HTML
DHTML - Dynamic HTML
 
Meteor + Ionic Introduction
Meteor + Ionic IntroductionMeteor + Ionic Introduction
Meteor + Ionic Introduction
 
Html5
Html5Html5
Html5
 
Html5
Html5Html5
Html5
 
Rawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web ComponentsRawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web Components
 
Xml operations in odoo
Xml operations in odooXml operations in odoo
Xml operations in odoo
 
Angular 2
Angular 2Angular 2
Angular 2
 
PPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to serverPPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to server
 

More from ThinkOpen

Discover Facilitation: gestire le riunioni in modo efficace
Discover Facilitation: gestire le riunioni in modo efficaceDiscover Facilitation: gestire le riunioni in modo efficace
Discover Facilitation: gestire le riunioni in modo efficaceThinkOpen
 
Infrastructure as a code: a cloud approach
Infrastructure as a code: a cloud approachInfrastructure as a code: a cloud approach
Infrastructure as a code: a cloud approachThinkOpen
 
Smart Signage: la nuova digital experience
Smart Signage: la nuova digital experienceSmart Signage: la nuova digital experience
Smart Signage: la nuova digital experienceThinkOpen
 
I Graph Database: analisi del comportamento degli utenti
I Graph Database: analisi del comportamento degli utentiI Graph Database: analisi del comportamento degli utenti
I Graph Database: analisi del comportamento degli utentiThinkOpen
 
2019: Odissea nell'e-commerce
2019: Odissea nell'e-commerce2019: Odissea nell'e-commerce
2019: Odissea nell'e-commerceThinkOpen
 
Guida galattica a Javascript
Guida galattica a JavascriptGuida galattica a Javascript
Guida galattica a JavascriptThinkOpen
 
Java 8 -12: da Oracle a Eclipse. Due anni e una rivoluzione
Java 8 -12: da Oracle a Eclipse. Due anni e una rivoluzioneJava 8 -12: da Oracle a Eclipse. Due anni e una rivoluzione
Java 8 -12: da Oracle a Eclipse. Due anni e una rivoluzioneThinkOpen
 
Amazon Alexa vs Google Home. Quale scegliere? Funzionalità e usi
Amazon Alexa vs Google Home. Quale scegliere? Funzionalità e usiAmazon Alexa vs Google Home. Quale scegliere? Funzionalità e usi
Amazon Alexa vs Google Home. Quale scegliere? Funzionalità e usiThinkOpen
 
Amazon Web Services - Le potenzialità di AWS e il mondo di Amazon Alexa by Ni...
Amazon Web Services - Le potenzialità di AWS e il mondo di Amazon Alexa by Ni...Amazon Web Services - Le potenzialità di AWS e il mondo di Amazon Alexa by Ni...
Amazon Web Services - Le potenzialità di AWS e il mondo di Amazon Alexa by Ni...ThinkOpen
 
"Java 8, Lambda e la programmazione funzionale" by Theodor Dumitrescu
"Java 8, Lambda e la programmazione funzionale" by Theodor Dumitrescu"Java 8, Lambda e la programmazione funzionale" by Theodor Dumitrescu
"Java 8, Lambda e la programmazione funzionale" by Theodor DumitrescuThinkOpen
 
"Odoo: l'open source che fa tremare SAP" by Davide Davin e Nicola Napolitano
"Odoo: l'open source che fa tremare SAP" by Davide Davin e Nicola Napolitano"Odoo: l'open source che fa tremare SAP" by Davide Davin e Nicola Napolitano
"Odoo: l'open source che fa tremare SAP" by Davide Davin e Nicola NapolitanoThinkOpen
 
"Configuration Manager: il ruolo nel ciclo di vita del software" by Omar Rossini
"Configuration Manager: il ruolo nel ciclo di vita del software" by Omar Rossini"Configuration Manager: il ruolo nel ciclo di vita del software" by Omar Rossini
"Configuration Manager: il ruolo nel ciclo di vita del software" by Omar RossiniThinkOpen
 
"Google Home: how to make Google do it" by Theodor Dumitrescu e Gianfranco Bo...
"Google Home: how to make Google do it" by Theodor Dumitrescu e Gianfranco Bo..."Google Home: how to make Google do it" by Theodor Dumitrescu e Gianfranco Bo...
"Google Home: how to make Google do it" by Theodor Dumitrescu e Gianfranco Bo...ThinkOpen
 
"ThinkOpen Agile Days - #Day3" by Donato Andrisani e Giuseppe Trotta
"ThinkOpen Agile Days - #Day3" by Donato Andrisani e Giuseppe Trotta"ThinkOpen Agile Days - #Day3" by Donato Andrisani e Giuseppe Trotta
"ThinkOpen Agile Days - #Day3" by Donato Andrisani e Giuseppe TrottaThinkOpen
 
"Reactive programming" by Theodor Dumitrescu & Gianfranco Bottiglieri
"Reactive programming" by Theodor Dumitrescu & Gianfranco Bottiglieri"Reactive programming" by Theodor Dumitrescu & Gianfranco Bottiglieri
"Reactive programming" by Theodor Dumitrescu & Gianfranco BottiglieriThinkOpen
 
"GDPR: cos'è e come funziona" by Francesco Puglisi
"GDPR: cos'è e come funziona" by Francesco Puglisi"GDPR: cos'è e come funziona" by Francesco Puglisi
"GDPR: cos'è e come funziona" by Francesco PuglisiThinkOpen
 
"ThinkOpen Agile Days - #Day2" by Donato Andrisani e Giuseppe Trotta
"ThinkOpen Agile Days - #Day2" by Donato Andrisani e Giuseppe Trotta"ThinkOpen Agile Days - #Day2" by Donato Andrisani e Giuseppe Trotta
"ThinkOpen Agile Days - #Day2" by Donato Andrisani e Giuseppe TrottaThinkOpen
 
"ThinkOpen Agile Days - #Day" by Giuseppe Trotta
"ThinkOpen Agile Days - #Day" by Giuseppe Trotta"ThinkOpen Agile Days - #Day" by Giuseppe Trotta
"ThinkOpen Agile Days - #Day" by Giuseppe TrottaThinkOpen
 
"React Native" by Vanessa Leo e Roberto Brogi
"React Native" by Vanessa Leo e Roberto Brogi "React Native" by Vanessa Leo e Roberto Brogi
"React Native" by Vanessa Leo e Roberto Brogi ThinkOpen
 
"How to... React" by Luca Perna
"How to... React" by Luca Perna"How to... React" by Luca Perna
"How to... React" by Luca PernaThinkOpen
 

More from ThinkOpen (20)

Discover Facilitation: gestire le riunioni in modo efficace
Discover Facilitation: gestire le riunioni in modo efficaceDiscover Facilitation: gestire le riunioni in modo efficace
Discover Facilitation: gestire le riunioni in modo efficace
 
Infrastructure as a code: a cloud approach
Infrastructure as a code: a cloud approachInfrastructure as a code: a cloud approach
Infrastructure as a code: a cloud approach
 
Smart Signage: la nuova digital experience
Smart Signage: la nuova digital experienceSmart Signage: la nuova digital experience
Smart Signage: la nuova digital experience
 
I Graph Database: analisi del comportamento degli utenti
I Graph Database: analisi del comportamento degli utentiI Graph Database: analisi del comportamento degli utenti
I Graph Database: analisi del comportamento degli utenti
 
2019: Odissea nell'e-commerce
2019: Odissea nell'e-commerce2019: Odissea nell'e-commerce
2019: Odissea nell'e-commerce
 
Guida galattica a Javascript
Guida galattica a JavascriptGuida galattica a Javascript
Guida galattica a Javascript
 
Java 8 -12: da Oracle a Eclipse. Due anni e una rivoluzione
Java 8 -12: da Oracle a Eclipse. Due anni e una rivoluzioneJava 8 -12: da Oracle a Eclipse. Due anni e una rivoluzione
Java 8 -12: da Oracle a Eclipse. Due anni e una rivoluzione
 
Amazon Alexa vs Google Home. Quale scegliere? Funzionalità e usi
Amazon Alexa vs Google Home. Quale scegliere? Funzionalità e usiAmazon Alexa vs Google Home. Quale scegliere? Funzionalità e usi
Amazon Alexa vs Google Home. Quale scegliere? Funzionalità e usi
 
Amazon Web Services - Le potenzialità di AWS e il mondo di Amazon Alexa by Ni...
Amazon Web Services - Le potenzialità di AWS e il mondo di Amazon Alexa by Ni...Amazon Web Services - Le potenzialità di AWS e il mondo di Amazon Alexa by Ni...
Amazon Web Services - Le potenzialità di AWS e il mondo di Amazon Alexa by Ni...
 
"Java 8, Lambda e la programmazione funzionale" by Theodor Dumitrescu
"Java 8, Lambda e la programmazione funzionale" by Theodor Dumitrescu"Java 8, Lambda e la programmazione funzionale" by Theodor Dumitrescu
"Java 8, Lambda e la programmazione funzionale" by Theodor Dumitrescu
 
"Odoo: l'open source che fa tremare SAP" by Davide Davin e Nicola Napolitano
"Odoo: l'open source che fa tremare SAP" by Davide Davin e Nicola Napolitano"Odoo: l'open source che fa tremare SAP" by Davide Davin e Nicola Napolitano
"Odoo: l'open source che fa tremare SAP" by Davide Davin e Nicola Napolitano
 
"Configuration Manager: il ruolo nel ciclo di vita del software" by Omar Rossini
"Configuration Manager: il ruolo nel ciclo di vita del software" by Omar Rossini"Configuration Manager: il ruolo nel ciclo di vita del software" by Omar Rossini
"Configuration Manager: il ruolo nel ciclo di vita del software" by Omar Rossini
 
"Google Home: how to make Google do it" by Theodor Dumitrescu e Gianfranco Bo...
"Google Home: how to make Google do it" by Theodor Dumitrescu e Gianfranco Bo..."Google Home: how to make Google do it" by Theodor Dumitrescu e Gianfranco Bo...
"Google Home: how to make Google do it" by Theodor Dumitrescu e Gianfranco Bo...
 
"ThinkOpen Agile Days - #Day3" by Donato Andrisani e Giuseppe Trotta
"ThinkOpen Agile Days - #Day3" by Donato Andrisani e Giuseppe Trotta"ThinkOpen Agile Days - #Day3" by Donato Andrisani e Giuseppe Trotta
"ThinkOpen Agile Days - #Day3" by Donato Andrisani e Giuseppe Trotta
 
"Reactive programming" by Theodor Dumitrescu & Gianfranco Bottiglieri
"Reactive programming" by Theodor Dumitrescu & Gianfranco Bottiglieri"Reactive programming" by Theodor Dumitrescu & Gianfranco Bottiglieri
"Reactive programming" by Theodor Dumitrescu & Gianfranco Bottiglieri
 
"GDPR: cos'è e come funziona" by Francesco Puglisi
"GDPR: cos'è e come funziona" by Francesco Puglisi"GDPR: cos'è e come funziona" by Francesco Puglisi
"GDPR: cos'è e come funziona" by Francesco Puglisi
 
"ThinkOpen Agile Days - #Day2" by Donato Andrisani e Giuseppe Trotta
"ThinkOpen Agile Days - #Day2" by Donato Andrisani e Giuseppe Trotta"ThinkOpen Agile Days - #Day2" by Donato Andrisani e Giuseppe Trotta
"ThinkOpen Agile Days - #Day2" by Donato Andrisani e Giuseppe Trotta
 
"ThinkOpen Agile Days - #Day" by Giuseppe Trotta
"ThinkOpen Agile Days - #Day" by Giuseppe Trotta"ThinkOpen Agile Days - #Day" by Giuseppe Trotta
"ThinkOpen Agile Days - #Day" by Giuseppe Trotta
 
"React Native" by Vanessa Leo e Roberto Brogi
"React Native" by Vanessa Leo e Roberto Brogi "React Native" by Vanessa Leo e Roberto Brogi
"React Native" by Vanessa Leo e Roberto Brogi
 
"How to... React" by Luca Perna
"How to... React" by Luca Perna"How to... React" by Luca Perna
"How to... React" by Luca Perna
 

Recently uploaded

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 

Recently uploaded (20)

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 

Polymer 3.0 by Michele Gallotti

  • 1. Polymer 3.0 A simple Polymer 3.0 project structure
  • 2. Copyright 2011 - 2018, ThinkOpen S.r.l. What’s Polymer 3.0? Polymer 3.0 is the latest version of the Polymer library for building web components. It is developed by Google. For docs and resources visit https://www.polymer-project.org/
  • 3. Copyright 2011 - 2018, ThinkOpen S.r.l. Basics
  • 4. Copyright 2011 - 2018, ThinkOpen S.r.l. Basics What is a Web Component? Web components are a set of web platfor APIs that allow you to create new custom reusable, encapsulated HTML tags to use web pages and web apps. Custom components and widgets build on the We Component standards, will work across modern browsers, and can be used with a JavaScript library or framework that work with HTML. [1] [1] https://www.webcomponents.org/introduction
  • 5. Copyright 2011 - 2018, ThinkOpen S.r.l. Basics What is a Custom Element? Custom elements provide a component model for the web. The custom elements specification provides: ● A mechanism for associating a class with a custom element name. ● A set of lifecycle callbacks invoked when an instance of the custom element changes state (for example, added or removed from the document). ● A callback invoked whenever one of a specified set of attributes changes on the instance.
  • 6. Copyright 2011 - 2018, ThinkOpen S.r.l. What is a Customer Element? <html> <head></head> <body> <my-custom-element></my-custom-element> </body> </html> export class MyCustomElement extends PolymerElement { ... } customElements.define('my-custom-element', MyCustomElement); <div class="MyElement"> <div class="MyElement__title"></div> <div class="MyElement__body"></div> </div> <html> <head></head> <body> #ShadowDOM <div class="MyElement"> <div class="MyElement__title"></div> <div class="MyElement__body"></div> </div> </body> </html>
  • 7. Copyright 2011 - 2018, ThinkOpen S.r.l. constructor Custom Element Lyfecycle connectedCallback disconnectedCallback attributeChangedCallback
  • 8. Copyright 2011 - 2018, ThinkOpen S.r.l. constructor Custom Element Lyfecycle connectedCallback disconnectedCallback attributeChangedCallback ready
  • 9. Copyright 2011 - 2018, ThinkOpen S.r.l. Basics What is the Shadow DOM? The DOM a component author writes. Shadow DOM is local to the component and defines its internal structure, scoped CSS, and encapsulates your implementation details. It can also define how to render markup that's authored by the consumer of your component.
  • 10. Copyright 2011 - 2018, ThinkOpen S.r.l. What is the Shadow DOM? <div> #shadow-root <style>...</style> <slot name="icon"></slot> <span id="wrapper"> <slot>Button</slot> </span> </div> A shadow root is a document fragment that gets attached to a “host” element. The act of attaching a shadow root is how the element gains its shadow DOM. let div = document.createElement('div'); let shadowRoot = header.attachShadow({mode: 'open'});
  • 11. Copyright 2011 - 2018, ThinkOpen S.r.l. What is the Shadow DOM? ➢ DOM encapsulation ➢ Scoped CSS ➢ Composition ➢ Simplifies CSS
  • 12. Copyright 2011 - 2018, ThinkOpen S.r.l. What is the Shadow DOM? <better-button> <!-- the image and span are better-button's light DOM --> <img src="gear.svg" slot="icon"> <span>Settings</span> </better-button> #shadow-root <style>...</style> <slot name="icon"></slot> <span id="wrapper"> <slot>Button</slot> </span> <better-button> #shadow-root <style>...</style> <slot name="icon"> <img src="gear.svg" slot="icon"> </slot> <span id="wrapper"> <slot> <span>Settings</span> </slot> </span> </better-button> Example by: https://developers.google.com/web/fundamentals/web-components/shadowdom
  • 13. Copyright 2011 - 2018, ThinkOpen S.r.l. What is the Shadow DOM? Example by: https://developers.google.com/web/fundamentals/web-components/shadowdom #shadow-root <div id="tabs"> <slot id="tabsSlot" name="title"></slot> </div> <div id="panels"> <slot id="panelsSlot"></slot> </div> <fancy-tabs> <button slot="title">Title</button> <button slot="title" selected>Title 2</button> <button slot="title">Title 3</button> <section>content panel 1</section> <section>content panel 2</section> <section>content panel 3</section> </fancy-tabs> <fancy-tabs> #shadow-root <div id="tabs"> <slot id="tabsSlot" name="title"> <button slot="title">Title</button> <button slot="title" selected>Title 2</button> <button slot="title">Title 3</button> </slot> </div> <div id="panels"> <slot id="panelsSlot"> <section>content panel 1</section> <section>content panel 2</section> <section>content panel 3</section> </slot> </div> </fancy-tabs>
  • 14. Copyright 2011 - 2018, ThinkOpen S.r.l. Basics How Polymer 3.0 handles and fires events? Elements use events to communicate state changes up the DOM tree to parent elements. Polymer elements can use the standard DOM APIs for creating, dispatching, and listening for events. Polymer also provides annotated event listeners, which allow you to specify event listeners declaratively as part of the element's DOM template
  • 15. Copyright 2011 - 2018, ThinkOpen S.r.l. How Polymer 3.0 handles and fires events? <multiselection-component(data='{{convertFromTableToMultiselection(config.table)}}' on-checked- box='onCheckedBox')></multiselection-component> (this as any).dispatchEvent(new CustomEvent('checked-box', {detail: {name: e.currentTarget.name, checked: e.currentTarget.checked}})); (this as any).dispatchEvent( new CustomEvent( 'on-change-page', <CustomEventInit> {bubbles:true, cancelable:true, composed: true, detail: {}} ) ); (this as any).addEventListener('on-change-page', e => { e.stopPropagation(); });
  • 16. Copyright 2011 - 2018, ThinkOpen S.r.l. Basics Observers Observers are methods invoked when observable changes occur to the element's data.
  • 17. Copyright 2011 - 2018, ThinkOpen S.r.l. Observers static get observers() { return [ 'checkList(data.*)', 'getArraySize(array.length)', 'checkArray(array.splices)', 'isChange(data.change)' ] } static get properties() { return { configuration: { type: Object, observer: 'drawChart' }, data: { type: Object, observer: 'drawChart' } }; }
  • 18. Copyright 2011 - 2018, ThinkOpen S.r.l. Basics Data Binding A data binding connects data from a custom element (the host element) to a property or attribute of an element in its local DOM (the child or target element). The host element data can be a property or sub-property represented by a data path, or data generated based on one or more paths.
  • 19. Copyright 2011 - 2018, ThinkOpen S.r.l. Data Binding <table-component(data='[[data.table]]' config='{{config.table}}')></table-component> <multiselection-component(data='{{convertFromTableToMultiselection(config.table)}}')></multiselection-component> One-way Two-way
  • 20. Copyright 2011 - 2018, ThinkOpen S.r.l. Polyfill In web development, a polyfill is code that implements a feature on web browsers that do not support the feature. Most often, it refers to a JavaScript library that implements an HTML5 web standard, either an established standard (supported by some browsers) on older browsers, or a proposed standard (not supported by any browsers) on existing browsers. Formally, "a polyfill is a shim for a browser API".[1] [1] Wikipedia EN
  • 21. Copyright 2011 - 2018, ThinkOpen S.r.l. Polymer-cli Polymer CLI is the official command line tool for Polymer projects and Web Components. It includes a build pipeline, a boilerplate generator for creating elements and apps, a linter, a development server, and a test runner.[1] [1] https://polymer-library.polymer-project.org/3.0/docs/tools/polymer-cli
  • 22. Copyright 2011 - 2018, ThinkOpen S.r.l. The code
  • 23. Copyright 2011 - 2018, ThinkOpen S.r.l. Basic structure code: https://github.com/Darbiel/polymer3-basic-typerscript-pug-project Workshop example code: https://github.com/Darbiel/polymer3-ts-workshop Sources for the example

Editor's Notes

  1. constructor = Called when the element is upgraded. The constructor is a logical place to set default values, and to manually set up event listeners for the element itself. connectedCallback = Called when the element is added to a document. Can be called multiple times during the lifetime of an element. For event listener too attributeChangedCallback = Called when any of the element's attributes are changed, appended, removed, or replaced. disconnectedCallback = Called when the element is removed from a document. Can be called multiple times during the lifetime of an element.
  2. ready = Called during Polymer-specific element initialization. Called once, the first time the element is attached to the document.
  3. The events fired can reach only the first next layer. If you want to fire an event over the first layer, you can use bubbling