Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. class CoolCard extends HTMLElement {
  2. constructor() {
  3. // MUST to allow HTMLElement interface to set
  4. // itself up so we can take advantage of it
  5. super();
  6. }
  7.  
  8. connectedCallback() {
  9. // Every time a cool-card gets inserted into a
  10. // document this asynchronous callback gets called
  11. const shadow = this.attachShadow({mode: 'open'});
  12.  
  13. shadow.innerHTML = `
  14. <style>
  15. div.card {
  16. width: 100%;
  17. max-width: 300px;
  18. display: inline-block;
  19. box-shadow: 0px 1px 3px rgba(0, 0, 0, .6);
  20. margin: 10px;
  21. padding: 10px;
  22. background: white;
  23. }
  24. </style>
  25.  
  26. <div class="card">
  27. <h2>CoolCard Title</h2>
  28. </div>
  29. `;
  30. }
  31. }
  32.  
  33. // Tell the browser about our 'cool-card' custom element
  34. customElements.define('cool-card', CoolCard);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement