nodality 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animator.cjs.js +1 -0
- package/dist/animator.esm.js +1 -0
- package/dist/audionew.cjs.js +1 -0
- package/dist/audionew.esm.js +1 -0
- package/dist/base.cjs.js +1 -0
- package/dist/base.esm.js +1 -0
- package/dist/betaDesktopBar.esm.js +1 -0
- package/dist/betaMobileBar.esm.js +1 -0
- package/dist/bundle.umd.js +1 -0
- package/dist/button.cjs.js +1 -0
- package/dist/button.esm.js +1 -0
- package/dist/cardGetter.cjs.js +1 -0
- package/dist/cardGetter.esm.js +1 -0
- package/dist/center.cjs.js +1 -0
- package/dist/center.esm.js +1 -0
- package/dist/checkbox.cjs.js +1 -0
- package/dist/checkbox.esm.js +1 -0
- package/dist/code.cjs.js +1 -0
- package/dist/code.esm.js +1 -0
- package/dist/container.cjs.js +1 -0
- package/dist/container.esm.js +1 -0
- package/dist/datalist.cjs.js +1 -0
- package/dist/datalist.esm.js +1 -0
- package/dist/designer.cjs.js +1 -0
- package/dist/designer.esm.js +1 -0
- package/dist/dropdown.cjs.js +1 -0
- package/dist/dropdown.esm.js +1 -0
- package/dist/elementMapper.cjs.js +1 -0
- package/dist/elementMapper.esm.js +1 -0
- package/dist/finalresult.esm.js +1 -0
- package/dist/flexCard.cjs.js +1 -0
- package/dist/flexCard.esm.js +1 -0
- package/dist/flexGrid.cjs.js +1 -0
- package/dist/flexGrid.esm.js +1 -0
- package/dist/flexRow.cjs.js +1 -0
- package/dist/flexRow.esm.js +1 -0
- package/dist/floatingInput.cjs.js +1 -0
- package/dist/floatingInput.esm.js +1 -0
- package/dist/free.cjs.js +1 -0
- package/dist/free.esm.js +1 -0
- package/dist/horizontalScroller.esm.js +1 -0
- package/dist/image.cjs.js +1 -0
- package/dist/image.esm.js +1 -0
- package/dist/imagePicker.cjs.js +1 -0
- package/dist/imagePicker.esm.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.esm.js +1 -0
- package/dist/link.cjs.js +1 -0
- package/dist/link.esm.js +1 -0
- package/dist/linkGetter.cjs.js +1 -0
- package/dist/linkGetter.esm.js +1 -0
- package/dist/metaAdder.cjs.js +1 -0
- package/dist/metaAdder.esm.js +1 -0
- package/dist/modal2025.cjs.js +1 -0
- package/dist/modal2025.esm.js +1 -0
- package/dist/multiswitchers.esm.js +1 -0
- package/dist/newNavBar.cjs.js +1 -0
- package/dist/newNavBar.esm.js +1 -0
- package/dist/picker.cjs.js +1 -0
- package/dist/picker.esm.js +1 -0
- package/dist/progress.cjs.js +1 -0
- package/dist/progress.esm.js +1 -0
- package/dist/radio.cjs.js +1 -0
- package/dist/radio.esm.js +1 -0
- package/dist/range.cjs.js +1 -0
- package/dist/range.esm.js +1 -0
- package/dist/sideBar.cjs.js +1 -0
- package/dist/sideBar.esm.js +1 -0
- package/dist/sideNavBar.cjs.js +1 -0
- package/dist/sideNavBar.esm.js +1 -0
- package/dist/simpleBar.cjs.js +1 -0
- package/dist/simpleBar.esm.js +1 -0
- package/dist/stack.cjs.js +1 -0
- package/dist/stack.esm.js +1 -0
- package/dist/table.cjs.js +1 -0
- package/dist/table.esm.js +1 -0
- package/dist/text.cjs.js +1 -0
- package/dist/text.esm.js +1 -0
- package/dist/textField.cjs.js +1 -0
- package/dist/textField.esm.js +1 -0
- package/dist/wrap.cjs.js +1 -0
- package/dist/wrap.esm.js +1 -0
- package/dist/zoomCard.cjs.js +1 -0
- package/dist/zoomCard.esm.js +1 -0
- package/layout/<head> +59 -0
- package/layout/DEADJOE +49 -0
- package/layout/DEPRECATED-PARAGRAPH.js +103 -0
- package/layout/animator.js +1915 -0
- package/layout/audio.js +145 -0
- package/layout/audionew.js +70 -0
- package/layout/base-2.js +92 -0
- package/layout/base.js +161 -0
- package/layout/betaDesktopBar.js +126 -0
- package/layout/betaMobileBar.js +293 -0
- package/layout/box.js +29 -0
- package/layout/button.js +516 -0
- package/layout/cards.js +136 -0
- package/layout/center.js +143 -0
- package/layout/checkbox.js +183 -0
- package/layout/cleanRow.js +775 -0
- package/layout/code.js +60 -0
- package/layout/container.js +1005 -0
- package/layout/custom.js +289 -0
- package/layout/divImage.js +209 -0
- package/layout/dropdown.js +154 -0
- package/layout/dropdown2025.js +152 -0
- package/layout/edit.sh +39 -0
- package/layout/emptyElement.js +21 -0
- package/layout/externalStylesheet.js +19 -0
- package/layout/flexCard.js +220 -0
- package/layout/flexGrid.js +192 -0
- package/layout/flexrow.js +866 -0
- package/layout/footer.js +83 -0
- package/layout/formComponents/custom.js +0 -0
- package/layout/formComponents/dataList.js +183 -0
- package/layout/formComponents/edit.sh +39 -0
- package/layout/formComponents/floatingInput.js +163 -0
- package/layout/formComponents/form-all.js +161 -0
- package/layout/formComponents/form.js +76 -0
- package/layout/formComponents/imagePicker.js +266 -0
- package/layout/formComponents/picker.js +208 -0
- package/layout/formComponents/radio.js +231 -0
- package/layout/formComponents/radiogroup.js +231 -0
- package/layout/formComponents/range.js +158 -0
- package/layout/free.js +232 -0
- package/layout/grid-new.js +299 -0
- package/layout/grid.js +190 -0
- package/layout/gridSwitcher.js +188 -0
- package/layout/group.js +163 -0
- package/layout/header.js +175 -0
- package/layout/hello.html +126 -0
- package/layout/horizontalScroller.js +222 -0
- package/layout/image-old.js +487 -0
- package/layout/image.js +1039 -0
- package/layout/index.js +183 -0
- package/layout/label.js +50 -0
- package/layout/link.js +1085 -0
- package/layout/list-OLD.js +0 -0
- package/layout/list.js +127 -0
- package/layout/metaAdder.js +17 -0
- package/layout/modal2025.js +142 -0
- package/layout/modernwrap.js +92 -0
- package/layout/multiswitcher.js +224 -0
- package/layout/multiswitcherBeta.js +63 -0
- package/layout/navBar-OLD.js +261 -0
- package/layout/navBar.js +371 -0
- package/layout/navFactor/customDiv.js +60 -0
- package/layout/navFactor/edit.sh +39 -0
- package/layout/newFlatAdder.js +41 -0
- package/layout/newNavBar copy 2.js +915 -0
- package/layout/newNavBar copy.js +774 -0
- package/layout/newNavBar.js +925 -0
- package/layout/offsetContainer.js +395 -0
- package/layout/progress.js +111 -0
- package/layout/remWin.sh +20 -0
- package/layout/row.js +208 -0
- package/layout/savedNewNavBar.js +437 -0
- package/layout/scrollvideo.js +120 -0
- package/layout/sideBar.js +183 -0
- package/layout/sideNavBar.js +313 -0
- package/layout/simpleBar.js +25 -0
- package/layout/slider2025.js +198 -0
- package/layout/spacer.js +44 -0
- package/layout/stack.js +76 -0
- package/layout/styler.js +113 -0
- package/layout/switcher.js +102 -0
- package/layout/table.js +155 -0
- package/layout/text.js +1685 -0
- package/layout/textField.js +282 -0
- package/layout/ulist.js +147 -0
- package/layout/video.js +70 -0
- package/layout/withoutNew.js +60 -0
- package/layout/wrap.js +140 -0
- package/layout/zoomCard.js +219 -0
- package/lib/cardGetter.js +80 -0
- package/lib/designer.js +875 -0
- package/lib/elementMapper.js +1428 -0
- package/lib/linkGetter.js +202 -0
- package/package.json +33 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
class Modal {
|
|
4
|
+
constructor(){
|
|
5
|
+
this.el = null;
|
|
6
|
+
this.obj = null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setup(obj){
|
|
10
|
+
let el = document.createElement("div");
|
|
11
|
+
el.style.width = "100vw";
|
|
12
|
+
el.style.height = "160vh";
|
|
13
|
+
el.style.backgroundColor = obj.background;//"rgba(70,157,115,0.8)";
|
|
14
|
+
// el.style.backgroundColor = "#3498db";
|
|
15
|
+
el.style.zIndex = "1";
|
|
16
|
+
//el.style.opacity = 0.90;
|
|
17
|
+
el.style.position = "absolute";
|
|
18
|
+
el.style.overflowY = "scroll";
|
|
19
|
+
el.style.display = "block";
|
|
20
|
+
|
|
21
|
+
this.obj = obj;
|
|
22
|
+
this.res = el;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
close(){
|
|
31
|
+
this.res.style.display = "none";
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
show(){
|
|
36
|
+
this.res.style.display = "block";
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
add(els){
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
let el = document.createElement("div");
|
|
47
|
+
el.style.marginTop = "60px";
|
|
48
|
+
el.style.width = this.obj.width; //"60%";
|
|
49
|
+
el.style.height = "auto";
|
|
50
|
+
el.style.marginLeft = "auto";
|
|
51
|
+
el.style.marginRight = "auto";
|
|
52
|
+
el.style.backgroundColor = "white"; // "#3498db";
|
|
53
|
+
el.style.opacity = 1.0;
|
|
54
|
+
el.style.zIndex = "2";
|
|
55
|
+
el.style.borderRadius = "16px";
|
|
56
|
+
// el.style.padding = "2em";
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
let mq = window.matchMedia("(max-device-width: 415px)");
|
|
60
|
+
if (mq.matches){
|
|
61
|
+
el.style.marginTop = "200px";
|
|
62
|
+
el.style.width = "100%";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
for (var i = 0; i < els.length; i++){
|
|
68
|
+
console.log(els[i]);
|
|
69
|
+
el.appendChild(els[i].render());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
this.res.appendChild(el);
|
|
76
|
+
|
|
77
|
+
/* let inner = new Text("WOW");
|
|
78
|
+
let ren = inner.render();
|
|
79
|
+
ren.style.zIndex = "2";
|
|
80
|
+
|
|
81
|
+
this.res.appendChild(ren);
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
return this;
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
render(el) {
|
|
93
|
+
if (el) {
|
|
94
|
+
document.querySelector("body").style.margin = 0;
|
|
95
|
+
document.querySelector("body").style.padding = 0;
|
|
96
|
+
document.querySelector(el).appendChild(this.res);
|
|
97
|
+
} else {
|
|
98
|
+
return this.res;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class GridNew {
|
|
107
|
+
constructor(frs, saveEl) {
|
|
108
|
+
this.saveEl = saveEl;
|
|
109
|
+
this.frs = frs;
|
|
110
|
+
this.res = null;
|
|
111
|
+
this.setup();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
setup() {
|
|
115
|
+
let parent = document.createElement("div");
|
|
116
|
+
parent.setAttribute("id", "ABC34");
|
|
117
|
+
this.parent = parent;
|
|
118
|
+
|
|
119
|
+
let grid = document.createElement("div");
|
|
120
|
+
grid.style.margin = 0;
|
|
121
|
+
grid.style.padding = 0;
|
|
122
|
+
grid.style.display = "flex";
|
|
123
|
+
grid.style.flexWrap = "wrap";
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
if (this.frs){
|
|
128
|
+
grid.style.gridTemplateColumns = Array(this.frs).fill("1fr").join(" ");
|
|
129
|
+
}
|
|
130
|
+
grid.style.gridTemplateColumns = "repeat(auto-fit, minmax(250px, 1fr))";
|
|
131
|
+
*/
|
|
132
|
+
this.res = grid;
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
absolute(){
|
|
137
|
+
// this.res.style.position = "absolute";
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
setAreas(areas){
|
|
142
|
+
console.log(areas);
|
|
143
|
+
this.res.children[0].style.gridArea = "a";
|
|
144
|
+
this.res.children[1].style.gridArea = "b";
|
|
145
|
+
this.res.style.gridTemplateAreas = `"a a a b"`;
|
|
146
|
+
console.warn(this.res.style.gridTemplateAreas);
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
detailView(){
|
|
153
|
+
/*let detail = document.createElement("img");
|
|
154
|
+
|
|
155
|
+
detail.setAttribute("src", "https://www.kasandbox.org/programming-images/animals/birds_rainbow-lorakeets.png");
|
|
156
|
+
detail.style.width = "400px";
|
|
157
|
+
detail.style.marginLeft = "auto";
|
|
158
|
+
detail.style.marginRight = "auto";
|
|
159
|
+
detail.style.position = "absolute";
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
detail.style.zIndex = 2;
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
this.parent.appendChild(detail);*/
|
|
167
|
+
this.parent.appendChild(this.res);
|
|
168
|
+
return this;
|
|
169
|
+
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
stretchFit() {
|
|
177
|
+
this.res.style.height = "auto";
|
|
178
|
+
this.res.style.width = "100%";
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
size(w, h) {
|
|
183
|
+
if (w === "wide") {
|
|
184
|
+
this.res.style.width = "100%";
|
|
185
|
+
} else {
|
|
186
|
+
this.res.style.width = w;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (h === "fit") {
|
|
190
|
+
this.res.style.height = "auto";
|
|
191
|
+
} else {
|
|
192
|
+
this.res.style.height = h;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
border(){
|
|
199
|
+
this.res.style.border = "3px solid green";
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
items(arr) {
|
|
204
|
+
console.warn(arr);
|
|
205
|
+
for (var i = 0; i < arr.length; i++) {
|
|
206
|
+
this.res.appendChild(arr[i].render());
|
|
207
|
+
}
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
center() {
|
|
213
|
+
this.res.style.justifyItems = "center";
|
|
214
|
+
return this;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
padding(val, direction) {
|
|
218
|
+
if (direction) {
|
|
219
|
+
if (direction == "left") {
|
|
220
|
+
this.res.style.paddingLeft = val;
|
|
221
|
+
} else if (direction == "top") {
|
|
222
|
+
this.res.style.paddingTop = val;
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
this.res.style.padding = val;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
onTap(e) {
|
|
232
|
+
this.res.addEventListener("click", e);
|
|
233
|
+
return this;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
gap(value){
|
|
237
|
+
this.gap = `${value}px`;
|
|
238
|
+
return this;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
setColumns(obj) { // (count, h)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
let count = obj.count;
|
|
246
|
+
let h = obj.width;
|
|
247
|
+
|
|
248
|
+
//let media = window.matchMedia(`(max-width: 600px)`);
|
|
249
|
+
let query = window.matchMedia("(max-device-width: 415px)");
|
|
250
|
+
|
|
251
|
+
if (window.innerWidth < h || query.matches) {
|
|
252
|
+
this.res.style.gridTemplateColumns = Array(count).fill("1fr").join(" ");
|
|
253
|
+
this.res.style.gridGap = this.gap; //"30px";
|
|
254
|
+
} else {
|
|
255
|
+
this.res.style.gridGap = this.gap; // "30px";
|
|
256
|
+
this.res.style.gridTemplateColumns = Array(this.frs).fill("1fr").join(" ");
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
const adjust = () => {
|
|
261
|
+
|
|
262
|
+
if (window.innerWidth < h) {
|
|
263
|
+
this.res.style.gridTemplateColumns = Array(count).fill("1fr").join(" ");
|
|
264
|
+
this.res.style.gridGap = this.gap; //"30px";
|
|
265
|
+
} else {
|
|
266
|
+
this.res.style.gridTemplateColumns = Array(this.frs).fill("1fr").join(" ");
|
|
267
|
+
this.res.style.gridGap = this.gap; // "30px";
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
window.addEventListener("resize", adjust);
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
render(el) {
|
|
280
|
+
if (el){
|
|
281
|
+
document.querySelector(el).appendChild(this.parent);
|
|
282
|
+
} else {
|
|
283
|
+
return this.parent;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
window.Modal
|
|
296
|
+
GridNew = Modal
|
|
297
|
+
GridNew;
|
|
298
|
+
export { Modal
|
|
299
|
+
GridNew };
|
package/layout/grid.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Grid {
|
|
5
|
+
constructor(frs, saveEl) {
|
|
6
|
+
this.saveEl = saveEl;
|
|
7
|
+
this.frs = frs;
|
|
8
|
+
this.res = null;
|
|
9
|
+
this.setup();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getType(){
|
|
13
|
+
return "GridLayoutElement";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
setup() {
|
|
17
|
+
let parent = document.createElement("div");
|
|
18
|
+
this.parent = parent;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
let grid = document.createElement("div");
|
|
22
|
+
grid.style.margin = 0;
|
|
23
|
+
grid.style.padding = 0;
|
|
24
|
+
grid.style.display = "grid";
|
|
25
|
+
|
|
26
|
+
if (this.frs){
|
|
27
|
+
grid.style.gridTemplateColumns = Array(this.frs).fill("1fr").join(" ");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.res = grid;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
freeAreas(){
|
|
35
|
+
this.res.style.gridTemplateAreas = `"a a a b c"`;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
setAreas(areas){
|
|
41
|
+
console.log(areas);
|
|
42
|
+
this.res.children[0].style.gridArea = "a";
|
|
43
|
+
this.res.children[1].style.gridArea = "b";
|
|
44
|
+
this.res.style.gridTemplateAreas = `"a a a b"`;
|
|
45
|
+
console.warn(this.res.style.gridTemplateAreas);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
detailView(){
|
|
50
|
+
let detail = document.createElement("img");
|
|
51
|
+
detail.setAttribute("src", "https://www.kasandbox.org/programming-images/animals/birds_rainbow-lorakeets.png");
|
|
52
|
+
detail.style.width = "400px";
|
|
53
|
+
detail.style.marginLeft = "auto";
|
|
54
|
+
detail.style.marginRight = "auto";
|
|
55
|
+
|
|
56
|
+
//this.res.style.zIndex = -1;
|
|
57
|
+
|
|
58
|
+
detail.style.zIndex = 2;
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
this.res.appendChild(detail);
|
|
63
|
+
return this;
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
stretchFit() {
|
|
72
|
+
this.res.style.height = "auto";
|
|
73
|
+
this.res.style.width = "100%";
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
size(w, h) {
|
|
78
|
+
if (w === "wide") {
|
|
79
|
+
this.res.style.width = "100%";
|
|
80
|
+
} else {
|
|
81
|
+
this.res.style.width = w;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (h === "fit") {
|
|
85
|
+
this.res.style.height = "auto";
|
|
86
|
+
} else {
|
|
87
|
+
this.res.style.height = h;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
border(){
|
|
94
|
+
this.res.style.border = "3px solid green";
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
items(arr) {
|
|
99
|
+
console.warn(arr);
|
|
100
|
+
for (var i = 0; i < arr.length; i++) {
|
|
101
|
+
this.res.appendChild(arr[i].render());
|
|
102
|
+
}
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
center() {
|
|
108
|
+
this.res.style.justifyItems = "center";
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
padding(val, direction) {
|
|
113
|
+
if (direction) {
|
|
114
|
+
if (direction == "left") {
|
|
115
|
+
this.res.style.paddingLeft = val;
|
|
116
|
+
} else if (direction == "top") {
|
|
117
|
+
this.res.style.paddingTop = val;
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
this.res.style.padding = val;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
onTap(e) {
|
|
127
|
+
this.res.addEventListener("click", e);
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
gap(value){
|
|
132
|
+
this.gap = `${value}px`;
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
setColumns(obj) { // (count, h)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
let count = obj.count;
|
|
141
|
+
let h = obj.width;
|
|
142
|
+
|
|
143
|
+
//let media = window.matchMedia(`(max-width: 600px)`);
|
|
144
|
+
let query = window.matchMedia("(max-device-width: 415px)");
|
|
145
|
+
|
|
146
|
+
if (window.innerWidth < h || query.matches) {
|
|
147
|
+
this.res.style.gridTemplateColumns = Array(count).fill("1fr").join(" ");
|
|
148
|
+
this.res.style.gridGap = this.gap; //"30px";
|
|
149
|
+
} else {
|
|
150
|
+
this.res.style.gridGap = this.gap; // "30px";
|
|
151
|
+
this.res.style.gridTemplateColumns = Array(this.frs).fill("1fr").join(" ");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
const adjust = () => {
|
|
156
|
+
|
|
157
|
+
if (window.innerWidth < h) {
|
|
158
|
+
this.res.style.gridTemplateColumns = Array(count).fill("1fr").join(" ");
|
|
159
|
+
this.res.style.gridGap = this.gap; //"30px";
|
|
160
|
+
} else {
|
|
161
|
+
this.res.style.gridTemplateColumns = Array(this.frs).fill("1fr").join(" ");
|
|
162
|
+
this.res.style.gridGap = this.gap; // "30px";
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
window.addEventListener("resize", adjust);
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
render(el) {
|
|
175
|
+
if (el){
|
|
176
|
+
document.querySelector(el).appendChild(this.res);
|
|
177
|
+
} else {
|
|
178
|
+
return this.res;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
export { Grid };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
class Simple {
|
|
2
|
+
constructor() {
|
|
3
|
+
|
|
4
|
+
this.gridContainer = document.createElement("div");
|
|
5
|
+
this.gridContainer.classList.add("grid-container");
|
|
6
|
+
this.gridContainer.style.display = "grid";
|
|
7
|
+
// this.gridContainer.style.gridAutoRows = "1fr"; EVIL LINE
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
set(obj){
|
|
11
|
+
obj.gap && (this.gridContainer.style.gap = obj.gap);
|
|
12
|
+
obj.height && (this.gridContainer.style.height = obj.height);
|
|
13
|
+
obj.width && (this.gridContainer.style.width = obj.width);
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
[
|
|
19
|
+
{
|
|
20
|
+
at: "default",
|
|
21
|
+
template: [
|
|
22
|
+
"abbbbb",
|
|
23
|
+
"abbbbb",
|
|
24
|
+
"abbbbb",
|
|
25
|
+
"cccccc",
|
|
26
|
+
"cccccc",
|
|
27
|
+
"dddddd",
|
|
28
|
+
"eeeeee",
|
|
29
|
+
"eeeeee"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
*/
|
|
33
|
+
react(arr){
|
|
34
|
+
const reacta = () => {
|
|
35
|
+
console.log(arr.length);
|
|
36
|
+
for (var i = 0; i < arr.length - 1; i++){
|
|
37
|
+
// alert(parseInt(arr[i].at))
|
|
38
|
+
console.warn(window.innerWidth);
|
|
39
|
+
//console.warn("BETWEEN" + parseInt(arr[i].at) + " - " + parseInt(arr[i + 1].at) );
|
|
40
|
+
|
|
41
|
+
let from = parseInt(arr[i].at);
|
|
42
|
+
let to = parseInt(arr[i + 1].at);
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if ( window.innerWidth > from && window.innerWidth < to ){
|
|
46
|
+
//alert("O")
|
|
47
|
+
console.log("FROM " + from + " TO " + to);
|
|
48
|
+
let obj = arr[i].template;
|
|
49
|
+
|
|
50
|
+
let withSpaceObj = obj.map(str => str.split('').join(' '));
|
|
51
|
+
const outputString = withSpaceObj.map(row => `"${row}"`).join(" ");
|
|
52
|
+
this.gridContainer.style.gridTemplateAreas = outputString;
|
|
53
|
+
|
|
54
|
+
this.gridContainer.style.border = `3px solid ${arr[i].color}`;
|
|
55
|
+
|
|
56
|
+
} else if (window.innerWidth > to) {
|
|
57
|
+
this.gridContainer.style.border = `3px solid ${arr[arr.length - 1].color}`;
|
|
58
|
+
console.log("BIGGER THAN" + " " + to);
|
|
59
|
+
//alert("P")
|
|
60
|
+
// This always fires
|
|
61
|
+
let obj = arr[arr.length - 1].template;
|
|
62
|
+
|
|
63
|
+
let withSpaceObj = obj.map(str => str.split('').join(' '));
|
|
64
|
+
const outputString = withSpaceObj.map(row => `"${row}"`).join(" ");
|
|
65
|
+
this.gridContainer.style.gridTemplateAreas = outputString;
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
//return this;
|
|
72
|
+
}
|
|
73
|
+
reacta();
|
|
74
|
+
window.addEventListener("resize", reacta);
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
add(items){
|
|
79
|
+
console.log(items);
|
|
80
|
+
|
|
81
|
+
// let withSpaceObj = obj.map(str => str.split('').join(' '));
|
|
82
|
+
// const outputString = withSpaceObj.map(row => `"${row}"`).join(" ");
|
|
83
|
+
// this.gridContainer.style.gridTemplateAreas = outputString;//'"a a a" "b b b" "c d d" "c d d"';
|
|
84
|
+
// Function to generate alphabetic sequences
|
|
85
|
+
const generateAlphabeticSequence = (count) => {
|
|
86
|
+
const chars = [];
|
|
87
|
+
for (let i = 0; i < count; i++) {
|
|
88
|
+
let str = '';
|
|
89
|
+
let num = i;
|
|
90
|
+
do {
|
|
91
|
+
str = String.fromCharCode(65 + (num % 26)) + str; // Generate character
|
|
92
|
+
num = Math.floor(num / 26) - 1;
|
|
93
|
+
} while (num >= 0);
|
|
94
|
+
chars.push(str);
|
|
95
|
+
}
|
|
96
|
+
return chars;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Generate 'els' array dynamically
|
|
100
|
+
let els = generateAlphabeticSequence(items.length); // ['A', 'B', ..., 'Z', 'AA', 'AB', ...]
|
|
101
|
+
|
|
102
|
+
for (let i = 0; i < items.length; i++) {
|
|
103
|
+
let e = items[i].render();
|
|
104
|
+
e.style.border = "1px solid gray";
|
|
105
|
+
e.style.gridArea = els[i].toLowerCase(); // e.g., 'a', 'b', 'aa', 'ab', ...
|
|
106
|
+
|
|
107
|
+
const gridItem = document.createElement("div");
|
|
108
|
+
gridItem.textContent = items[i].text;
|
|
109
|
+
gridItem.style.gridArea = els[i].toLowerCase();
|
|
110
|
+
this.gridContainer.appendChild(e);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
render(el) {
|
|
118
|
+
el && document.querySelector(el).appendChild(this.gridContainer);
|
|
119
|
+
return this.gridContainer;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
toCode(){
|
|
123
|
+
return `new Simple().set({}).react([])`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Usage example:
|
|
128
|
+
//const simpleGrid = new Simple();
|
|
129
|
+
//document.body.appendChild(simpleGrid.render());
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class GridSwitcher {
|
|
133
|
+
constructor(){
|
|
134
|
+
this.el = document.createElement("div");
|
|
135
|
+
this.gridWrap = document.createElement("div");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
DOMAdd(dom){
|
|
139
|
+
this.domStr = dom;
|
|
140
|
+
this.domEl = document.querySelector(dom);
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
items(arr){
|
|
145
|
+
this.items = arr;
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
dynamicItems(arr){
|
|
150
|
+
this.dynamicItems = arr;
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
switch(breakpoints){
|
|
154
|
+
const innerSwitch = () => {
|
|
155
|
+
for (let i = 0; i < breakpoints.length; i++){
|
|
156
|
+
const val = breakpoints[i];
|
|
157
|
+
let mq = window.matchMedia(`(max-width: ${val.at})`).matches;
|
|
158
|
+
if ((mq || val.at == "default") && mq !== this.lastMq){
|
|
159
|
+
const update = new Simple().set(val.template, this.dynamicItems).render();
|
|
160
|
+
this.el = update;
|
|
161
|
+
this.el.style.border = "1px solid black";
|
|
162
|
+
this.render(this.domStr);
|
|
163
|
+
this.lastMq = mq;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
innerSwitch();
|
|
168
|
+
window.addEventListener("resize", innerSwitch);
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
render(div){
|
|
173
|
+
this.gridWrap.innerHTML = "";
|
|
174
|
+
this.gridWrap.appendChild(this.el);
|
|
175
|
+
|
|
176
|
+
// document.querySelector(div).removeChild(this.el);
|
|
177
|
+
if (div){
|
|
178
|
+
document.querySelector(div).appendChild(this.gridWrap);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return this.gridWrap;
|
|
182
|
+
|
|
183
|
+
// return this.el;
|
|
184
|
+
// Just return this.el it normally
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export {Simple};
|