polymer - el fin a tus problemas con el frontend

54
Polymer el fin a tus problemas con el front-end +Israel Blancas @iblancasa #DevFestGRX GDG Granada

Upload: israel-blancas

Post on 20-Mar-2017

111 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Polymer - El fin a tus problemas con el FrontEnd

Polymerel fin a tus problemas con el front-end

+Israel Blancas@iblancasa

#DevFestGRX

GDG Granada

Page 2: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG Granada

Page 3: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG Granada

Page 4: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG Granada

Page 5: Polymer - El fin a tus problemas con el FrontEnd

Web Components are low-level primitives that let you define your own HTML Elements.

#DevFestGRX

GDG Granada

Page 6: Polymer - El fin a tus problemas con el FrontEnd

Template

Shadow DOM

Custom Elements

HTML Imports

native client-side templating

scoping, composition

define new HTML/DOM

loading web components

#DevFestGRX

GDG Granada

Page 7: Polymer - El fin a tus problemas con el FrontEnd

Primitives are designed so we can build libraries on top of them.

#DevFestGRX

GDG Granada

Page 8: Polymer - El fin a tus problemas con el FrontEnd

So what is Polymer?

#DevFestGRX

GDG Granada

Page 9: Polymer - El fin a tus problemas con el FrontEnd

Polymer is nota framework

#DevFestGRX

GDG Granada

Page 10: Polymer - El fin a tus problemas con el FrontEnd

Existing Frameworks

Applications

Web Platform

Web Components built with Polymer (or not)

#DevFestGRX

GDG Granada

Page 11: Polymer - El fin a tus problemas con el FrontEnd

Polymer is nota framework

Sure?

#DevFestGRX

GDG Granada

Page 12: Polymer - El fin a tus problemas con el FrontEnd

Over 3M pages

#DevFestGRX

GDG Granada

Page 13: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG Granada

Page 14: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG Granada

Page 15: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG Granada

Page 16: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG Granada

Page 17: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG Granada

Page 18: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG Granada

Page 19: Polymer - El fin a tus problemas con el FrontEnd

Let’s buildan element!

Image by Gloria Viganò for the Noun Project

#DevFestGRX

GDG Granada

Page 20: Polymer - El fin a tus problemas con el FrontEnd

Hey user! Something awesome happened!

#DevFestGRX

GDG Granada

Page 21: Polymer - El fin a tus problemas con el FrontEnd

xHey user! Something awesome happened!

<alert-banner>

#DevFestGRX

GDG Granada

Page 22: Polymer - El fin a tus problemas con el FrontEnd

alert-banner.html

<dom-module id=“alert-banner"> <template> </template> <script> Polymer({ is: ‘alert-banner' }); </script></dom-module>

<link rel=“import” href=“../polymer/polymer.html”>

#DevFestGRX

GDG Granada

Page 23: Polymer - El fin a tus problemas con el FrontEnd

alert-banner.html

<dom-module id=“alert-banner"> <template> </template> <script> Polymer({ is: ‘alert-banner' }); </script></dom-module>

<link rel=“import” href=“../polymer/polymer.html”>

Import all of yourdependencies

#DevFestGRX

GDG Granada

Page 24: Polymer - El fin a tus problemas con el FrontEnd

alert-banner.html

<dom-module id=“alert-banner"> <template> </template> <script> Polymer({ is: ‘alert-banner' }); </script></dom-module>

<link rel=“import” href=“../polymer/polymer.html”>

A container for yourelement definition

#DevFestGRX

GDG Granada

Page 25: Polymer - El fin a tus problemas con el FrontEnd

alert-banner.html

<dom-module id=“alert-banner"> <template> </template> <script> Polymer({ is: ‘alert-banner' }); </script></dom-module>

Local DOM is the DOMan elements is in charge of creating and managing

<link rel=“import” href=“../polymer/polymer.html”>

#DevFestGRX

GDG Granada

Page 26: Polymer - El fin a tus problemas con el FrontEnd

Shadow DOM

#DevFestGRX

GDG Granada

Page 27: Polymer - El fin a tus problemas con el FrontEnd

Shadow DOM || “Shady DOM”

#DevFestGRX

GDG Granada

Page 28: Polymer - El fin a tus problemas con el FrontEnd

Shadow DOM || “Shady DOM” == Local DOM

#DevFestGRX

GDG Granada

Page 29: Polymer - El fin a tus problemas con el FrontEnd

alert-banner.html

<dom-module id=“alert-banner"> <template> </template> <script> Polymer({ is: ‘alert-banner' }); </script></dom-module>

Local DOM is the DOMan elements is in charge of creating and managing

<link rel=“import” href=“../polymer/polymer.html”>

#DevFestGRX

GDG Granada

Page 30: Polymer - El fin a tus problemas con el FrontEnd

alert-banner.html

<dom-module id=“alert-banner"> <template> <style> .alert { background: blue; color: white; } </style> <div class=“alert”> Hey user! Something awesome happened! </div> </template> <script> Polymer({ is: ‘alert-banner' }); </script></dom-module>

<link rel=“import” href=“../polymer/polymer.html”>Hey user! Something awesome happened! xHey user! Something awesome happened!

#DevFestGRX

GDG Granada

Page 31: Polymer - El fin a tus problemas con el FrontEnd

alert-banner.html

<dom-module id=“alert-banner"> <template> <style> .alert { background: blue; color: white; } </style> <div class=“alert”> Hey user! Something awesome happened! </div> </template> <script> Polymer({ is: ‘alert-banner' }); </script></dom-module>

<link rel=“import” href=“../polymer/polymer.html”>

Define yourprototype

#DevFestGRX

GDG Granada

Page 32: Polymer - El fin a tus problemas con el FrontEnd

<body unresolved> <nav> <header> <ul> <li><a href="#">About us</a></li> <li><a href="#">Make a reservation</a></li> <li><a href="#">Contact</a></li> </ul> </header> </nav> <main> <h1 class="logo">Polymer!</h1> <alert-banner></alert-banner> <section> <article class="top-story"> <img src="headline.jpg"/> <p>Lorem ipsum dolor sit amet…</p> </article> <article class="breaking-news"> <img src="breaking.jpg" alt="Important new images" /> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p> </article> </section> </main></body>

#DevFestGRX

GDG Granada

Page 33: Polymer - El fin a tus problemas con el FrontEnd

Hey user! Something awesome happened!

#DevFestGRX

GDG Granada

Page 34: Polymer - El fin a tus problemas con el FrontEnd

alert-banner.html

<dom-module id=“alert-banner"> <template> <style> .alert { background: blue; color: white; } </style> <div class=“alert”> Hey user! Something awesome happened! </div> </template> <script> Polymer({ is: ‘alert-banner' }); </script></dom-module>

<link rel=“import” href=“../polymer/polymer.html”>

Replace hard-coded data

#DevFestGRX

GDG Granada

Page 35: Polymer - El fin a tus problemas con el FrontEnd

alert-banner.html

<dom-module id=“alert-banner"> <template> <style> .alert { background: blue; color: white; } </style> <div class=“alert”> <content select=“.message”></content> </div> </template> <script> Polymer({ is: ‘alert-banner' }); </script></dom-module>

<link rel=“import” href=“../polymer/polymer.html”>

With content elements!

#DevFestGRX

GDG Granada

Page 36: Polymer - El fin a tus problemas con el FrontEnd

Light DOM - The world outsideyour component’s Local DOM

#DevFestGRX

GDG Granada

Page 37: Polymer - El fin a tus problemas con el FrontEnd

alert-banner.html

<dom-module id=“alert-banner"> <template> <style> .alert { background: blue; color: white; } </style> <div class=“alert”> <content select=“.message”></content> </div> </template> <script> Polymer({ is: ‘alert-banner' }); </script></dom-module>

<link rel=“import” href=“../polymer/polymer.html”>

Select content withCSS selectors

#DevFestGRX

GDG Granada

Page 38: Polymer - El fin a tus problemas con el FrontEnd

<body unresolved> <nav> <header> <ul> <li><a href="#">About us</a></li> <li><a href="#">Make a reservation</a></li> <li><a href="#">Contact</a></li> </ul> </header> </nav> <main> <h1 class="logo">Polymer!</h1> <alert-banner></alert-banner> <section> <article class="top-story"> <img src="headline.jpg"/> <p>Lorem ipsum dolor sit amet…</p> </article> <article class="breaking-news"> <img src="breaking.jpg" alt="Important new images" /> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p> </article> </section> </main></body>

#DevFestGRX

GDG Granada

Page 39: Polymer - El fin a tus problemas con el FrontEnd

<body unresolved> <nav> <header> <ul> <li><a href="#">About us</a></li> <li><a href="#">Make a reservation</a></li> <li><a href="#">Contact</a></li> </ul> </header> </nav> <main> <h1 class="logo">Polymer!</h1> <alert-banner> <span class=“message”> Success! Your first component! </span> </alert-banner> <section> <article class="top-story"> <img src="headline.jpg"/> <p>Lorem ipsum dolor sit amet…</p> </article> <article class="breaking-news"> <img src="breaking.jpg" alt="Important new images" /> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p> </article> </section> </main></body>

#DevFestGRX

GDG Granada

Page 40: Polymer - El fin a tus problemas con el FrontEnd

<body unresolved> <nav> <header> <ul> <li><a href="#">About us</a></li> <li><a href="#">Make a reservation</a></li> <li><a href="#">Contact</a></li> </ul> </header> </nav> <main> <h1 class="logo">Polymer!</h1> <alert-banner> <span class=“message”> Success! Your first component! </span> </alert-banner> <section> <article class="top-story"> <img src="headline.jpg"/> <p>Lorem ipsum dolor sit amet…</p> </article> <article class="breaking-news"> <img src="breaking.jpg" alt="Important new images" /> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p> </article> </section> </main></body>

Matching class

#DevFestGRX

GDG Granada

Page 41: Polymer - El fin a tus problemas con el FrontEnd

Success! Your first component!

#DevFestGRX

GDG Granada

Page 42: Polymer - El fin a tus problemas con el FrontEnd

ElementsBuilding blocks for a better web

#DevFestGRX

GDG Granada

Page 43: Polymer - El fin a tus problemas con el FrontEnd

There’s an element for that!

Page 44: Polymer - El fin a tus problemas con el FrontEnd

https://beta.webcomponents.org/collection/Polymer/elements

#DevFestGRX

GDG Granada

Page 45: Polymer - El fin a tus problemas con el FrontEnd

ApplicationsCombining elements into something great

#DevFestGRX

GDG Granada

Page 46: Polymer - El fin a tus problemas con el FrontEnd

Create or reuse elements in any app

#DevFestGRX

GDG Granada

Page 47: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG Granada

Page 48: Polymer - El fin a tus problemas con el FrontEnd

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

#DevFestGRX

GDG Granada

Page 49: Polymer - El fin a tus problemas con el FrontEnd

Production-ising Apps

#DevFestGRX

GDG Granada

Page 50: Polymer - El fin a tus problemas con el FrontEnd

Build process out of the box#DevFestGRX

GDG Granada

Page 51: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG Granada

Page 52: Polymer - El fin a tus problemas con el FrontEnd

#DevFestGRX

GDG GranadaGDG Granada

Page 53: Polymer - El fin a tus problemas con el FrontEnd

polymer-project.org

#DevFestGRX

GDG Granada

Page 54: Polymer - El fin a tus problemas con el FrontEnd

Muchas gracias¿Preguntas?

+Israel Blancas@iblancasa

#DevFestGRX

GDG Granada