Slide 1

Slide 1 text

JÖRG NEUMANN | ACANDO GMBH MANUEL RAUBER | THINKTECTURE AG WEB COMPONENTS MIT ANGULAR UI-FEUERWERK MIT STRUKTUR

Slide 2

Slide 2 text

JÖRG NEUMANN THEMEN § Mobile Development § UI-Technologien § Consulting, Coaching, Training KONTAKT § Mail: Joerg.Neumann@Acando.de § Twitter: @JoergNeumann § GitHub: https://github.com/JoergNeumann § Blog: www.HeadWriteLine.BlogSpot.com

Slide 3

Slide 3 text

MANUEL RAUBER THEMEN § Cross-Plattform Entwicklung mit Angular § Backend Entwicklung mit Node.js, .NET oder .NET Core § Consultant, Speaker, Writer KONTAKT § Mail: manuel.rauber@thinktecture.com § Twitter: @manuelrauber § Blog: https://manuel-rauber.com

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

DEVELOPER CHALLENGES

Slide 7

Slide 7 text

DESIGN DEVELOPMENT DESIGNER / DEVELOPER WORKFLOW

Slide 8

Slide 8 text

Slide 9

Slide 9 text

§ Keine Semantik § Intransparenz § Anpassungen schwierig § Framework-Abhängigkeit

Slide 10

Slide 10 text

+ - …
§ Global Scoping § Namenskonflikte § Styling-Konflikte

Slide 11

Slide 11 text

§ Semantik § Local Scoping § Konfiguration § Bundle Import

Slide 12

Slide 12 text

CUSTOM ELEMENTS Eine API zur Registrierung von eigenen HTML Elementen HTML TEMPLATES UI-Vorlage für eine Komponente SHADOW DOM Kapselung der inneren DOM- Bestandteile eines Elements HTML IMPORTS / ES MODULES Importieren von Komponenten WEB COMPONENTS

Slide 13

Slide 13 text

Custom Elements HTML Imports Shaddow DOM HTML Templates

Slide 14

Slide 14 text

DEMO

Slide 15

Slide 15 text

CUSTOM ELEMENTS DEFINITION § Eigene HTML-Elemente erstellen § Das Verhalten ist vom Dokument entkoppelt § Eigenständiges Lifecycle-Modell (Erstellung, Attributänderungen, …)

Slide 16

Slide 16 text

DEMO

Slide 17

Slide 17 text

HTML TEMPLATES DEFINITION § HTML Element § Enthält Content der nach dem Laden nicht direkt gerendert wird § Wird erst bei Verwendung gerendert § Das Fragment kann im Dokument wiederverwendet werden Nr. Name

Slide 18

Slide 18 text

DEMO

Slide 19

Slide 19 text

SHADOW DOM DEFINITION § Bietet ein gekapseltes DOM / CSS für eine Komponente FEATURES § Isolated DOM: Lokale Elemente der Komponente sind von außen nicht sichtbar. § Scoped CSS: Lokale CSS-Definitionen wirken sich nur auf die Komponente aus. § Composition: Komponente kann von außen per Markup erweitert werden. § Einfaches CSS: Keine Konflikte mit id/class-Namen von außen. § Produktivität: App besteht aus gekapselten, wiederverwendbaren Komponenten.

Slide 20

Slide 20 text

DEMO

Slide 21

Slide 21 text

SHADOW DOM - STYLING CSS SELECTORS § Pseudo-classes: :host, :host(), :host-context() § Pseudo-elements: ::slotted() § Combinator: >>> * :host { display: block; width: fit-content; font-size: 30px; background: #78909c; margin: 1px; padding: 14px; } span { background: white; font-size: 30px; } Document Element (Shadow Host) Shadow Root Content

Slide 22

Slide 22 text

+ -
kg Verwendung: Template: SHADOW DOM - COMPOSITION DEFINITION § Ermöglicht das Einbetten von benutzerdefinierten Elementen § -Element im Template dient als Platzhalter § slot-Eigenschaft im Host stellt die Verbindung her

Slide 23

Slide 23 text

DEMO

Slide 24

Slide 24 text

HTML IMPORTS DEFINITION § Dienen zum Paketieren von Komponenten § Kann CSS und JavaScript enthalten § Einbindung erfolgt über: § Wird zukünftig von ES6-Modulen abgelöst Human Being

What is a body without a heart?

var link = document.querySelector('link[rel=import]'); var heart = link.import; // Access DOM of the document in /imports/heart.html var pulse = heart.querySelector('div.pulse');

Slide 25

Slide 25 text

BROWSER-KOMPATIBILITÄT CUSTOM ELEMENTS V1 HTML TEMPLATES SHADOW DOM V1 HTML IMPORTS

Slide 26

Slide 26 text

BROWSER-KOMPATIBILITÄT Chrome Firefox IE 11+/ Edge Opera Safari 9+ Chrome (Android) Safari (iOS 9+) Template Native Native Partial Native Native Native Native HTML Imports Native Polyfill Polyfill Native Polyfill Native Polyfill Custom Elements Native Polyfill Polyfill Native Partial Native Partial Shadow DOM Native Polyfill Polyfill Native Partial Native Partial

Slide 27

Slide 27 text

DEMO

Slide 28

Slide 28 text

POLYMER WEB COMPONENTS-FRAMEWORK VON GOOGLE § Version 1.0 wurde 2015 veröffentlicht § Version 2 in 2017 FEATURES § Einfache Entwicklung von Custom Elements § Two-Way Data Binding § Computed Properties § Conditional & Repeat Templates § Gesture Events § Element Library

Slide 29

Slide 29 text

DEMO

Slide 30

Slide 30 text

ANGULAR

Slide 31

Slide 31 text

ANGULAR SINGLE-PAGE APPLICATION FRAMEWORK VON GOOGLE § Version 1 wurde 2010 veröffentlicht § Version 2 in 2016 als kompletter Rewrite („Application Platform“) § Folgt semantischer Versionierung (a lá Google Chrome) FEATURES § Hierarchisches Komponentenmodell § Datenbindung § Datenflusssteuerung via Input & Output § Routing § Dependency Injection

Slide 32

Slide 32 text

KOMPONENTEN HIERARCHISCHES KOMPONENTENMODELL § Kapseln Logik und Anzeige § Anzeige besteht aus Struktur und Design Parent -> Child Application Hackathons Users Hackathon Hackathon [hackathons]=“someExp” [hackathon]=“someExp” Child-> Parent Application Hackathons Users Hackathon Hackathon (rate)=“onRate()” (rate)=“onRate()” via @Input() via @Output()

Slide 33

Slide 33 text

DEMO

Slide 34

Slide 34 text

FAZIT Komponenten helfen! § Bessere Struktur der App § Klare Semantik § Fördert die Wartbarkeit Web Components unterstützen § Kapselung von Markup & Code § Bessere Wiederverwendung § Bisher noch nicht 100% Browser Support Angular § Unterstützt eine komponentenbasierte Architektur

Slide 35

Slide 35 text

@MANUELRAUBER @JOERGNEUMANN

Slide 36

Slide 36 text

Q & A

Slide 37

Slide 37 text

RESSOURCEN WEBCOMPONENTS.ORG § http://webcomponents.org/ WEB COMPONENTS TUTORIALS § https://blogs.windows.com/msedgedev/2015/07/14/bringing-componentization-to-the-web-an- overview-of-web-components/#TSeSZK7qXciRX8oE.99 § https://component.kitchen/tutorial WEB COMPONENTS BROWSER SUPPORT § http://webcomponents.org SHADOW DOM § https://developer.mozilla.org/en-US/docs/Web/Web_Components/Shadow_DOM

Slide 38

Slide 38 text

WEB COMPONENTS: BROWSER SUPPORT ÜBERBLICK ALLER FEATURES/BROWSERS § http://jonrimmer.github.io/are-we-componentized-yet/ CUSTOM ELEMENTS § http://caniuse.com/#search=Custom%20elements SHADOW DOM § http://caniuse.com/#search=shadow%20dom TEMPLATES § http://caniuse.com/#feat=template HTML IMPORTS § http://caniuse.com/#search=html%20imports

Slide 39

Slide 39 text

SPECS CUSTOM ELEMENTS § http://w3c.github.io/webcomponents/spec/custom/ HTML IMPORTS § http://w3c.github.io/webcomponents/spec/imports/ TEMPLATES § https://html.spec.whatwg.org/multipage/scripting.html#the-template-element SHADOW DOM § http://w3c.github.io/webcomponents/spec/shadow/