49
Polymer Sami Suo-Heikki Turku <3 Frontend 2016-02-24

How to build a web application with Polymer

Embed Size (px)

Citation preview

Page 1: How to build a web application with Polymer

PolymerSami Suo-HeikkiTurku <3 Frontend2016-02-24

Page 2: How to build a web application with Polymer

What is Polymer?

Page 3: How to build a web application with Polymer

Polymer is a library utilizing web components for building elements and applications

Page 4: How to build a web application with Polymer

So what Polymer really is?

Page 5: How to build a web application with Polymer

Polymer

Polymer uses web components

Polymer isn’t a framework

With Polymer DOM is the frameworkScoping provided by Shadow DOM

Page 6: How to build a web application with Polymer

Polymer

Polymer works well with JS frameworks

With Polymer you can build your own elements and apps

Polymer is created by Google

“Using HTML with web components is a revolution how we do front-end development”

Page 7: How to build a web application with Polymer

Components all the way down

Page 8: How to build a web application with Polymer

Everything is an element

Page 9: How to build a web application with Polymer
Page 10: How to build a web application with Polymer

Today’s topic

Page 11: How to build a web application with Polymer

Development Design Deploy

Page 12: How to build a web application with Polymer

Development

Page 13: How to build a web application with Polymer

<video src="identio_startup_journey.mp4" controls></video>

Page 14: How to build a web application with Polymer

<video src="identio_startup_journey.mp4" controls></video>

Page 15: How to build a web application with Polymer

<video src="identio_startup_journey.mp4" controls></video>

Page 16: How to build a web application with Polymer

Polymer is easy - index.html

<head> <title>Polymer is easy</title> <script src=”webcomponents-lite.min.js”></script> <link rel=”import” href=”polymer.html”> <link rel=”import” href=”my-element.html”></head><body> <my-element myname=”Turku”></my-element></body>

Page 17: How to build a web application with Polymer

Polymer is easy - index.html

<head> <title>Polymer is easy</title> <script src=”webcomponents-lite.min.js”></script> <link rel=”import” href=”polymer.html”> <link rel=”import” href=”my-element.html”></head><body> <my-element myname=”Turku”></my-element></body>

Page 18: How to build a web application with Polymer

Polymer is easy - index.html

<head> <title>Polymer is easy</title> <script src=”webcomponents-lite.min.js”></script> <link rel=”import” href=”polymer.html”> <link rel=”import” href=”my-element.html”></head><body> <my-element myname=”Turku”></my-element></body>

Page 19: How to build a web application with Polymer

Polymer is easy - index.html

<head> <title>Polymer is easy</title> <script src=”webcomponents-lite.min.js”></script> <link rel=”import” href=”polymer.html”> <link rel=”import” href=”my-element.html”></head><body> <my-element myname=”Turku”></my-element></body>

Page 20: How to build a web application with Polymer

Polymer is easy - index.html

<head> <title>Polymer is easy</title> <script src=”webcomponents-lite.min.js”></script> <link rel=”import” href=”polymer.html”> <link rel=”import” href=”my-element.html”></head><body> <my-element myname=”Turku”></my-element></body>

Page 21: How to build a web application with Polymer

Polymer is easy - my-element.html

<dom-module id="my-element"> <template> <input value="{{myname::input}}"><br/> <span>Hello {{myname}}!</span> </template> <script> Polymer({ is: 'my-element', properties: { myname: String } }); </script></dom-module>

Page 22: How to build a web application with Polymer

Polymer is easy - my-element.html

<dom-module id="my-element"> <template> <input value="{{myname::input}}"><br/> <span>Hello {{myname}}!</span> </template> <script> Polymer({ is: 'my-element', properties: { myname: String } }); </script></dom-module>

Page 23: How to build a web application with Polymer

Polymer is easy - my-element.html

<dom-module id="my-element"> <template> <input value="{{myname::input}}"><br/> <span>Hello {{myname}}!</span> </template> <script> Polymer({ is: 'my-element', properties: { myname: String } }); </script></dom-module>

Page 24: How to build a web application with Polymer

Polymer is easy - my-element.html

<dom-module id="my-element"> <template> <input value="{{myname::input}}"><br/> <span>Hello {{myname}}!</span> </template> <script> Polymer({ is: 'my-element', properties: { myname: String } }); </script></dom-module>

Page 25: How to build a web application with Polymer

Output

Page 26: How to build a web application with Polymer

Design

Page 27: How to build a web application with Polymer

Polymer is easy - my-element.html

<dom-module id="my-element"> <template> <style> /* Add style here */ </style> <input value="{{myname::input}}"><br/> <span>Hello {{myname}}!</span> </template> ...</dom-module>

Page 28: How to build a web application with Polymer
Page 29: How to build a web application with Polymer
Page 30: How to build a web application with Polymer

Polymer Paper Elements

Page 31: How to build a web application with Polymer

Polymer Paper Elements

Page 32: How to build a web application with Polymer

Polymer Paper Elements

Page 33: How to build a web application with Polymer

Polymer Paper Elements

Page 34: How to build a web application with Polymer

Polymer Paper Elements

Page 35: How to build a web application with Polymer

Polymer is easy - my-element.html (OLD)

<dom-module id="my-element"> <template> <input value="{{myname::input}}"><br/> <span>Hello {{myname}}!</span> </template> ...</dom-module>

Page 36: How to build a web application with Polymer

Polymer is easy - my-element.html (NEW)

<link rel="import" href="paper-input.html"><link rel="import" href="paper-card.html"><dom-module id="my-element"> <template> <paper-input label="Your name" value="{{myname::input}}"></paper-input> <paper-card heading="Hello {{myname}}!"></paper-card> </template> ...</dom-module>

Page 37: How to build a web application with Polymer

Polymer is easy - my-element.html (NEW)

<link rel="import" href="paper-input.html"><link rel="import" href="paper-card.html"><dom-module id="my-element"> <template> <paper-input label="Your name" value="{{myname::input}}"></paper-input> <paper-card heading="Hello {{myname}}!"></paper-card> </template> ...</dom-module>

Page 38: How to build a web application with Polymer

Polymer is easy - my-element.html (NEW)

<link rel="import" href="paper-input.html"><link rel="import" href="paper-card.html"><dom-module id="my-element"> <template> <paper-input label="Your name" value="{{myname::input}}"></paper-input> <paper-card heading="Hello {{myname}}!"></paper-card> </template> ...</dom-module>

Page 39: How to build a web application with Polymer

Output

Page 40: How to build a web application with Polymer

Deploy

Page 41: How to build a web application with Polymer

Database User authentication Hosting

Page 42: How to build a web application with Polymer
Page 43: How to build a web application with Polymer

Realtime Database

ref.on(‘value’, function(snapshot) { console.log(snapshot.val());});

<firebase-collection data={{myData}} location=”https://turkupolymer.firebaseio.com”></firebase-collection>

Page 44: How to build a web application with Polymer

User authenticatio

nref.authWithOAuthPopup(‘google’, function(error, authData) { console.log(authData.uid);});

<firebase-auth provider=”google” location=”https://turkupolymer.firebaseio.com”></firebase-auth>

Page 45: How to build a web application with Polymer

Hosting

$ npm install -g firebase-tools$ cd “Polymer is easy”

$ firebase init

$ firebase deploy

https://turkupolymer.firebaseapp.com/

Page 46: How to build a web application with Polymer
Page 47: How to build a web application with Polymer

Getting started

This project: https://github.com/samiheikki/turkupolymer

Polymer: https://www.polymer-project.org

Polymer Elements: https://elements.polymer-project.org/

Polymer Starter Kit: https://developers.google.com/web/tools/polymer-starter-kit/

Page 48: How to build a web application with Polymer

Advanced

High class components: https://vaadin.com/elements

Even more components: https://customelements.io

Page 49: How to build a web application with Polymer

Thank You!

Sami Suo-Heikki @samisuoheikkigithub.com/samiheikki