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,198 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
import {Button} from "./button.js";
|
|
3
|
+
|
|
4
|
+
class Slider {
|
|
5
|
+
constructor(elements, buttons) {
|
|
6
|
+
this.container = document.createElement("div");//document.querySelector(containerSelector);
|
|
7
|
+
this.elements = elements;
|
|
8
|
+
this.currentSlideIndex = 0;
|
|
9
|
+
|
|
10
|
+
this.buttons = buttons;
|
|
11
|
+
|
|
12
|
+
if (!this.buttons){
|
|
13
|
+
|
|
14
|
+
let buttons = {
|
|
15
|
+
leftButton: new Button("L").set({
|
|
16
|
+
url: "https://static-00.iconduck.com/assets.00/circle-arrow-left-icon-512x512-xp8okg5c.png",
|
|
17
|
+
color: "#1abc9c",
|
|
18
|
+
frame: {width: 50, height: 50},
|
|
19
|
+
radius: "100%",
|
|
20
|
+
arrayMargin: {sides: ["all"], value: "1rem"}
|
|
21
|
+
// 10/01/2025 18:12:55 margin does not add to page width, padding does
|
|
22
|
+
}),
|
|
23
|
+
|
|
24
|
+
rightButton: new Button("R").set({
|
|
25
|
+
url: "https://static-00.iconduck.com/assets.00/arrow-right-circle-icon-2048x2048-m0qcnetg.png",
|
|
26
|
+
color: "#1abc9c",
|
|
27
|
+
frame: {width: 50, height: 50},
|
|
28
|
+
radius: "100%",
|
|
29
|
+
arrayMargin: {sides: ["all"], value: "1rem"}
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
this.buttons = buttons;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.createSlider();
|
|
37
|
+
this.init();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
toCode(){
|
|
41
|
+
let code = `new Slider([${this.elements.map(el => el.toCode())}], null)`;
|
|
42
|
+
code = code.replace(/,\s*\./g, '.');
|
|
43
|
+
return [code];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
createSlider() {
|
|
47
|
+
// Slider container
|
|
48
|
+
this.slider = document.createElement('div');
|
|
49
|
+
this.slider.style.width = '100%';
|
|
50
|
+
this.slider.style.height = '400px';
|
|
51
|
+
this.slider.style.margin = '20px auto';
|
|
52
|
+
this.slider.style.textAlign = 'center';
|
|
53
|
+
this.slider.style.borderRadius = '20px';
|
|
54
|
+
this.slider.style.overflow = 'hidden';
|
|
55
|
+
this.slider.style.position = 'relative';
|
|
56
|
+
|
|
57
|
+
// Slides wrapper
|
|
58
|
+
const slidesWrapper = document.createElement('div');
|
|
59
|
+
this.slidesWrapper = slidesWrapper;
|
|
60
|
+
slidesWrapper.style.display = 'flex';
|
|
61
|
+
slidesWrapper.style.overflowX = 'scroll';
|
|
62
|
+
slidesWrapper.style.scrollBehavior = 'smooth';
|
|
63
|
+
slidesWrapper.style.scrollSnapType = 'x mandatory';
|
|
64
|
+
|
|
65
|
+
this.elements.forEach((text, index) => {
|
|
66
|
+
const slide = document.createElement('div');
|
|
67
|
+
slide.setAttribute("class", "slide");
|
|
68
|
+
slide.style.display = 'flex';
|
|
69
|
+
slide.style.justifyContent = 'center';
|
|
70
|
+
slide.style.alignItems = 'center';
|
|
71
|
+
slide.style.flexShrink = '0';
|
|
72
|
+
slide.style.width = '100%';
|
|
73
|
+
slide.style.height = '400px';
|
|
74
|
+
slide.style.background = index % 2 === 0 ? 'rgb(250, 246, 212)' : 'white';
|
|
75
|
+
slide.style.transformOrigin = 'center center';
|
|
76
|
+
slide.style.transform = 'scale(1)';
|
|
77
|
+
slide.style.scrollSnapAlign = 'center';
|
|
78
|
+
|
|
79
|
+
slide.appendChild(text.render());
|
|
80
|
+
slidesWrapper.appendChild(slide);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Navigation arrows
|
|
84
|
+
this.arrowPrev = this.buttons.leftButton.render();
|
|
85
|
+
this.arrowPrev.style.position = 'absolute';
|
|
86
|
+
this.arrowPrev.style.left = '10px';
|
|
87
|
+
this.arrowPrev.style.top = '50%';
|
|
88
|
+
this.arrowPrev.style.transform = 'translateY(-50%)';
|
|
89
|
+
this.arrowPrev.style.zIndex = '1';
|
|
90
|
+
|
|
91
|
+
this.arrowNext = this.buttons.rightButton.render();
|
|
92
|
+
this.arrowNext.style.position = 'absolute';
|
|
93
|
+
this.arrowNext.style.right = '10px';
|
|
94
|
+
this.arrowNext.style.top = '50%';
|
|
95
|
+
this.arrowNext.style.transform = 'translateY(-50%)';
|
|
96
|
+
this.arrowNext.style.zIndex = '1';
|
|
97
|
+
|
|
98
|
+
// Navigation dots
|
|
99
|
+
const nav = document.createElement('div');
|
|
100
|
+
nav.style.position = 'absolute';
|
|
101
|
+
nav.style.bottom = '10%';
|
|
102
|
+
nav.style.left = '50%';
|
|
103
|
+
nav.style.width = '200px';
|
|
104
|
+
nav.style.transform = 'translateX(-50%)';
|
|
105
|
+
nav.style.textAlign = 'center';
|
|
106
|
+
|
|
107
|
+
this.elements.forEach((_, index) => {
|
|
108
|
+
const navLink = document.createElement('a');
|
|
109
|
+
navLink.style.display = 'inline-block';
|
|
110
|
+
navLink.style.height = '15px';
|
|
111
|
+
navLink.style.width = '15px';
|
|
112
|
+
navLink.style.borderRadius = '50%';
|
|
113
|
+
navLink.style.backgroundColor = 'black';
|
|
114
|
+
navLink.style.margin = '0 10px';
|
|
115
|
+
navLink.style.cursor = 'pointer';
|
|
116
|
+
navLink.dataset.index = index;
|
|
117
|
+
nav.appendChild(navLink);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Append elements to the slider
|
|
121
|
+
this.slider.appendChild(this.arrowPrev);
|
|
122
|
+
this.slider.appendChild(this.arrowNext);
|
|
123
|
+
this.slider.appendChild(slidesWrapper);
|
|
124
|
+
this.slider.appendChild(nav);
|
|
125
|
+
|
|
126
|
+
// Append slider to the container
|
|
127
|
+
this.container.appendChild(this.slider);
|
|
128
|
+
|
|
129
|
+
// Store references
|
|
130
|
+
this.slidesWrapper = slidesWrapper;
|
|
131
|
+
this.navLinks = nav.querySelectorAll('a');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
init() {
|
|
135
|
+
this.updateActiveSlide();
|
|
136
|
+
this.attachEventListeners();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
attachEventListeners() {
|
|
140
|
+
this.arrowPrev.addEventListener('click', () => {
|
|
141
|
+
this.moveToSlide(
|
|
142
|
+
this.currentSlideIndex - 1 < 0 ? this.elements.length - 1 : this.currentSlideIndex - 1
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
this.arrowNext.addEventListener('click', () => {
|
|
147
|
+
this.moveToSlide((this.currentSlideIndex + 1) % this.elements.length);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
this.navLinks.forEach((navLink) => {
|
|
151
|
+
navLink.addEventListener('click', (e) => {
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
const index = parseInt(navLink.dataset.index, 10);
|
|
154
|
+
this.moveToSlide(index);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Keydown event for left and right arrow keys
|
|
159
|
+
document.addEventListener('keydown', (e) => {
|
|
160
|
+
if (e.key === 'ArrowLeft') {
|
|
161
|
+
// Move to the previous slide
|
|
162
|
+
this.moveToSlide(
|
|
163
|
+
this.currentSlideIndex - 1 < 0 ? this.elements.length - 1 : this.currentSlideIndex - 1
|
|
164
|
+
);
|
|
165
|
+
} else if (e.key === 'ArrowRight') {
|
|
166
|
+
// Move to the next slide
|
|
167
|
+
this.moveToSlide((this.currentSlideIndex + 1) % this.elements.length);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
moveToSlide(index) {
|
|
173
|
+
this.currentSlideIndex = index;
|
|
174
|
+
this.updateActiveSlide();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
updateActiveSlide() {
|
|
178
|
+
this.navLinks.forEach((navLink, index) => {
|
|
179
|
+
navLink.style.backgroundColor = index === this.currentSlideIndex ? 'green' : 'gray';
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const slideWidth = this.slidesWrapper.querySelector('.slide').offsetWidth;
|
|
183
|
+
this.slidesWrapper.scrollTo({
|
|
184
|
+
left: this.currentSlideIndex * slideWidth,
|
|
185
|
+
behavior: 'smooth',
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
render(div) {
|
|
190
|
+
if (div) {
|
|
191
|
+
document.querySelector(div).appendChild(this.slider);
|
|
192
|
+
} else {
|
|
193
|
+
return this.slider;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export { Slider };
|
package/layout/spacer.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
class Spacer {
|
|
4
|
+
constructor( hide) {
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
this.hide = hide;
|
|
10
|
+
|
|
11
|
+
if (hide){
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var card = document.createElement("div");
|
|
15
|
+
card.style.flex = "1";
|
|
16
|
+
this.res = card;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
if (hide){
|
|
21
|
+
this.res.setAttribute("class", "innerHider");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return this;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
toCode(){
|
|
30
|
+
return [`new Spacer(${this.hide})`];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
render(){
|
|
34
|
+
|
|
35
|
+
var one = document.createElement("h2");
|
|
36
|
+
one.style.display = "none !important";
|
|
37
|
+
|
|
38
|
+
return this.res ?? one;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { Spacer };
|
package/layout/stack.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
class Stack {
|
|
4
|
+
constructor(st){
|
|
5
|
+
this.res = null;
|
|
6
|
+
|
|
7
|
+
this.st = st;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
setup(){
|
|
11
|
+
let grid = document.createElement("div");
|
|
12
|
+
grid.style.display = "grid";
|
|
13
|
+
this.res = grid;
|
|
14
|
+
|
|
15
|
+
if (this.st){
|
|
16
|
+
this.sticky();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
set(obj){
|
|
24
|
+
this.setup();
|
|
25
|
+
obj.height && (this.res.style.height = obj.height);
|
|
26
|
+
obj.sticky && this.sticky();
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
sticky(){
|
|
31
|
+
this.res.style.position = "sticky";
|
|
32
|
+
this.res.style.top = 0;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
add(els){
|
|
37
|
+
this.children = els;
|
|
38
|
+
for (var i = 0; i < els.length; i++){
|
|
39
|
+
let el = els[i].render();
|
|
40
|
+
el.style.gridColumn = 1;
|
|
41
|
+
el.style.gridRow = 1;
|
|
42
|
+
this.res.appendChild(el);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
toCode() {
|
|
50
|
+
// Initialize the code string with the Stack setup
|
|
51
|
+
let code = `new Stack().set({})`;
|
|
52
|
+
|
|
53
|
+
// Add child elements
|
|
54
|
+
if (this.children.length > 0) {
|
|
55
|
+
const childrenCode = this.children.map(child => child.toCode()).join(",\n");
|
|
56
|
+
code += `.add([\n \n ${childrenCode} \n \n])`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Return the final code
|
|
60
|
+
return [code];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
render(el) {
|
|
64
|
+
if (el) {
|
|
65
|
+
document.querySelector("body").style.margin = 0;
|
|
66
|
+
document.querySelector("body").style.padding = 0;
|
|
67
|
+
document.querySelector(el).appendChild(this.res);
|
|
68
|
+
} else {
|
|
69
|
+
return this.res;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
export { Stack };
|
package/layout/styler.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
let un = new UniStyle()
|
|
15
|
+
.maxWidth(800, new Style().color("blue"));
|
|
16
|
+
// write applyUniStyle for each element
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// write applyUniStyleMethod
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class Style {
|
|
34
|
+
constructor(obj) {
|
|
35
|
+
this.width = obj.max;
|
|
36
|
+
this.min = obj.min;
|
|
37
|
+
this.max = obj.max;
|
|
38
|
+
|
|
39
|
+
this.styles = {
|
|
40
|
+
color: "",
|
|
41
|
+
background: "",
|
|
42
|
+
fontWeight: "",
|
|
43
|
+
align: "",
|
|
44
|
+
padding: [],
|
|
45
|
+
margin: [],
|
|
46
|
+
opacity: 1,
|
|
47
|
+
fontSize: "",
|
|
48
|
+
width: "",
|
|
49
|
+
height:"",
|
|
50
|
+
gridTemplateAreas: "",
|
|
51
|
+
height: ""
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
height(h){
|
|
57
|
+
this.styles.height = h;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
arrayAreas(str){
|
|
62
|
+
this.styles.gridTemplateAreas = str;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
color(name) {
|
|
67
|
+
this.styles.color = name;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
background(name) {
|
|
72
|
+
this.styles.background = name;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
bold() {
|
|
77
|
+
this.styles.fontWeight = "bold";
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
align(alignment) {
|
|
82
|
+
this.styles.align = alignment;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
padding(L, T, R, B) {
|
|
87
|
+
this.styles.padding = [L, T, R, B];
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
margin(L, T, R, B) {
|
|
92
|
+
this.styles.margin = [L, T, R, B];
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
opacity(value) {
|
|
97
|
+
this.styles.opacity = value;
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
size(w, h) {
|
|
103
|
+
this.styles.width = w;
|
|
104
|
+
this.styles.height = w;
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
em(val){
|
|
109
|
+
this.styles.fontSize = `${val}em`;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export { Style };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Switcher {
|
|
5
|
+
constructor(obj){
|
|
6
|
+
this.res = null;
|
|
7
|
+
this.obj = obj;
|
|
8
|
+
this.code = [];
|
|
9
|
+
console.warn(this.obj);
|
|
10
|
+
|
|
11
|
+
if (obj.first.toCode && obj.second.toCode){
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
this.code.push(`, new Switcher({breakpoint: "${this.obj.breakpoint}", first: ${this.obj.first.toCode()}, second: ${this.obj.second.toCode()}})`);
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
// console.log(this.obj.first.toCode());
|
|
18
|
+
|
|
19
|
+
let area = document.createElement("textarea");
|
|
20
|
+
area.style.fontWeight = "bold";
|
|
21
|
+
area.style.height = 1000;
|
|
22
|
+
area.style.width = 1000;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/* te.value = te.value.replace(".mount('#mount');,", ".mount('#mount');");
|
|
27
|
+
te.value = te.value.replace(" ,new Wrapper", "new Wrapper");
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
this.codeArr = [...this.code];
|
|
31
|
+
|
|
32
|
+
this.code = this.code.toString().replaceAll(", .", ".")
|
|
33
|
+
.replaceAll(",.", ".")
|
|
34
|
+
.replaceAll(",,.", ".")
|
|
35
|
+
.replaceAll("{,", "{")
|
|
36
|
+
.replaceAll("[,", "[")
|
|
37
|
+
.replace(/,+/g, ',');
|
|
38
|
+
|
|
39
|
+
area.value = this.code;
|
|
40
|
+
document.body.appendChild(area);
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/* {
|
|
44
|
+
breakpoint: 700px,
|
|
45
|
+
first: element,
|
|
46
|
+
second: element,
|
|
47
|
+
|
|
48
|
+
}*/
|
|
49
|
+
|
|
50
|
+
this.switchElements();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
switchElements(){
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
this.res = document.createElement("div"); // move out of the loop
|
|
58
|
+
// 17:27:15 29/09/23
|
|
59
|
+
|
|
60
|
+
const innerSwitch = () => {
|
|
61
|
+
|
|
62
|
+
console.log("I")
|
|
63
|
+
|
|
64
|
+
// alert("LK")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
this.res.innerHTML = "";
|
|
68
|
+
// this.code.push(` \n .switchElements()`)
|
|
69
|
+
let mq = window.matchMedia(`(max-width: ${this.obj.breakpoint})`).matches;
|
|
70
|
+
|
|
71
|
+
if (mq){
|
|
72
|
+
// alert("O")
|
|
73
|
+
|
|
74
|
+
this.res.appendChild(this.obj.first.render());
|
|
75
|
+
} else {
|
|
76
|
+
|
|
77
|
+
this.res.appendChild(this.obj.second.render());
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
innerSwitch();
|
|
82
|
+
|
|
83
|
+
window.addEventListener("resize", innerSwitch);
|
|
84
|
+
// 17:30:22 Nice
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
toCode(){
|
|
91
|
+
// alert("IO0")
|
|
92
|
+
console.log(this.code);
|
|
93
|
+
return this.codeArr;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
render(div){
|
|
98
|
+
document.querySelector(div).appendChild(this.res);
|
|
99
|
+
return this.res;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export { Switcher };
|
package/layout/table.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
class Table extends Animator {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
this.res = document.createElement("table");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
add(data) {
|
|
10
|
+
this.data = data;
|
|
11
|
+
this.datas = data;
|
|
12
|
+
const datas = Object.keys(data[0]);
|
|
13
|
+
this.generateTable(this.res, data);
|
|
14
|
+
this.generateTableHead(this.res, datas);
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
style(obj) {
|
|
20
|
+
this.res.style.fontFamily = obj.font;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
set(obj) {
|
|
25
|
+
obj.cellPadding && this.cellPadding(obj.cellPadding);
|
|
26
|
+
obj.cellAlign && this.cellAlign(obj.cellAlign);
|
|
27
|
+
obj.style && this.style(obj.style);
|
|
28
|
+
obj.headStyle && this.headStyle(obj.headStyle);
|
|
29
|
+
obj.border && this.border(obj.border);
|
|
30
|
+
obj.center && this.center(obj.center);
|
|
31
|
+
obj.borderRadius && this.borderRadius(obj.borderRadius);
|
|
32
|
+
this.obj = obj;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
toCode() {
|
|
37
|
+
let code = `new Table().add(${JSON.stringify(this.data)}).set(${JSON.stringify(this.obj)})`;
|
|
38
|
+
code = code.replace(/"(\w+)":/g, '$1:');
|
|
39
|
+
code = code.replace(/,/g, ',\n');
|
|
40
|
+
return [code];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
center() {
|
|
44
|
+
this.res.style.marginLeft = "auto";
|
|
45
|
+
this.res.style.marginRight = "auto";
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
borderRadius(num) {
|
|
50
|
+
this.res.style.borderCollapse = "separate";
|
|
51
|
+
this.res.style.borderSpacing = 0;
|
|
52
|
+
this.res.style.overflow = "hidden";
|
|
53
|
+
|
|
54
|
+
const table = this.res;
|
|
55
|
+
const cols = Object.keys(this.datas[0]).length;
|
|
56
|
+
const rows = this.datas.length + 1;
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < cols; i++) {
|
|
59
|
+
table.rows[0].cells[i].style.borderTop = `${num * 2}px solid black`;
|
|
60
|
+
table.rows[rows - 1].cells[i].style.borderBottom = `${num * 2}px solid black`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
for (let i = 0; i < rows; i++) {
|
|
64
|
+
table.rows[i].cells[0].style.borderLeft = `${num * 2}px solid black`;
|
|
65
|
+
table.rows[i].cells[cols - 1].style.borderRight = `${num * 2}px solid black`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
table.rows[0].cells[0].style.borderTopLeftRadius = "10px";
|
|
69
|
+
table.rows[0].cells[cols - 1].style.borderTopRightRadius = "10px";
|
|
70
|
+
table.rows[rows - 1].cells[0].style.borderBottomLeftRadius = "10px";
|
|
71
|
+
table.rows[rows - 1].cells[cols - 1].style.borderBottomRightRadius = "10px";
|
|
72
|
+
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
cellPadding(padding) {
|
|
77
|
+
for (let row of this.res.rows) {
|
|
78
|
+
for (let cell of row.cells) {
|
|
79
|
+
cell.style.padding = padding;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
cellAlign(align) {
|
|
86
|
+
for (let row of this.res.rows) {
|
|
87
|
+
for (let cell of row.cells) {
|
|
88
|
+
cell.style.textAlign = align;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
headStyle(style) {
|
|
95
|
+
const row = this.res.rows[0];
|
|
96
|
+
if (row) {
|
|
97
|
+
row.style.color = style.color;
|
|
98
|
+
if (style.background) {
|
|
99
|
+
row.style.backgroundColor = style.background;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
border(borderStyle) {
|
|
106
|
+
this.res.style.borderCollapse = "collapse";
|
|
107
|
+
for (let row of this.res.rows) {
|
|
108
|
+
row.style.border = borderStyle;
|
|
109
|
+
for (let cell of row.cells) {
|
|
110
|
+
cell.style.border = borderStyle;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
generateTableHead(table, data) {
|
|
117
|
+
const thead = table.createTHead();
|
|
118
|
+
const row = thead.insertRow();
|
|
119
|
+
for (let key of data) {
|
|
120
|
+
const th = document.createElement("th");
|
|
121
|
+
const text = document.createTextNode(key);
|
|
122
|
+
th.appendChild(text);
|
|
123
|
+
row.appendChild(th);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
generateTable(table, data) {
|
|
128
|
+
for (let element of data) {
|
|
129
|
+
const row = table.insertRow();
|
|
130
|
+
for (let key in element) {
|
|
131
|
+
const cell = row.insertCell();
|
|
132
|
+
const text = document.createTextNode(element[key]);
|
|
133
|
+
cell.appendChild(text);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
render(div) {
|
|
139
|
+
if (div) {
|
|
140
|
+
const wrapper = document.createElement("div");
|
|
141
|
+
wrapper.style.overflowX = "auto";
|
|
142
|
+
wrapper.appendChild(this.res);
|
|
143
|
+
document.querySelector(div).appendChild(wrapper);
|
|
144
|
+
} else {
|
|
145
|
+
const wrapper = document.createElement("div");
|
|
146
|
+
wrapper.style.overflowX = "auto";
|
|
147
|
+
wrapper.appendChild(this.res);
|
|
148
|
+
return wrapper;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
export { Table };
|