Slide 1

Slide 1 text

Componentize your app with Polymer +Rob Dodson @rob_dodson

Slide 2

Slide 2 text

JAM https://goo.gl/0HxSK2

Slide 3

Slide 3 text

https://goo.gl/5oqPUy

Slide 4

Slide 4 text

https://goo.gl/c06yLS

Slide 5

Slide 5 text

when presented with an abundance of choice, you can feel increasingly unsure of whether yours is the right one - Addy Osmani

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

LET’S WORK TOGETHER Image:

Slide 9

Slide 9 text

What is Polymer?

Slide 10

Slide 10 text

Polymer is not a framework.

Slide 11

Slide 11 text

Existing Frameworks Applications Web Platform Web Components built with Polymer (or not)

Slide 12

Slide 12 text

The Polymer Experiment https://goo.gl/sjeFN6

Slide 13

Slide 13 text

https://goo.gl/ulZRgU LIKES!

Slide 14

Slide 14 text

Data binding is sweet! Reuse other components Easy to get started

Slide 15

Slide 15 text

https://goo.gl/sjeFN6 DISLIKES

Slide 16

Slide 16 text

https://goo.gl/sjeFN6 Cross-browser weirdness Polyfills are slow Theming is hard

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

actual Polymer engineer

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

1.0 121kb 42kb 0.5

Slide 21

Slide 21 text

1.0 0.5 121kb 42kb

Slide 22

Slide 22 text

READY FOR PRODUCTION

Slide 23

Slide 23 text

Let me show you

Slide 24

Slide 24 text

Success! Your first component!

Slide 25

Slide 25 text

Slide 26

Slide 26 text

Polymer({ is: 'quick-alert' });

Slide 27

Slide 27 text

Slide 28

Slide 28 text

Slide 29

Slide 29 text

Local DOM - The DOM an elements is in charge of creating and managing

Slide 30

Slide 30 text

Alert!!

Slide 31

Slide 31 text

.alert { background: green; }
Alert!!

Slide 32

Slide 32 text

Slide 33

Slide 33 text

Alert!!!

Slide 34

Slide 34 text

Alert!!

Slide 35

Slide 35 text

Light DOM - The world outside your component’s Local DOM

Slide 36

Slide 36 text

Alert!!

Slide 37

Slide 37 text

Slide 38

Slide 38 text

Success! Your first component!

Slide 39

Slide 39 text

Success! Your first component!

Slide 40

Slide 40 text

Properties & Data Binding

Slide 41

Slide 41 text

Polymer({ is: ‘name-tag’, properties: { first: String, last: String } }); Property type

Slide 42

Slide 42 text

Polymer({ is: ‘name-tag’, properties: { first: String, last: String, age: { type: Number, value: 42 } } }); Default value

Slide 43

Slide 43 text

Polymer({ is: ‘name-tag’, properties: { first: String, last: String, age: { type: Number, value: 42, observer: ‘_ageChanged' } } }); Observer function

Slide 44

Slide 44 text

Polymer({ is: ‘name-tag’, properties: { first: String, last: String, age: { type: Number, value: 42, observer: ‘_ageChanged’, notify: true } } }); Notify event / bindings

Slide 45

Slide 45 text

Polymer({ is: ‘name-tag’, properties: { first: String, last: String, fullname: { type: String, computed: ‘_computeFullName(first, last)' } } }); Computed property

Slide 46

Slide 46 text

Success! Your first component!

Slide 47

Slide 47 text

quick-alert.html Polymer({ is: 'quick-alert', properties: { shown: { type: Boolean, value: false, notify: true } } });

Slide 48

Slide 48 text

Slide 49

Slide 49 text

Slide 50

Slide 50 text

Thanks for signing up! Sign up for our newsletter

Slide 51

Slide 51 text

Thanks for signing up! Sign up for our newsletter

Slide 52

Slide 52 text

Thanks for signing up! Sign up for our newsletter

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Styling & Theming

Slide 55

Slide 55 text

.alert { background: green; }
Alert!!

Slide 56

Slide 56 text

.alert { background: var(--quick-alert-background); }
Alert!!
A custom property

Slide 57

Slide 57 text

.alert { background: var(--quick-alert-background, green); }
Alert!!

Slide 58

Slide 58 text

quick-alert { --quick-alert-background: #FF5722; }

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

.alert { background: green; @apply(--quick-alert-theme) }
Alert!!

Slide 61

Slide 61 text

quick-alert { }

Slide 62

Slide 62 text

quick-alert { --quick-alert-theme: { }; }

Slide 63

Slide 63 text

quick-alert { --quick-alert-theme: { background: linear-gradient(135deg, #3D7EAA, #FFE47A); font-size: 24px; text-shadow: 0px 3px 0px #909090, 0px 5px 10px rgba(0, 0, 0, 0.6); }; }

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

Elements Building blocks for a better web

Slide 66

Slide 66 text

There’s an element for that!

Slide 67

Slide 67 text

core paper

Slide 68

Slide 68 text

core paper

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

elements.polymer-project.org

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

There’s an element for that!

Slide 86

Slide 86 text

Applications Combining elements into something great

Slide 87

Slide 87 text

Polymer Starter Kit

Slide 88

Slide 88 text

Polymer Starter Kit

Slide 89

Slide 89 text

Image: App templates

Slide 90

Slide 90 text

Navigation Cards Layout

Slide 91

Slide 91 text

Navigation List Detail

Slide 92

Slide 92 text

List Card Over

Slide 93

Slide 93 text

Image: Responsive breakpoints

Slide 94

Slide 94 text

Material Design breakpoints

Slide 95

Slide 95 text

App-wide Theming #303f9f CSS custom properties --dark-primary-color --light-primary-color --accent-color --primary-text-color #303f9f --dark-primary-color --light-primary-color --accent-color --primary-text-color

Slide 96

Slide 96 text

Web App install banner Mobile Web defaults Meta theme color

Slide 97

Slide 97 text

Icons

Slide 98

Slide 98 text

Offline-first (in your app)

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

// While there is only one cache in this example, the same logic will handle the case where // there are multiple versioned caches. var expectedCacheNames = Object.keys(CURRENT_CACHES).map(function(key) { return CURRENT_CACHES[key]; }); event.waitUntil( caches.keys().then(function(cacheNames) { return Promise.all( cacheNames.map(function(cacheName) { if (expectedCacheNames.indexOf(cacheName) == -1) { // If this cache name isn't present in the array of "expected" cache names, then delete it. console.log('Deleting out of date cache:', cacheName); return caches.delete(cacheName); } }) ); }) ); }); // This sample illustrates an aggressive approach to caching, in which every valid response is

Slide 101

Slide 101 text

There’s an element for that!

Slide 102

Slide 102 text

No content

Slide 103

Slide 103 text

Service Worker caching Take your app offline with ease

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

There’s an element for that too!

Slide 106

Slide 106 text

Push Notifications Stay informed of messages from your app

Slide 107

Slide 107 text

Production-ising Apps

Slide 108

Slide 108 text

image: http://gulpjs.com

Slide 109

Slide 109 text

Build process out of the box

Slide 110

Slide 110 text

Live-reload and cross-device development

Slide 111

Slide 111 text

DOWNLOAD developers.google.com/web/tools/polymer-starter-kit

Slide 112

Slide 112 text

Polymer Starter Kit + Angular 2 The best of both worlds

Slide 113

Slide 113 text

No content

Slide 114

Slide 114 text

angular/zone.js #138

Slide 115

Slide 115 text

No content

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

index.html …

Slide 118

Slide 118 text

Polymer Starter Kit

Slide 119

Slide 119 text

index.html …
Menu … Delete this element and move the content to your own Angular template

Slide 120

Slide 120 text

my-app.ts @Component({ selector: 'my-app' }) @View({ templateUrl: 'views/my-app/my-app.html' }) // Component controller export class MyAppComponent { } bootstrap(MyAppComponent);

Slide 121

Slide 121 text

my-app.html
Menu Home

Slide 122

Slide 122 text

Remove old data bindings: {{param.user}}

Slide 123

Slide 123 text

Remove old data bindings: {{param.user}} Remove event handlers: on-iron-select=“onMenuSelect"

Slide 124

Slide 124 text

Remove old data bindings: {{param.user}} Remove event handlers: on-iron-select=“onMenuSelect" Update routes: selected=“{{route}}”

Slide 125

Slide 125 text

Remove old data bindings: {{param.user}} Remove event handlers: on-iron-select=“onMenuSelect" Update routes: [selected]=“route”

Slide 126

Slide 126 text

my-app.ts // Component controller export class MyAppComponent { }

Slide 127

Slide 127 text

my-app.ts // Component controller export class MyAppComponent { page('/', () => { this.route = 'home'; }); page('/users', () => { this.route = 'users'; }); page('/contact', () => { this.route = 'contact'; }); // add #! before urls page({ hashbang: true }); }

Slide 128

Slide 128 text

No content

Slide 129

Slide 129 text

Adding components Dealing with content distribution

Slide 130

Slide 130 text

No content

Slide 131

Slide 131 text

WAT?

Slide 132

Slide 132 text

Local DOM - The DOM an elements is in charge of creating and managing

Slide 133

Slide 133 text

index.html ... ...

Slide 134

Slide 134 text

index.html ... // Tell Polymer to use Shadow DOM var Polymer = Polymer || {}; Polymer.dom = 'shadow'; ...

Slide 135

Slide 135 text

No content

Slide 136

Slide 136 text

NativeShadowDomStrategy?

Slide 137

Slide 137 text

NativeShadowDomStrategy? Shady DOM Adapters?

Slide 138

Slide 138 text

NativeShadowDomStrategy? Shady DOM Adapters? Ship Shadow DOM!

Slide 139

Slide 139 text

Listening for events Going old school

Slide 140

Slide 140 text

my-app.html …

Slide 141

Slide 141 text

my-app.html …

Slide 142

Slide 142 text

service-worker-installed

Slide 143

Slide 143 text

serviceWorkerInstalled

Slide 144

Slide 144 text

No content

Slide 145

Slide 145 text

my-app.ts import {Component, View, bootstrap, ElementRef} from 'angular2/angular2'; constructor(elementRef: ElementRef) { // Access DOM with elementRef.domElement } Access the DOM for this component

Slide 146

Slide 146 text

my-app.ts // Show toast when Service Worker registration completes var el = elementRef.domElement; var sw = el.querySelector('platinum-sw-register'); var toast = el.querySelector('#caching-complete'); sw.addEventListener('service-worker-installed', function() { toast.show(); });

Slide 147

Slide 147 text

No content

Slide 148

Slide 148 text

No content

Slide 149

Slide 149 text

Recap Wow, that was a lot of stuff

Slide 150

Slide 150 text

Polymer is lean, and production ready

Slide 151

Slide 151 text

Components for nearly any app, out of the box.

Slide 152

Slide 152 text

Components for nearly any app, out of the box. Complete build chain for bringing your app to production.

Slide 153

Slide 153 text

Components for nearly any app, out of the box. Complete build chain for bringing your app to production. Flexible app theming using custom properties

Slide 154

Slide 154 text

Components for nearly any app, out of the box. Complete build chain for bringing your app to production. Flexible app theming using custom properties Responsive app layout boilerplate & routing

Slide 155

Slide 155 text

Components for nearly any app, out of the box. Complete build chain for bringing your app to production. Flexible app theming using custom properties Responsive app layout boilerplate & routing Material Design ready

Slide 156

Slide 156 text

bit.ly/polycasts

Slide 157

Slide 157 text

Polymer Summit September 15, 2015 Amsterdam

Slide 158

Slide 158 text

polymer-project.org Componentize the web!

Slide 159

Slide 159 text

+Rob Dodson @rob_dodson Thank You!