Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

card-front.html 2.6KB

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