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

Using Polymer, today

Frontend NE
October 01, 2015

Using Polymer, today

How web-components, through Polymer can provide a true separation of concerns when building a pattern library

Frontend NE

October 01, 2015
Tweet

More Decks by Frontend NE

Other Decks in Technology

Transcript

  1. <ul> <li class="field__location"> <span class="field__location__name">Location</span> <div class="field__location__map"> <div class="location__loading-indicator"> <svg

    viewbox="0 0 100 100" class="icon icon__logoma <use xlink:href="/resources/images/sprite/icon- </svg> </div> </div> <div class="field__location__search"> <input type="search" value="" placeholder="Enter a post </div> <ul class="form-fields grid"> <li class="column column__6-of-12"> <label for="lat">Latitude</label> <input type="text" pattern="-?[0-9]{0,2}\.?[0-9]*" </li> <li class="column column__6-of-12"> <label for="lon">Longitude</label> <input type="text" pattern="-?[0-9]{0,3}\.?[0-9]*" </li> </ul> </li>
  2. <ul> <li class="field__location"> <span class="field__location__name">Location</span> <div class="field__location__map"> <div class="location__loading-indicator"> <svg

    viewbox="0 0 100 100" class="icon icon__logoma <use xlink:href="/resources/images/sprite/icon- </svg> </div> </div> <div class="field__location__search"> <input type="search" value="" placeholder="Enter a post </div> <ul class="form-fields grid"> <li class="column column__6-of-12"> <label for="lat">Latitude</label> <input type="text" pattern="-?[0-9]{0,2}\.?[0-9]*" </li> <li class="column column__6-of-12"> <label for="lon">Longitude</label> <input type="text" pattern="-?[0-9]{0,3}\.?[0-9]*" </li> </ul> </li>
  3. <div class="pagination"> <a href="#" class="button button--disabled pagination__paddle" <input class="pagination__page" type="text"

    inputmode="number" <span class="pagination__limit">52</span> <a href="#" class="button pagination__paddle">Next ></a> </div> Pagination Pagination Component Component
  4. "Web Components are a set of standards currently being produced

    by Google engineers as a W3C specification that allow for the creation of reusable widgets or components in web documents and web applications. The intention behind them is to bring component-based software engineering to the World Wide Web. The components model allows for encapsulation and interoperability of individual HTML elements."
  5. <div class="pagination"> <a href="#" class="button button--disabled pagination__paddle" <input class="pagination__page" type="text"

    inputmode="number" <span class="pagination__limit">52</span> <a href="#" class="button pagination__paddle">Next ></a> </div> Pagination Pagination Component Component
  6. <link rel="import" href=".../polymer.html"> <dom-module id="my-pagination"> <template> <!-- Element markup goes

    here --> </template> <script> Polymer({ is: 'my-pagination' }); </script> </dom-module> Scripts Scripts
  7. <dom-module id="my-pagination"> <template> <!-- Element markup goes here --> </template>

    <script> Polymer({ is: 'my-pagination', properties: { currentPage: {}, totalPages: {} } }); </script> </dom-module> Element Attributes Element Attributes
  8. <template> <div class="pagination"> <a class="pagination__paddle">Prev</a> <input class="pagination__page" type="text" max="52" value="1">

    <span class="pagination__limit">52</span> <a href="#" class="pagination__paddle">Next</a> </div> </template> Static HTML Static HTML
  9. <link rel="stylesheet" href="my-pagination.css"> <template> <div class="pagination"> <a class="pagination__paddle">Prev</a> <input class="pagination__page"

    type="text" max="52" value="1"> <span class="pagination__limit">52</span> <a href="#" class="pagination__paddle">Next</a> </div> </template> Styles Styles
  10. <link rel="stylesheet" href="my-pagination.css"> <template> <div class="pagination"> <a class="pagination__paddle">Prev</a> <input class="pagination__page"

    type="text" max="{{ totalpages }}" value="{{ currentpage ::input }}"> <span class="pagination__limit">{{ totalpages }}</span> <a href="#" class="pagination__paddle">Next</a> </div> </template> Attribute injection Attribute injection
  11. <ul> <li class="field__location"> <span class="field__location__name">Location</span> <div class="field__location__map"> <div class="location__loading-indicator"> <svg

    viewbox="0 0 100 100" class="icon icon__logoma <use xlink:href="/resources/images/sprite/icon- </svg> </div> </div> <div class="field__location__search"> <input type="search" value="" placeholder="Enter a post </div> <ul class="form-fields grid"> <li class="column column__6-of-12"> <label for="lat">Latitude</label> <input type="text" pattern="-?[0-9]{0,2}\.?[0-9]*" </li> <li class="column column__6-of-12"> <label for="lon">Longitude</label> <input type="text" pattern="-?[0-9]{0,3}\.?[0-9]*" </li> </ul> </li>
  12. <ul> <li class="field__location"> <span class="field__location__name">Location</span> <div class="field__location__map"> <div class="location__loading-indicator"> <svg

    viewbox="0 0 100 100" class="icon icon__logoma <use xlink:href="/resources/images/sprite/icon- </svg> </div> </div> <div class="field__location__search"> <input type="search" value="" placeholder="Enter a post </div> <ul class="form-fields grid"> <li class="column column__6-of-12"> <label for="lat">Latitude</label> <input type="text" pattern="-?[0-9]{0,2}\.?[0-9]*" </li> <li class="column column__6-of-12"> <label for="lon">Longitude</label> <input type="text" pattern="-?[0-9]{0,3}\.?[0-9]*" </li> </ul> </li>