설명 없음
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.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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>
  6. #card {
  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. <div id="card">
  28. <content></content>
  29. </div>
  30. </template>
  31. <script>
  32. (function (window, document) {
  33. var elemName = 'card-front';
  34. var mainDoc = document;
  35. var importDoc = document.currentScript.ownerDocument;
  36. var proto = Object.create(HTMLElement.prototype);
  37. Object.defineProperty(proto, "color", {
  38. get: function () {
  39. return "";
  40. },
  41. set: function (value) {
  42. var root = this.shadowRoot;
  43. var style = root.getElementById("card").style;
  44. style.color = value;
  45. style.backgroundColor = value;
  46. style.borderColor = value;
  47. }
  48. });
  49. proto.createdCallback = function () {
  50. var template = importDoc.getElementById(elemName);
  51. var clone = mainDoc.importNode(template.content, true);
  52. var root = this.createShadowRoot();
  53. root.appendChild(clone);
  54. this.color = this.getAttribute('color') || "black";
  55. }
  56. proto.attributeChangedCallback = function (name, oldValue, newValue) {
  57. switch (name) {
  58. case "color": this.color = newValue;
  59. }
  60. }
  61. mainDoc.registerElement(elemName, { prototype: proto });
  62. })(window, document);
  63. </script>