SlideShare a Scribd company logo
1 of 45
Download to read offline
CollabSphere 2019
Woburn, MA | October 28-30
Web Components:
build your own HTML tags
like <domino-view>
Knut Herrmann
1
CollabSphere 2019
Woburn, MA | October 28-30
2
Sponsors
CollabSphere 2019
Woburn, MA | October 28-30
3
Knut Herrmann
 Senior Software Architect
Leonso GmbH
 Notes Domino developer since version 2
 Web application developer
 StackOverflow contributor
E-Mail: knut.herrmann@leonso.de
Twitter: @KnutHerrmann
Skype: knut.herrmann2018 and 2019
CollabSphere 2019
Woburn, MA | October 28-30
4
Why
Web Components
?
CollabSphere 2019
Woburn, MA | October 28-30
5
Server-side
rendering
Client-side
rendering
XPages
Frameworks for
Web Application Development
CollabSphere 2019
Woburn, MA | October 28-30
6
React Frontend Domino Backend
CollabSphere 2019
Woburn, MA | October 28-30
7
Reusable
Components
consistency
less code
faster development
easier testing
fever bugs
CollabSphere 2019
Woburn, MA | October 28-30
8
CollabSphere 2019
Woburn, MA | October 28-30
9
CollabSphere 2019
Woburn, MA | October 28-30
10
CollabSphere 2019
Woburn, MA | October 28-30
11
Web Component
CollabSphere 2019
Woburn, MA | October 28-30
12
Web Components
based on web standards
framework agnostic
CollabSphere 2019
Woburn, MA | October 28-30
13
Let’s create a Web Component
<domino-view
db="myDb"
view="myView">
</domino-view>
CollabSphere 2019
Woburn, MA | October 28-30
14
Custom Elements
create new HTML tags or extend existing
with vanilla JS/HTML/CSS
CollabSphere 2019
Woburn, MA | October 28-30
15
class DominoElement extends HTMLElement {…code…}
customElements.define('domino-view', DominoElement);
<domino-view></domino-view>
<script type="module" src="domino-view.js"></script>
domino-view.js
index.html
dash!
Custom Elements
CollabSphere 2019
Woburn, MA | October 28-30
16
class DominoElement extends HTMLElement {
constructor() {
super();
...
}
connectedCallback() {
...
}
disconnectedCallback() {
...
}
}
live cycle
demo 1
Custom Elements
CollabSphere 2019
Woburn, MA | October 28-30
17
<domino-view>
attributes
<domino-view
db="myDb"
view="myView">
</domino-view>
<script>
document.querySelector('domino-view')
.setAttribute('view', 'myOtherView')
</script>
Custom Elements
attributes
CollabSphere 2019
Woburn, MA | October 28-30
18
<domino-view>
attributes
attributes
class DominoElement extends HTMLElement {
static get observedAttributes() {
return ["db", "view"];
}
attributeChangedCallback(attrName,
oldValue, newValue) {
if (attrName === "db") {
this._db = newValue;
} else if (attrName === "view") {
this._view = newValue;
}
this.render();
}
demo 2
Custom Elements
CollabSphere 2019
Woburn, MA | October 28-30
19
<domino-view>
<domino-view></domino-view>
properties
<script>
const dominoView =
document.querySelector('domino-view');
dominoView.db = 'myDb';
dominoView.view = 'myView';
</script>
Custom Elements
properties
CollabSphere 2019
Woburn, MA | October 28-30
20
<domino-view>
properties
properties
class DominoElement extends HTMLElement {
set view(view) {
this._view = view;
this.render();
}
get view() {
return this._view;
}
Custom Elements
CollabSphere 2019
Woburn, MA | October 28-30
21
<domino-view>
attributes
attributes & properties
properties
class DominoElement extends HTMLElement {
set view(view) {
this.setAttribute("view", view);
}
get view() {
return this.getAttribute("view");
}
demo 3
Custom Elements
CollabSphere 2019
Woburn, MA | October 28-30
class DominoElement extends HTMLElement {
attributeChangedCallback(attrName,
oldValue, newValue) {
...
this.render();
}
connectedCallback() {
this._isConnected = true;
this.render();
}
render = () =>
this._isConnected &&
/* render Domino view here */
this.innerHtml = ...
<domino-view>
22
attributes
properties
demo 4
Custom Elements
rendering
CollabSphere 2019
Woburn, MA | October 28-30
23
<domino-view>
attributes
events
properties
events
<domino-view
db="myDb"
view="myView">
</domino-view>
<script>
document
.querySelector("domino-view")
.addEventListener(
"handleRowClick",
event => doSomethingWith(event.detail)
);
</script>
Custom Elements
CollabSphere 2019
Woburn, MA | October 28-30
24
<domino-view>
attributes
properties
events
class DominoElement extends HTMLElement {
handleRowClick = (rowData) =>
this.dispatchEvent(
new CustomEvent("handleRowClick",
{detail: rowData}));
render = () =>
this._isConnected &&
/* render Domino view here */
...
handleRowClick={this.handleRowClick}
...
Custom Elements
events
CollabSphere 2019
Woburn, MA | October 28-30
25
<domino-view>
attributes
properties
events
<domino-form>
attributes
properties
events
application
demo 5
Custom Elements
events
CollabSphere 2019
Woburn, MA | October 28-30
26
Shadow DOM
encapsulates custom components
by hidden separated DOM
CollabSphere 2019
Woburn, MA | October 28-30
27
https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM
Shadow DOM
CollabSphere 2019
Woburn, MA | October 28-30
28
isolated DOM
simple CSS selectors
cheap style checks
fast
Shadow DOM
CollabSphere 2019
Woburn, MA | October 28-30
29
class DominoElement extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: 'open'});
}
Shadow DOM
CollabSphere 2019
Woburn, MA | October 28-30
30
.domino-view__header-row {
color: var(--header-color);
}
<style>
domino-view {
height: 300px;
color: blue;
--header-color: green;
}
</style>
<domino-view … ></domino-view>
shadow host
shadow DOM
CSS custom properties
User defined styles overwrite
custom element’s styles
Shadow DOM
CollabSphere 2019
Woburn, MA | October 28-30
31
:host {
all: initial;
display: block;
height: 100%;
}
:host([hidden]) {
display: none;
}
Inheritable styles
(background, color, font, line-height, etc.)
continue to inherit in shadow DOM
unlessshadow DOM
demo 6
Shadow DOM
CollabSphere 2019
Woburn, MA | October 28-30
32
Templates
placeholder for declaring the structure
of a custom element
CollabSphere 2019
Woburn, MA | October 28-30
33
parsed once
instantiated during
runtime any number of
times
Templates
CollabSphere 2019
Woburn, MA | October 28-30
34
const template = document.createElement('template');
template.innerHTML = `
<style>:host { ... }</style>
<h2>This is an example for Templates.</h2>
<slot></slot>
<p>Content...</p>
`;
class DominoElement extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: 'open'});
this.shadowRoot.appendChild(
template.content.cloneNode(true));
}
Templates
CollabSphere 2019
Woburn, MA | October 28-30
35
const template = document.createElement('template');
template.innerHTML = `
<style>:host { ... }</style>
<h2>This is an example for Templates.</h2>
<slot></slot>
<p>Content...</p>
`;
<domino-view ...>
<b>This will be placed into slot.</b>
</domino-view>
demo 7
Templates
CollabSphere 2019
Woburn, MA | October 28-30
36
Deployment
…
<script type="module"
src="https://server/WebComponents.nsf/domino-view.js">
</script>
demo XPages
… or publishing on NPM
CollabSphere 2019
Woburn, MA | October 28-30
37
https://www.webcomponents.org/
CollabSphere 2019
Woburn, MA | October 28-30
38
Compatibility
Use Web Components
Build Web Components
*
*
*with workarounds/limitations now – better in future releases https://custom-elements-everywhere.com/
CollabSphere 2019
Woburn, MA | October 28-30
39
https://www.polymer-project.org/
Tools for Web Component development
https://stenciljs.com/
CollabSphere 2019
Woburn, MA | October 28-30
Production ready free Web components
40
…
https://vaadin.com/components
CollabSphere 2019
Woburn, MA | October 28-30
41
Web Components
run on any platform or device
reusable, really
CollabSphere 2019
Woburn, MA | October 28-30
42
CollabSphere 2019
Woburn, MA | October 28-30
43
Suggestion: HCL or community
creates a cool set of Web Components
<domino-view>
<domino-datetime-field>
<domino-form>
<domino-folder>
<domino-agent>
<domino-what-ever>
<domino-login>
<domino-for-ever>
<domino-richtext-field>
CollabSphere 2019
Woburn, MA | October 28-30
44
Questions?
CollabSphere 2019
Woburn, MA | October 28-30
45
Thank you!

More Related Content

Similar to Build reusable Web Components for Domino apps

Unite Copehagen 2019 - Unity Roadmap 2020
Unite Copehagen 2019 - Unity Roadmap 2020Unite Copehagen 2019 - Unity Roadmap 2020
Unite Copehagen 2019 - Unity Roadmap 2020Unity Technologies
 
MDSD for iPhone and Android
MDSD for iPhone and AndroidMDSD for iPhone and Android
MDSD for iPhone and AndroidHeiko Behrens
 
Hartwarming lightning talk in winter Sapporo
Hartwarming lightning talk in winter SapporoHartwarming lightning talk in winter Sapporo
Hartwarming lightning talk in winter SapporoJun OHWADA
 
PrimeNG - Components para la Vida Real
PrimeNG - Components para la Vida RealPrimeNG - Components para la Vida Real
PrimeNG - Components para la Vida Realcagataycivici
 
Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015Tobias Mattsson
 
Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVCAcquisio
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinSimon Gauvin
 
Advanced SQL - Introduction to Databases (1007156ANR).pdf
Advanced SQL - Introduction to Databases (1007156ANR).pdfAdvanced SQL - Introduction to Databases (1007156ANR).pdf
Advanced SQL - Introduction to Databases (1007156ANR).pdfSara Parker
 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019Matt Raible
 
Creating effective ruby gems
Creating effective ruby gemsCreating effective ruby gems
Creating effective ruby gemsBen Zhang
 
MoDELS'16 presentation: Integration of a Graph-Based Model Indexer in Commerc...
MoDELS'16 presentation: Integration of a Graph-Based Model Indexer in Commerc...MoDELS'16 presentation: Integration of a Graph-Based Model Indexer in Commerc...
MoDELS'16 presentation: Integration of a Graph-Based Model Indexer in Commerc...Antonio García-Domínguez
 
Supercharge your data analytics with BigQuery
Supercharge your data analytics with BigQuerySupercharge your data analytics with BigQuery
Supercharge your data analytics with BigQueryMárton Kodok
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
Exploiting and empowering semantic data with 2 new semantic extension: Sparql...
Exploiting and empowering semantic data with 2 new semantic extension: Sparql...Exploiting and empowering semantic data with 2 new semantic extension: Sparql...
Exploiting and empowering semantic data with 2 new semantic extension: Sparql...Matteo Busanelli
 
A Short Introduction To jQuery
A Short Introduction To jQueryA Short Introduction To jQuery
A Short Introduction To jQuerySudar Muthu
 

Similar to Build reusable Web Components for Domino apps (20)

Unite Copehagen 2019 - Unity Roadmap 2020
Unite Copehagen 2019 - Unity Roadmap 2020Unite Copehagen 2019 - Unity Roadmap 2020
Unite Copehagen 2019 - Unity Roadmap 2020
 
Html 5 and css 3
Html 5 and css 3Html 5 and css 3
Html 5 and css 3
 
Blossom Q&A Webinar
Blossom Q&A WebinarBlossom Q&A Webinar
Blossom Q&A Webinar
 
MDSD for iPhone and Android
MDSD for iPhone and AndroidMDSD for iPhone and Android
MDSD for iPhone and Android
 
Hartwarming lightning talk in winter Sapporo
Hartwarming lightning talk in winter SapporoHartwarming lightning talk in winter Sapporo
Hartwarming lightning talk in winter Sapporo
 
PrimeNG - Components para la Vida Real
PrimeNG - Components para la Vida RealPrimeNG - Components para la Vida Real
PrimeNG - Components para la Vida Real
 
Hadoop presentation
Hadoop presentationHadoop presentation
Hadoop presentation
 
Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015Spring first in Magnolia CMS - Spring I/O 2015
Spring first in Magnolia CMS - Spring I/O 2015
 
Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVC
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon Gauvin
 
Advanced SQL - Introduction to Databases (1007156ANR).pdf
Advanced SQL - Introduction to Databases (1007156ANR).pdfAdvanced SQL - Introduction to Databases (1007156ANR).pdf
Advanced SQL - Introduction to Databases (1007156ANR).pdf
 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019
 
Creating effective ruby gems
Creating effective ruby gemsCreating effective ruby gems
Creating effective ruby gems
 
FrameMaker XML Author Toolkit
FrameMaker XML Author ToolkitFrameMaker XML Author Toolkit
FrameMaker XML Author Toolkit
 
MoDELS'16 presentation: Integration of a Graph-Based Model Indexer in Commerc...
MoDELS'16 presentation: Integration of a Graph-Based Model Indexer in Commerc...MoDELS'16 presentation: Integration of a Graph-Based Model Indexer in Commerc...
MoDELS'16 presentation: Integration of a Graph-Based Model Indexer in Commerc...
 
Supercharge your data analytics with BigQuery
Supercharge your data analytics with BigQuerySupercharge your data analytics with BigQuery
Supercharge your data analytics with BigQuery
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Exploiting and empowering semantic data with 2 new semantic extension: Sparql...
Exploiting and empowering semantic data with 2 new semantic extension: Sparql...Exploiting and empowering semantic data with 2 new semantic extension: Sparql...
Exploiting and empowering semantic data with 2 new semantic extension: Sparql...
 
A Short Introduction To jQuery
A Short Introduction To jQueryA Short Introduction To jQuery
A Short Introduction To jQuery
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 

Recently uploaded

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
(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
 
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.
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Recently uploaded (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
(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...
 
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
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

Build reusable Web Components for Domino apps

  • 1. CollabSphere 2019 Woburn, MA | October 28-30 Web Components: build your own HTML tags like <domino-view> Knut Herrmann 1
  • 2. CollabSphere 2019 Woburn, MA | October 28-30 2 Sponsors
  • 3. CollabSphere 2019 Woburn, MA | October 28-30 3 Knut Herrmann  Senior Software Architect Leonso GmbH  Notes Domino developer since version 2  Web application developer  StackOverflow contributor E-Mail: knut.herrmann@leonso.de Twitter: @KnutHerrmann Skype: knut.herrmann2018 and 2019
  • 4. CollabSphere 2019 Woburn, MA | October 28-30 4 Why Web Components ?
  • 5. CollabSphere 2019 Woburn, MA | October 28-30 5 Server-side rendering Client-side rendering XPages Frameworks for Web Application Development
  • 6. CollabSphere 2019 Woburn, MA | October 28-30 6 React Frontend Domino Backend
  • 7. CollabSphere 2019 Woburn, MA | October 28-30 7 Reusable Components consistency less code faster development easier testing fever bugs
  • 8. CollabSphere 2019 Woburn, MA | October 28-30 8
  • 9. CollabSphere 2019 Woburn, MA | October 28-30 9
  • 10. CollabSphere 2019 Woburn, MA | October 28-30 10
  • 11. CollabSphere 2019 Woburn, MA | October 28-30 11 Web Component
  • 12. CollabSphere 2019 Woburn, MA | October 28-30 12 Web Components based on web standards framework agnostic
  • 13. CollabSphere 2019 Woburn, MA | October 28-30 13 Let’s create a Web Component <domino-view db="myDb" view="myView"> </domino-view>
  • 14. CollabSphere 2019 Woburn, MA | October 28-30 14 Custom Elements create new HTML tags or extend existing with vanilla JS/HTML/CSS
  • 15. CollabSphere 2019 Woburn, MA | October 28-30 15 class DominoElement extends HTMLElement {…code…} customElements.define('domino-view', DominoElement); <domino-view></domino-view> <script type="module" src="domino-view.js"></script> domino-view.js index.html dash! Custom Elements
  • 16. CollabSphere 2019 Woburn, MA | October 28-30 16 class DominoElement extends HTMLElement { constructor() { super(); ... } connectedCallback() { ... } disconnectedCallback() { ... } } live cycle demo 1 Custom Elements
  • 17. CollabSphere 2019 Woburn, MA | October 28-30 17 <domino-view> attributes <domino-view db="myDb" view="myView"> </domino-view> <script> document.querySelector('domino-view') .setAttribute('view', 'myOtherView') </script> Custom Elements attributes
  • 18. CollabSphere 2019 Woburn, MA | October 28-30 18 <domino-view> attributes attributes class DominoElement extends HTMLElement { static get observedAttributes() { return ["db", "view"]; } attributeChangedCallback(attrName, oldValue, newValue) { if (attrName === "db") { this._db = newValue; } else if (attrName === "view") { this._view = newValue; } this.render(); } demo 2 Custom Elements
  • 19. CollabSphere 2019 Woburn, MA | October 28-30 19 <domino-view> <domino-view></domino-view> properties <script> const dominoView = document.querySelector('domino-view'); dominoView.db = 'myDb'; dominoView.view = 'myView'; </script> Custom Elements properties
  • 20. CollabSphere 2019 Woburn, MA | October 28-30 20 <domino-view> properties properties class DominoElement extends HTMLElement { set view(view) { this._view = view; this.render(); } get view() { return this._view; } Custom Elements
  • 21. CollabSphere 2019 Woburn, MA | October 28-30 21 <domino-view> attributes attributes & properties properties class DominoElement extends HTMLElement { set view(view) { this.setAttribute("view", view); } get view() { return this.getAttribute("view"); } demo 3 Custom Elements
  • 22. CollabSphere 2019 Woburn, MA | October 28-30 class DominoElement extends HTMLElement { attributeChangedCallback(attrName, oldValue, newValue) { ... this.render(); } connectedCallback() { this._isConnected = true; this.render(); } render = () => this._isConnected && /* render Domino view here */ this.innerHtml = ... <domino-view> 22 attributes properties demo 4 Custom Elements rendering
  • 23. CollabSphere 2019 Woburn, MA | October 28-30 23 <domino-view> attributes events properties events <domino-view db="myDb" view="myView"> </domino-view> <script> document .querySelector("domino-view") .addEventListener( "handleRowClick", event => doSomethingWith(event.detail) ); </script> Custom Elements
  • 24. CollabSphere 2019 Woburn, MA | October 28-30 24 <domino-view> attributes properties events class DominoElement extends HTMLElement { handleRowClick = (rowData) => this.dispatchEvent( new CustomEvent("handleRowClick", {detail: rowData})); render = () => this._isConnected && /* render Domino view here */ ... handleRowClick={this.handleRowClick} ... Custom Elements events
  • 25. CollabSphere 2019 Woburn, MA | October 28-30 25 <domino-view> attributes properties events <domino-form> attributes properties events application demo 5 Custom Elements events
  • 26. CollabSphere 2019 Woburn, MA | October 28-30 26 Shadow DOM encapsulates custom components by hidden separated DOM
  • 27. CollabSphere 2019 Woburn, MA | October 28-30 27 https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM Shadow DOM
  • 28. CollabSphere 2019 Woburn, MA | October 28-30 28 isolated DOM simple CSS selectors cheap style checks fast Shadow DOM
  • 29. CollabSphere 2019 Woburn, MA | October 28-30 29 class DominoElement extends HTMLElement { constructor() { super(); this.attachShadow({mode: 'open'}); } Shadow DOM
  • 30. CollabSphere 2019 Woburn, MA | October 28-30 30 .domino-view__header-row { color: var(--header-color); } <style> domino-view { height: 300px; color: blue; --header-color: green; } </style> <domino-view … ></domino-view> shadow host shadow DOM CSS custom properties User defined styles overwrite custom element’s styles Shadow DOM
  • 31. CollabSphere 2019 Woburn, MA | October 28-30 31 :host { all: initial; display: block; height: 100%; } :host([hidden]) { display: none; } Inheritable styles (background, color, font, line-height, etc.) continue to inherit in shadow DOM unlessshadow DOM demo 6 Shadow DOM
  • 32. CollabSphere 2019 Woburn, MA | October 28-30 32 Templates placeholder for declaring the structure of a custom element
  • 33. CollabSphere 2019 Woburn, MA | October 28-30 33 parsed once instantiated during runtime any number of times Templates
  • 34. CollabSphere 2019 Woburn, MA | October 28-30 34 const template = document.createElement('template'); template.innerHTML = ` <style>:host { ... }</style> <h2>This is an example for Templates.</h2> <slot></slot> <p>Content...</p> `; class DominoElement extends HTMLElement { constructor() { super(); this.attachShadow({mode: 'open'}); this.shadowRoot.appendChild( template.content.cloneNode(true)); } Templates
  • 35. CollabSphere 2019 Woburn, MA | October 28-30 35 const template = document.createElement('template'); template.innerHTML = ` <style>:host { ... }</style> <h2>This is an example for Templates.</h2> <slot></slot> <p>Content...</p> `; <domino-view ...> <b>This will be placed into slot.</b> </domino-view> demo 7 Templates
  • 36. CollabSphere 2019 Woburn, MA | October 28-30 36 Deployment … <script type="module" src="https://server/WebComponents.nsf/domino-view.js"> </script> demo XPages … or publishing on NPM
  • 37. CollabSphere 2019 Woburn, MA | October 28-30 37 https://www.webcomponents.org/
  • 38. CollabSphere 2019 Woburn, MA | October 28-30 38 Compatibility Use Web Components Build Web Components * * *with workarounds/limitations now – better in future releases https://custom-elements-everywhere.com/
  • 39. CollabSphere 2019 Woburn, MA | October 28-30 39 https://www.polymer-project.org/ Tools for Web Component development https://stenciljs.com/
  • 40. CollabSphere 2019 Woburn, MA | October 28-30 Production ready free Web components 40 … https://vaadin.com/components
  • 41. CollabSphere 2019 Woburn, MA | October 28-30 41 Web Components run on any platform or device reusable, really
  • 42. CollabSphere 2019 Woburn, MA | October 28-30 42
  • 43. CollabSphere 2019 Woburn, MA | October 28-30 43 Suggestion: HCL or community creates a cool set of Web Components <domino-view> <domino-datetime-field> <domino-form> <domino-folder> <domino-agent> <domino-what-ever> <domino-login> <domino-for-ever> <domino-richtext-field>
  • 44. CollabSphere 2019 Woburn, MA | October 28-30 44 Questions?
  • 45. CollabSphere 2019 Woburn, MA | October 28-30 45 Thank you!