Guest User

Untitled

a guest
Jan 16th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. // Imports from the Polymer framework
  2. import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
  3.  
  4. // Example of usage of Iron/Paper elements library
  5. // This library was created by Google and is a good example of components library
  6. // Details in Parts 7-9: Elements
  7. import '@polymer/iron-icon/iron-icon.js';
  8. import '@polymer/iron-icons/iron-icons.js';
  9.  
  10. // Definition of the element
  11. // The element displays a name with a search icon. Why search? Dunno...
  12. // For example: <my-element name="Element"></my-element>
  13. class MyElement extends PolymerElement {
  14. static get template() {
  15. return html`
  16. /* Styles of my-elements.
  17. They are encapsulated by default
  18. so if spans are used inside the icon, their color stays unaffected
  19. Part 1: Polyfill of Shadow DOM (Shady CSS + Shady DOM) */
  20. <style include="iron-flex">
  21. :host { @apply --layout; }
  22. span { color: blue; }
  23. </style>
  24.  
  25. <!-- The markup of my-element. Please note usage of "[[" and "]]".
  26. Part 3: Polyfill of HTMLTemplateElement -->
  27. <span>Hello, my name is [[name]]! <iron-icon icon="face"></iron-icon></span>
  28. `;
  29. }
  30.  
  31. // Properties to control my-element
  32. // Part 6: Polymer property bindings
  33. static get properties() {
  34. return {
  35. name: {
  36. type: String
  37. }
  38. };
  39. }
  40. }
  41.  
  42. // Custom Elements implementation. Part 2: Polyfill of Custom Elements
  43. customElements.define(MyElement.is, MyElement);
Add Comment
Please, Sign In to add comment