123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <link href='http://fonts.googleapis.com/css?family=Noto+Sans:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
- <link href='http://fonts.googleapis.com/css?family=Lora:700' rel='stylesheet' type='text/css'>
-
- <template id="card-front">
- <style>
- #card {
- /* Fill the whole area of the shadow root */
- width: 100%;
- height: 100%;
- /* Border */
- border: 2mm solid;
- border-radius: 4px;
- box-sizing: border-box;
- /* Flex display of children */
- position: relative;
- display: flex;
- flex-direction: column;
- /* Font */
- font-family: 'Noto Sans', 'Myriad Pro', Calibri, Helvetica, Arial, sans-serif;
- font-size: 8pt;
- }
-
- #content-container {
- padding:2mm;
- padding-top:1mm;
- border-radius: 2mm;
- margin-top:0px;
- background-color: white;
- border-color: inherit;
- display: flex;
- flex-direction: column;
- flex: 1;
- font-size: inherit;
- }
-
- #icon {
- width: 7mm;
- height: 7mm;
- background-repeat: no-repeat;
- background-size: contain;
- background-color: inherit;
- border-color: inherit;
- }
-
- #icon-container {
- position: absolute;
- right: -1mm;
- top: -1mm;
- border: 1mm solid;
- border-radius: 1mm;
- background-color: inherit;
- border-color: inherit;
- }
-
- </style>
-
- <div id="card">
- <div id="icon-container">
- <div id="icon"></div>
- </div>
-
- <content select="card-title"></content>
-
- <div id="content-container">
- <content select="card-contents"></content>
- </div>
- </div>
-
- </template>
-
- <script>
- (function (window, document) {
- var elemName = 'card-front';
- var mainDoc = document;
- var importDoc = document.currentScript.ownerDocument;
-
- var proto = Object.create(HTMLElement.prototype);
- Object.defineProperty(proto, "color", {
- get: function () {
- return "";
- },
- set: function (value) {
- var root = this.shadowRoot;
- var style = root.getElementById("card").style;
- style.color = value;
- style.backgroundColor = value;
- style.borderColor = value;
- }
- });
- proto.createdCallback = function () {
- var template = importDoc.getElementById(elemName);
- var clone = mainDoc.importNode(template.content, true);
- var root = this.createShadowRoot();
- root.appendChild(clone);
-
- this.color = this.getAttribute('color') || "black";
- }
- proto.attributeChangedCallback = function (name, oldValue, newValue) {
- switch (name) {
- case "color": this.color = newValue;
- }
- }
-
- mainDoc.registerElement(elemName, { prototype: proto });
-
- })(window, document);
- </script>
|