Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Desbravando Web Components

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Desbravando Web Components

Descubra como esse conceito formado por cinco novas especificações (Templates, Decorators, Shadow DOM, Custom Elements, Imports) irá revolucionar o modo como desenvolvemos e interagimos na web.

Avatar for Mateus Ortiz

Mateus Ortiz

June 22, 2015
Tweet

More Decks by Mateus Ortiz

Other Decks in Programming

Transcript

  1. var Proto = Object.create(HTMLElement.prototype); Proto.createdCallback = function() { this.textContent =

    "RuPy Campinas"; }; document.registerElement('rupy-city', { prototype: Proto }); <rupy-city></rupy-city>
  2. <dom-module id="rupy-city"> <template> <h1>Rupy <strong>{{onde}}</strong></h1> </template> <script> Polymer({ is: 'rupy-city',

    properties: { onde: { type: String, value: 'Campinas' } } }); </script> </dom-module>
  3. XMega = Polymer({ is: 'x-mega', extends: 'button', created: function() {

    this.style.border = '1px solid red'; } }); var el1 = new XMega(); console.log(el1 instanceof HTMLButtonElement); // true var el2 = document.createElement('button', 'x-mega'); console.log(el2 instanceof HTMLButtonElement); // true <button is="x-mega"></button>
  4.                    

             Templates     são  pedaços                                inertes  de  DOM     que  podem  ser                            reu)lizados.  
  5. t                  

                   O  Shadow  DOM   encapsula  style  e     marcação.  
  6. exemplo <link rel="import" href="bower_components/core-menu/ core-menu.html"> <link rel="import" href="bower_components/paper-item/ paper-item.html"> <link

    rel="import" href="bower_components/paper-item/ paper-item.html"> <link rel="import" href="bower_components/core-pages/ core-pages.html"> <link rel="import" href="elements.html"> elements.html
  7. Visual <core-­‐toolbar>   <core-­‐header-­‐panel>   <core-­‐drawer-­‐panel>   <core-­‐menu>   <core-­‐icon>

      <core-­‐overlay>   .... não  Visual <core-­‐ajax>   <core-­‐localstorage>   <core-­‐range>   <core-­‐shared-­‐lib>   <core-­‐media-­‐query>   <core-­‐iconset>   ....
  8. Quem             está    

                          Usando
  9. <dom-module id="list-users"> <template> <template is="dom-repeat" items="{{users}}"> <div>First name: <span>{{item.first}}</span></div> <div>Last

    name: <span>{{item.last}}</span></div> </template> </template> <script> Polymer({ is: 'list-users', ready: function() { this.users: [ {first: 'Bob', last: 'Smith'}, ... ]; } }); </script> </dom-module> polymer
  10. <dom-module id="profile-card"> <template> <link rel="import" type="css" href="styles.css"> <h2>I'm a profile-card</h2>

    </template> <script> Polymer({ is: 'profile-card' }); </script> </dom-module> polymer
  11. Time Mateus   Or<z Addy   Osmani Rob   Dodson

    Erik   Isaksen Ciro   Nunes