polymer - lego for the web!

33
29 November 2014 th Polymer Lego for the web

Upload: codemotion

Post on 05-Jul-2015

401 views

Category:

Technology


0 download

DESCRIPTION

by Maurizio Mangione - I web components sono un nuovo set di feature della piattaforma web. Polymer ne rende la creazione ancora più facile e permette, tramite polyfill di utilizzarli in tutti i browser moderni fin da ora. In Polymer tutto è un elemento, ha una vita propria e per questo può essere facilmente distribuibile e riutilizzabile.

TRANSCRIPT

Page 1: Polymer - Lego for the web!

 29  November 2014th

PolymerLego for the web

Page 2: Polymer - Lego for the web!

~ whoamiMaurizio Mangione

@granze

Lead FrontendDeveloper

Milano JSFounder

Page 3: Polymer - Lego for the web!

Polymer?

Page 4: Polymer - Lego for the web!

Web components?

Page 5: Polymer - Lego for the web!

Custom Elements

HTML imports

Shadow DOM

Templates

Page 6: Polymer - Lego for the web!

Custom elements

Create new HTML elements

Page 7: Polymer - Lego for the web!

Custom elements

<tabs> <tab>tab 1</tab> <tab>tab 2</tab> <tab>tab 3</tab> </tabs>

Page 8: Polymer - Lego for the web!

HTML imports

Load custom elementdefinitions and resources

Page 9: Polymer - Lego for the web!

HTML imports

<link rel="import" href="custom.html">

Page 10: Polymer - Lego for the web!

Shadow DOM

Scoped CSS + encapsulatedmarkup

Page 11: Polymer - Lego for the web!

Shadow DOM

Page 12: Polymer - Lego for the web!

Templates

Native templating in thebrowser

Page 13: Polymer - Lego for the web!

Templates

<template> <h1>Hey there!</h1>

<img src="xxx.jpg" />

<script> alert('whoooo!'); </script> </template>

Page 14: Polymer - Lego for the web!

Browser support

Page 15: Polymer - Lego for the web!

webcomponents.js

Page 16: Polymer - Lego for the web!

Polymer vs Vanil la

Page 17: Polymer - Lego for the web!
Page 18: Polymer - Lego for the web!
Page 19: Polymer - Lego for the web!
Page 20: Polymer - Lego for the web!

Special   features

Page 21: Polymer - Lego for the web!

Data binding <polymer-element name="user-group"> <template> This is the {{technology} } user group. </template> <script> Polymer('user-group', { ready: function() { this.technology = 'Javascript'; } }); </script> </polymer-element>

Page 22: Polymer - Lego for the web!

Declarative event mapping <polymer-element name="g-cool"> <template> <button on-click="{{buttonClick} }"></button> </template> <script> Polymer({ buttonClick: function(event, detail, sender) { ... } }); </script> </polymer-element>

Page 23: Polymer - Lego for the web!

Extending other elements <polymer-element name="my-label" noscript> <template> <span><content></content></span> </template> </polymer-element>

<polymer-element name="my-superlabel" extends="my-label" noscript> <template> <span> <i>★</i><shadow></shadow> </span> </template> </polymer-element>

<my-label>Hello!</my-label> // Hello!" <my-superlabel>Hello!</my-superlabel> // "★ Hello!"

Page 24: Polymer - Lego for the web!

Observing properties <polymer-element name="g-cool" attributes="better best"> <script> Polymer({ better: '', best: '', betterChanged: function(oldValue, newValue) { ... }, bestChanged: function(oldValue, newValue) { ... } }); </script> </polymer-element>

Page 25: Polymer - Lego for the web!

Tools

Page 26: Polymer - Lego for the web!

Yeoman

npm install ­g generator­polymer

Page 27: Polymer - Lego for the web!

Bower

bower install Polymer/core­ajax

Page 28: Polymer - Lego for the web!

Vulcanize

npm install ­g vulcanize npm install ­D gulp­vulcanize npm install ­D grunt­vulcanize

Page 29: Polymer - Lego for the web!

Useful components

Page 30: Polymer - Lego for the web!

Google web components

Paper elements

Core elements

Page 31: Polymer - Lego for the web!

Do you want more?

Page 32: Polymer - Lego for the web!

Lab Hands­on@

Codemotion11:40 ­ 13:10

Page 33: Polymer - Lego for the web!

Keep in touch!

 @granze

Slides made with Applause http://bit.ly/applause­slides