暫無描述
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 3.1KB

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