crobi 10 gadus atpakaļ
vecāks
revīzija
5816be2e7f

+ 131
- 0
generator/components/card-boxes.html Parādīt failu

@@ -0,0 +1,131 @@
1
+<template id="card-box">
2
+    <style>
3
+        :host {
4
+            display: inline-block;
5
+            vertical-align: top;
6
+        }
7
+        .box {
8
+            width: 100%;
9
+            height: 100%;
10
+            border: 2px solid;
11
+            box-sizing: border-box;
12
+            vertical-align: middle;
13
+            text-align: center;
14
+            display: flex;
15
+            justify-content: center;
16
+            align-content: center;
17
+            flex-direction: column;
18
+        }
19
+        #box2 {
20
+            display: flex;
21
+            justify-content: center;
22
+            align-content: center;
23
+            flex-direction: row;
24
+        }
25
+        
26
+    </style>
27
+    <div class="box">
28
+        <div id="box2">
29
+            <content></content>
30
+        </div>
31
+    </div>
32
+</template>
33
+
34
+<template id="card-boxes">
35
+    <style>
36
+        :host {
37
+            width: 100%;
38
+            vertical-align: top;
39
+        }
40
+        ::content card-box + card-box {
41
+            padding-left: 2px;
42
+        }
43
+    </style>
44
+
45
+    <style id="box-size">
46
+        ::content card-box {
47
+            width:2.5em;
48
+            height:2.5em;
49
+        }
50
+    </style>
51
+
52
+    <content></content>
53
+
54
+</template>
55
+
56
+<script>
57
+    (function (window, document) {
58
+        var elemName = 'card-box';
59
+        var mainDoc = document;
60
+        var importDoc = document.currentScript.ownerDocument;
61
+
62
+        var proto = Object.create(HTMLElement.prototype);
63
+        proto.createdCallback = function () {
64
+            var template = importDoc.getElementById(elemName);
65
+            var clone = mainDoc.importNode(template.content, true);
66
+            var root = this.createShadowRoot();
67
+            root.appendChild(clone);
68
+        }
69
+
70
+        mainDoc.registerElement(elemName, { prototype: proto });
71
+
72
+    })(window, document);
73
+
74
+    (function(window, document) {
75
+        var elemName = 'card-boxes';
76
+        var mainDoc = document;
77
+        var importDoc = document.currentScript.ownerDocument;
78
+
79
+        function createBoxes(element, count) {
80
+            while (element.firstChild) {
81
+                element.removeChild(element.firstChild);
82
+            }
83
+            for (var i = 0; i < count; ++i) {
84
+                element.appendChild(document.createElement("card-box"));
85
+            }
86
+        }
87
+
88
+        var proto = Object.create(HTMLElement.prototype);
89
+        Object.defineProperty(proto, "size", {
90
+            get: function () {
91
+                return "";
92
+            },
93
+            set: function (value) {
94
+                var root = this.shadowRoot;
95
+                var style = root.getElementById("box-size");
96
+                style.innerHTML = "\
97
+                ::content card-box {\
98
+                    width:" + value + "em;\
99
+                    height:" + value + "em;\
100
+                }\
101
+                ";
102
+            }
103
+        });
104
+        Object.defineProperty(proto, "count", {
105
+            get: function () {
106
+                return "";
107
+            },
108
+            set: function (value) {
109
+                createBoxes(this, value);
110
+            }
111
+        });
112
+        proto.createdCallback = function () {
113
+            var template = importDoc.getElementById(elemName);
114
+            var clone = mainDoc.importNode(template.content, true);
115
+            var root = this.createShadowRoot();
116
+            root.appendChild(clone);
117
+
118
+            this.size = this.getAttribute('size') || "1";
119
+            this.count = this.getAttribute('count') || "1";
120
+        }
121
+        proto.attributeChangedCallback = function (name, oldValue, newValue) {
122
+            switch (name) {
123
+                case "size": this.size = newValue; break;
124
+                case "count": this.count = newValue; break;
125
+            }
126
+        }
127
+
128
+        mainDoc.registerElement(elemName, { prototype: proto });
129
+
130
+    })(window, document);
131
+</script>

+ 1
- 1
generator/components/card-fill.html Parādīt failu

@@ -34,7 +34,7 @@
34 34
         }
35 35
         proto.attributeChangedCallback = function (name, oldValue, newValue) {
36 36
             switch (name) {
37
-                case "size": this.size = newValue;
37
+                case "size": this.size = newValue; break;
38 38
             }
39 39
         }
40 40
 

+ 4
- 1
generator/components/card-front.html Parādīt failu

@@ -70,6 +70,9 @@
70 70
                 ::content card-rule /deep/ svg {\
71 71
                     fill: " + value + ";\
72 72
                 }\
73
+                ::content card-boxes /deep/ svg rect {\
74
+                    stroke: " + value + ";\
75
+                }\
73 76
                 ";
74 77
             }
75 78
         });
@@ -83,7 +86,7 @@
83 86
         }
84 87
         proto.attributeChangedCallback = function (name, oldValue, newValue) {
85 88
             switch (name) {
86
-                case "color": this.color = newValue;
89
+                case "color": this.color = newValue; break;
87 90
             }
88 91
         }
89 92
 

+ 1
- 1
generator/components/card-icon.html Parādīt failu

@@ -82,7 +82,7 @@
82 82
         }
83 83
         proto.attributeChangedCallback = function (name, oldValue, newValue) {
84 84
             switch (name) {
85
-                case "src": this.src = newValue;
85
+                case "src": this.src = newValue; break;
86 86
             }
87 87
         }
88 88
 

+ 1
- 1
generator/components/card-title.html Parādīt failu

@@ -71,7 +71,7 @@
71 71
         }
72 72
         proto.attributeChangedCallback = function (name, oldValue, newValue) {
73 73
             switch (name) {
74
-                case "size": this.size = newValue;
74
+                case "size": this.size = newValue; break;
75 75
             }
76 76
         }
77 77
 

Notiek ielāde…
Atcelt
Saglabāt