SlideShare a Scribd company logo
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 Client
James Kleeh
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
Mindfire Solutions
 
Binding business data to vaadin components
Binding business data to vaadin componentsBinding business data to vaadin components
Binding business data to vaadin components
Peter 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 Development
Robert 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 360
RapidValue
 
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 2008
Jonas Follesø
 
Silverlight Developer Introduction
Silverlight   Developer IntroductionSilverlight   Developer Introduction
Silverlight Developer Introduction
Tomy Ismail
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5
Mahmoud Ouf
 
Presentation about html5 css3
Presentation about html5 css3Presentation about html5 css3
Presentation about html5 css3
Gopi A
 
Flex3 Deep Dive Final
Flex3 Deep Dive FinalFlex3 Deep Dive Final
Flex3 Deep Dive Final
RJ 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
 
Actionview
ActionviewActionview
Actionview
Amal Subhash
 
Salesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web ComponentSalesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web Component
Accenture Hungary
 
Django 1.10.3 Getting started
Django 1.10.3 Getting startedDjango 1.10.3 Getting started
Django 1.10.3 Getting started
MoniaJ
 
DHTML - Dynamic HTML
DHTML - Dynamic HTMLDHTML - Dynamic HTML
DHTML - Dynamic HTML
Reem Alattas
 
Meteor + Ionic Introduction
Meteor + Ionic IntroductionMeteor + Ionic Introduction
Meteor + Ionic Introduction
LearningTech
 
Html5
Html5Html5
Rawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web ComponentsRawnet Lightning Talk - Web Components
Rawnet Lightning Talk - Web Components
Rawnet
 
Xml operations in odoo
Xml operations in odooXml operations in odoo
Xml operations in odoo
Celine George
 
Angular 2
Angular 2Angular 2
Angular 2
Pramod Raghav
 
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
shivanichourasia01
 

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 efficace
ThinkOpen
 
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
ThinkOpen
 
Smart Signage: la nuova digital experience
Smart Signage: la nuova digital experienceSmart Signage: la nuova digital experience
Smart Signage: la nuova digital experience
ThinkOpen
 
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
ThinkOpen
 
2019: Odissea nell'e-commerce
2019: Odissea nell'e-commerce2019: Odissea nell'e-commerce
2019: Odissea nell'e-commerce
ThinkOpen
 
Guida galattica a Javascript
Guida galattica a JavascriptGuida galattica a Javascript
Guida galattica a Javascript
ThinkOpen
 
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
ThinkOpen
 
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
ThinkOpen
 
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 Dumitrescu
ThinkOpen
 
"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
ThinkOpen
 
"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
ThinkOpen
 
"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 Trotta
ThinkOpen
 
"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
ThinkOpen
 
"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
 
"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
 
"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
ThinkOpen
 
"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 Perna
ThinkOpen
 

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

How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 

Recently uploaded (20)

How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 

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