96
@peter_lehto WEB COMPONENTS

Vaadin DevDay 2017 - Web Components

Embed Size (px)

Citation preview

Page 1: Vaadin DevDay 2017 - Web Components

5

S T O R Y A N D P H I L O S O P H Y

Software is eating the world and what most of us see of it is the user interface. The user

interface has become the key component of how the users experience the business

behind it. Competition is lost or won due to user experience. Simplicity is king and the

users get frustrated by anything ugly, slow or not working on the device they happen to

use at the time. We at Vaadin fight for simplicity and invite everyone to join this fight.

Together we want to build a user interface that puts a smile on the user’s face.

Vaadin is the technology that empowers developers to build the best web-apps for

business purposes. Our priority over everything else is developer productivity because

we believe that by simplifying the developer experience and saving the developer’s

time, they are best able to focus on building great user interfaces.

Our brand is what we want everyone to think about us. When everyone - both us and

the people around us - have a consistent understanding of what Vaadin is and what we

stand for, it enables that image to spread and amplify. This book defines what we want

that image to be. It defines what the Vaadin brand is.

I hope that You are as excited and proud of living and breathing the Vaadin brand as

I am. You are the one who is shaping what everyone thinks about Vaadin - using this

brand as a tool and a guideline every day.

Let’s fight for simplicity for both the users and the developers!

Joonas Lehtinen

Founder & CEO

Vaadin

I N T R O D U C T I O N

@peter_lehto

W E B C O M P O N E N T S

Page 2: Vaadin DevDay 2017 - Web Components

Session’s content

Page 3: Vaadin DevDay 2017 - Web Components

Session’s content

• The roots, where are we coming from?

Page 4: Vaadin DevDay 2017 - Web Components

Session’s content

• The roots, where are we coming from?

• What constitutes a Web Component?

Page 5: Vaadin DevDay 2017 - Web Components

Session’s content

• The roots, where are we coming from?

• What constitutes a Web Component?

• Progressive Web Apps (PWA), Vaadin, Future?

Page 6: Vaadin DevDay 2017 - Web Components

Session’s content

• The roots, where are we coming from?

• What constitutes a Web Component?

• Progressive Web Apps (PWA), Vaadin, Future?

• Using Web Components with Vaadin today.

Page 7: Vaadin DevDay 2017 - Web Components

Session’s content

• The roots, where are we coming from?

• What constitutes a Web Component?

• Progressive Web Apps (PWA), Vaadin, Future?

• Using Web Components with Vaadin today.

Page 8: Vaadin DevDay 2017 - Web Components

Vaadin Framework

Page 9: Vaadin DevDay 2017 - Web Components

Vaadin Framework

.1 .2 3 4 5 6 7

Page 10: Vaadin DevDay 2017 - Web Components

Vaadin Framework

.1 .2 3 4 5 6 720

0120

0220

0220

0720

0720

0920

13

Page 11: Vaadin DevDay 2017 - Web Components
Page 12: Vaadin DevDay 2017 - Web Components

> var foo = [0];> foo == !foo;

Page 13: Vaadin DevDay 2017 - Web Components

> var foo = [0];> foo == !foo;> true

Page 14: Vaadin DevDay 2017 - Web Components

> [] + [];

> var foo = [0];> foo == !foo;> true

Page 15: Vaadin DevDay 2017 - Web Components

> [] + [];>

> var foo = [0];> foo == !foo;> true

Page 16: Vaadin DevDay 2017 - Web Components

> [] + [];>

> [] + {};

> var foo = [0];> foo == !foo;> true

Page 17: Vaadin DevDay 2017 - Web Components

> [] + [];>

> [] + {};> [object Object]

> var foo = [0];> foo == !foo;> true

Page 18: Vaadin DevDay 2017 - Web Components

> [] + [];>

> [] + {};> [object Object]

> {} + [];

> var foo = [0];> foo == !foo;> true

Page 19: Vaadin DevDay 2017 - Web Components

> [] + [];>

> [] + {};> [object Object]

> {} + [];> 0

> var foo = [0];> foo == !foo;> true

Page 20: Vaadin DevDay 2017 - Web Components

> [] + [];>

> [] + {};> [object Object]

> {} + [];> 0

> {} + {};> var foo = [0];> foo == !foo;> true

Page 21: Vaadin DevDay 2017 - Web Components

> [] + [];>

> [] + {};> [object Object]

> {} + [];> 0

> {} + {};> NaN

> var foo = [0];> foo == !foo;> true

Page 22: Vaadin DevDay 2017 - Web Components

> [] + [];>

> [] + {};> [object Object]

> {} + [];> 0

> {} + {};> NaN

> NaN == NaN;

> var foo = [0];> foo == !foo;> true

Page 23: Vaadin DevDay 2017 - Web Components

> [] + [];>

> [] + {};> [object Object]

> {} + [];> 0

> {} + {};> NaN

> NaN == NaN;> false

> var foo = [0];> foo == !foo;> true

Page 24: Vaadin DevDay 2017 - Web Components

> [] + [];>

> [] + {};> [object Object]

> {} + [];> 0

> {} + {};> NaN

> NaN == NaN;> false

> typeof NaN;

> var foo = [0];> foo == !foo;> true

Page 25: Vaadin DevDay 2017 - Web Components

> [] + [];>

> [] + {};> [object Object]

> {} + [];> 0

> {} + {};> NaN

> NaN == NaN;> false

> typeof NaN;> number

> var foo = [0];> foo == !foo;> true

Page 26: Vaadin DevDay 2017 - Web Components

> [] + [];>

> [] + {};> [object Object]

> {} + [];> 0

> {} + {};> NaN

> NaN == NaN;> false

> typeof NaN;> number

> var foo = [0];> foo == !foo;> true

Page 27: Vaadin DevDay 2017 - Web Components
Page 28: Vaadin DevDay 2017 - Web Components

A History of Stability

OVER 15+ YEARS OFSHIELDING YOU FROMCONSTANT CHANGE

< Millstone 3.0 (2002)

IT Mill Toolkit 5 (2009)

Vaadin 7.6.0 (2016) >

Page 29: Vaadin DevDay 2017 - Web Components

Vaadin Framework

.1 .2 3 4 5 6 720

0120

0220

0220

0720

0720

0920

13

Page 30: Vaadin DevDay 2017 - Web Components

Vaadin Framework

.1 .2 3 4 5 6 7 820

0120

0220

0220

0720

0720

0920

1320

17

Page 31: Vaadin DevDay 2017 - Web Components

Framework

8Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

Recent Changes

Page 32: Vaadin DevDay 2017 - Web Components

Framework

8Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

Recent Changes• Java 8

• New data binding

• Focus on new browsers

• HTML imports (Web components)

• Improved performance

Page 33: Vaadin DevDay 2017 - Web Components

Vaadin Framework

.1 .2 3 4 5 6 7 820

0120

0220

0220

0520

0720

0920

1320

17

GWTAJAXHTML

Page 34: Vaadin DevDay 2017 - Web Components

Backend

Server

Page 35: Vaadin DevDay 2017 - Web Components

UI Backend

Server

Page 36: Vaadin DevDay 2017 - Web Components

Browser

UI Backend

Server

Widgets Components

Page 37: Vaadin DevDay 2017 - Web Components

Them

e

Browser

UI Backend

Server

Widgets Components

Page 38: Vaadin DevDay 2017 - Web Components

Them

e

Browser

UI Backend

Server

Widgets Components

Shared StateRPC

Page 39: Vaadin DevDay 2017 - Web Components

GWT

Page 40: Vaadin DevDay 2017 - Web Components

Java -> JavaScript - Optimizing compiler

GWT

Page 41: Vaadin DevDay 2017 - Web Components

Browser specific compilation - No browser differences

GWT

Page 42: Vaadin DevDay 2017 - Web Components

Pure Java - Web apps without JavaScript

GWT

Page 43: Vaadin DevDay 2017 - Web Components

JSInterop - JavaScript interoperability

GWT

Page 44: Vaadin DevDay 2017 - Web Components
Page 45: Vaadin DevDay 2017 - Web Components

Vaadin Framework

.1 .2 3 4 5 6 7 820

0120

0220

0220

0520

0720

0920

1320

17

Web ComponentsGWTAJAXHTML

Page 46: Vaadin DevDay 2017 - Web Components

Framework

8Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

Web Components

.2

Page 47: Vaadin DevDay 2017 - Web Components

Framework

8Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

Web Components• Toolchain integration (Bower, npm)

• Integration with Vaadin Elements

.2

Page 48: Vaadin DevDay 2017 - Web Components

Vaadin Framework

.1 .2 3 4 5 6 7 8

Web ComponentsGWTAJAXHTML

Page 49: Vaadin DevDay 2017 - Web Components

Vaadin Framework

.1 .2 3 4 5 6 7 8

Vaadin Core Elements

Web ComponentsGWTAJAXHTML

Page 50: Vaadin DevDay 2017 - Web Components

Vaadin Core Elements

Vaadin Framework

4 5 6 7 8

Page 51: Vaadin DevDay 2017 - Web Components

Vaadin Core Elements

Vaadin Framework

4 5 6 7 8

2

“9”

Page 52: Vaadin DevDay 2017 - Web Components

Session’s content

• The roots, where are we coming from?

• What constitutes a Web Component?

• Progressive Web Apps (PWA), Vaadin, Future?

• Using Web Components with Vaadin today.

Page 53: Vaadin DevDay 2017 - Web Components

Web Components? Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

Page 54: Vaadin DevDay 2017 - Web Components

Web Components? Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

• HTML Templates

Page 55: Vaadin DevDay 2017 - Web Components

Web Components? Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

• HTML Templates• Custom Elements

Page 56: Vaadin DevDay 2017 - Web Components

Web Components? Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

• HTML Templates• Custom Elements• Shadow DOM

Page 57: Vaadin DevDay 2017 - Web Components

Web Components? Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

• HTML Templates• Custom Elements• Shadow DOM• HTML Imports

Page 58: Vaadin DevDay 2017 - Web Components

Templates

<template id=“my-template"> <style> ... </style> <div> <h1>Web Components</h1> <img src="/img/logo.svg"> </div> </template>

Page 59: Vaadin DevDay 2017 - Web Components

Custom Elements

<my-new-element></my-new-element>

Page 60: Vaadin DevDay 2017 - Web Components

S H A D O W D O M

Page 61: Vaadin DevDay 2017 - Web Components
Page 62: Vaadin DevDay 2017 - Web Components

HTML Imports

<link rel="import" href="my-el.html">

Page 63: Vaadin DevDay 2017 - Web Components

• Encapsulation

• Reusability

Benefits of using Web Components

Page 64: Vaadin DevDay 2017 - Web Components

Web Components in Practice 1/2

• A new TAG for your browser ‘<my-ui-component>’

• Based on standard specifications (no frameworks!)

Page 65: Vaadin DevDay 2017 - Web Components

Web Components in Practice 2/2

Advantages:

1. Goodbye to browser plugins (WC + HTML5)

2. Isolated from other elements in DOM

3. Easy to share (bower)

4. Easy to integrate

Page 66: Vaadin DevDay 2017 - Web Components
Page 67: Vaadin DevDay 2017 - Web Components
Page 68: Vaadin DevDay 2017 - Web Components

Polyfills? Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

Page 69: Vaadin DevDay 2017 - Web Components

Polyfills? Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

• Make standards work with today’s browsers

Page 70: Vaadin DevDay 2017 - Web Components

Polyfills? Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

• Make standards work with today’s browsers

• Able to detect native support

Page 71: Vaadin DevDay 2017 - Web Components

Polyfills? Vaadin Elements• Web Components

A new, major standard to create components for the Web “Custom tags for HTML”

• Vaadin ElementsHigh-quality UI components for users of client-side frameworks such as Angular, ionic …

• A new generation of UI components to be used also with future versions of the Vaadin server-side framework

• Make standards work with today’s browsers

• Able to detect native support

• Standards should out power polyfills in future

Page 72: Vaadin DevDay 2017 - Web Components

Session’s content

• The roots, where are we coming from?

• What constitutes a Web Component?

• Progressive Web Apps (PWA), Vaadin, Future?

• Using Web Components with Vaadin today.

Page 73: Vaadin DevDay 2017 - Web Components

B U I L D I N G A P W A

Page 74: Vaadin DevDay 2017 - Web Components

Reliable

User experiences need to be...

Page 75: Vaadin DevDay 2017 - Web Components

Reliability means never showing the offline dinosaur

Page 76: Vaadin DevDay 2017 - Web Components

Reliable Fast

User experiences need to be...

Page 77: Vaadin DevDay 2017 - Web Components

of users abandon sites that take longer than 3 seconds to load53%

Page 78: Vaadin DevDay 2017 - Web Components

Reliable Fast Engaging

User experiences need to be...

Page 79: Vaadin DevDay 2017 - Web Components

Immersive Notifications

Engaging

Home Screen

Page 80: Vaadin DevDay 2017 - Web Components

Full screen, theming,

orientation, etc.

Immersive Notifications

Engaging

Home Screen

Page 81: Vaadin DevDay 2017 - Web Components

Full screen, theming,

orientation, etc.

Immersive Notifications

Engaging

Auto-adding to Home Screen

Home Screen

Page 82: Vaadin DevDay 2017 - Web Components

Full screen, theming,

orientation, etc.

Push notifications

Immersive Notifications

Engaging

Auto-adding to Home Screen

Home Screen

Page 83: Vaadin DevDay 2017 - Web Components

`

Web Push Notifications

Page 84: Vaadin DevDay 2017 - Web Components
Page 85: Vaadin DevDay 2017 - Web Components
Page 86: Vaadin DevDay 2017 - Web Components
Page 87: Vaadin DevDay 2017 - Web Components
Page 88: Vaadin DevDay 2017 - Web Components
Page 89: Vaadin DevDay 2017 - Web Components
Page 90: Vaadin DevDay 2017 - Web Components
Page 91: Vaadin DevDay 2017 - Web Components
Page 92: Vaadin DevDay 2017 - Web Components
Page 93: Vaadin DevDay 2017 - Web Components

D E M O

Page 94: Vaadin DevDay 2017 - Web Components

Lessons learned

Page 95: Vaadin DevDay 2017 - Web Components

Lessons learned

• TODO: Remember to add items before the talk…

Page 96: Vaadin DevDay 2017 - Web Components

@peter_lehto

T H A N K Y O U !