Brak opisu
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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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:first-child {
  21. margin-top: -2px;
  22. margin-bottom: 4px;
  23. }
  24. ::content > card-title:last-child {
  25. margin-top: 4px;
  26. margin-bottom: -2px;
  27. }
  28. </style>
  29. <style type='text/css' id="color-style">
  30. :host {
  31. color: blue;
  32. background-color: blue;
  33. border-color: blue;
  34. }
  35. ::content card-rule /deep/ svg {
  36. fill: blue;
  37. }
  38. </style>
  39. <content></content>
  40. </template>
  41. <script>
  42. (function (window, document) {
  43. var elemName = 'card-front';
  44. var mainDoc = document;
  45. var importDoc = document.currentScript.ownerDocument;
  46. var proto = Object.create(HTMLElement.prototype);
  47. Object.defineProperty(proto, "color", {
  48. get: function () {
  49. return "";
  50. },
  51. set: function (value) {
  52. var root = this.shadowRoot;
  53. var style = root.getElementById("color-style");
  54. style.innerHTML = "\
  55. :host {\
  56. color: "+value+";\
  57. background-color: " + value + ";\
  58. border-color: " + value + ";\
  59. }\
  60. ::content card-rule /deep/ svg {\
  61. fill: " + value + ";\
  62. }\
  63. ::content card-boxes /deep/ svg rect {\
  64. stroke: " + value + ";\
  65. }\
  66. ";
  67. }
  68. });
  69. proto.createdCallback = function () {
  70. var template = importDoc.getElementById(elemName);
  71. var clone = mainDoc.importNode(template.content, true);
  72. var root = this.createShadowRoot();
  73. root.appendChild(clone);
  74. this.color = this.getAttribute('color') || "black";
  75. }
  76. proto.attributeChangedCallback = function (name, oldValue, newValue) {
  77. switch (name) {
  78. case "color": this.color = newValue; break;
  79. }
  80. }
  81. mainDoc.registerElement(elemName, { prototype: proto });
  82. })(window, document);
  83. </script>