Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

card-front.html 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <link href='http://fonts.googleapis.com/css?family=Noto+Sans:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
  2. <template id="card-front">
  3. <style type='text/css'>
  4. :host {
  5. /* Fill the whole area of the shadow root */
  6. width: 100%;
  7. height: 100%;
  8. /* Border */
  9. padding: 6px;
  10. border-radius: 4px;
  11. box-sizing: border-box;
  12. /* Flex display of children */
  13. position: relative;
  14. display: flex;
  15. flex-direction: column;
  16. /* Font */
  17. font-family: 'Noto Sans', 'Myriad Pro', Calibri, Helvetica, Arial, sans-serif;
  18. font-size: 8pt;
  19. }
  20. ::content > card-title {
  21. margin-top: -3px;
  22. margin-bottom: 3px;
  23. }
  24. </style>
  25. <style type='text/css' id="color-style">
  26. :host {
  27. color: blue;
  28. background-color: blue;
  29. border-color: blue;
  30. }
  31. ::content card-rule /deep/ svg {
  32. fill: blue;
  33. }
  34. </style>
  35. <content></content>
  36. </template>
  37. <script>
  38. (function (window, document) {
  39. var elemName = 'card-front';
  40. var mainDoc = document;
  41. var importDoc = document.currentScript.ownerDocument;
  42. var proto = Object.create(HTMLElement.prototype);
  43. Object.defineProperty(proto, "color", {
  44. get: function () {
  45. return "";
  46. },
  47. set: function (value) {
  48. var root = this.shadowRoot;
  49. var style = root.getElementById("color-style");
  50. style.innerHTML = "\
  51. :host {\
  52. color: "+value+";\
  53. background-color: " + value + ";\
  54. border-color: " + value + ";\
  55. }\
  56. ::content card-rule /deep/ svg {\
  57. fill: " + value + ";\
  58. }\
  59. ";
  60. }
  61. });
  62. proto.createdCallback = function () {
  63. var template = importDoc.getElementById(elemName);
  64. var clone = mainDoc.importNode(template.content, true);
  65. var root = this.createShadowRoot();
  66. root.appendChild(clone);
  67. this.color = this.getAttribute('color') || "black";
  68. }
  69. proto.attributeChangedCallback = function (name, oldValue, newValue) {
  70. switch (name) {
  71. case "color": this.color = newValue;
  72. }
  73. }
  74. mainDoc.registerElement(elemName, { prototype: proto });
  75. })(window, document);
  76. </script>