slicejs-cli 1.0.45 → 1.0.47
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/PROJECT_TEMPLATES/Basic/Slice/Components/Service/FetchManager/FetchManager.js +109 -37
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Service/Translator/Translator.js +15 -15
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Service/Translator/messages.json +50 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/Controller/Controller.js +81 -83
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/Debugger/Debugger.css +47 -10
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/Debugger/Debugger.html +7 -3
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/Debugger/Debugger.js +114 -41
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/Logger/Logger.js +11 -11
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/StylesManager/StylesManager.js +32 -28
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Button/Button.css +44 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Button/Button.html +5 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Button/Button.js +39 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Card/Card.css +63 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Card/Card.html +7 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Card/Card.js +110 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Checkbox/Checkbox.css +87 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Checkbox/Checkbox.html +8 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Checkbox/Checkbox.js +87 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/CodeValidator/CodeValidator.css +97 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/CodeValidator/CodeValidator.html +18 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/CodeValidator/CodeValidator.js +86 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/Icon.css +505 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/Icon.html +1 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/Icon.js +95 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.eot +0 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.json +550 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.styl +502 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.svg +1470 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.symbol.svg +1035 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.ttf +0 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.woff +0 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.woff2 +0 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Input/Input.css +87 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Input/Input.html +4 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Input/Input.js +210 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Loading/Loading.css +56 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Loading/Loading.html +83 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Loading/Loading.js +39 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Navbar/Navbar.css +30 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Navbar/Navbar.html +6 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Navbar/Navbar.js +39 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Select/Select.css +91 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Select/Select.html +8 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Select/Select.js +210 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Switch/Switch.css +76 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Switch/Switch.html +8 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Switch/Switch.js +109 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester/Tester.css +34 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester/Tester.html +7 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester/Tester.js +33 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester2/Tester2.css +34 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester2/Tester2.html +43 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester2/Tester2.js +39 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/ToastAlert/ToastAlert.css +110 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/ToastAlert/ToastAlert.html +12 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/ToastAlert/ToastAlert.js +65 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/complexNavbar/complexNavbar.css +163 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/complexNavbar/complexNavbar.html +15 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/complexNavbar/complexNavbar.js +48 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/imageCarousel/img-carousel.css +56 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/imageCarousel/img-carousel.html +6 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/imageCarousel/img-carousel.js +119 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Components/components.js +22 -11
- package/PROJECT_TEMPLATES/Basic/Slice/Slice.js +169 -147
- package/PROJECT_TEMPLATES/Basic/Slice/Styles/sliceStyles.css +10 -0
- package/PROJECT_TEMPLATES/Basic/Slice/Themes/Dark.css +33 -9
- package/PROJECT_TEMPLATES/Basic/Slice/Themes/Light.css +27 -10
- package/PROJECT_TEMPLATES/Basic/Slice/Themes/Slice.css +27 -12
- package/PROJECT_TEMPLATES/Basic/Slice/package.json +12 -0
- package/PROJECT_TEMPLATES/Basic/Slice/sliceConfig.json +9 -1
- package/PROJECT_TEMPLATES/Basic/src/Views/LandingPage/index.html +9 -13
- package/PROJECT_TEMPLATES/Basic/src/Views/LandingPage/index.js +381 -9
- package/commands/createComponent/createComponent.js +4 -1
- package/commands/deleteComponent/deleteComponent.js +7 -1
- package/commands/listComponents/listComponents.js +12 -3
- package/package.json +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import sliceConfig from "../../../sliceConfig.json" assert { type: "json" };
|
|
2
2
|
|
|
3
3
|
export default class Debugger extends HTMLElement {
|
|
4
|
-
constructor(
|
|
4
|
+
constructor() {
|
|
5
5
|
super();
|
|
6
|
-
this.enabled = sliceConfig.debugger.enabled;
|
|
7
6
|
this.toggleClick = sliceConfig.debugger.click;
|
|
8
7
|
this.toggle = "click";
|
|
8
|
+
this.selectedComponentSliceId = null;
|
|
9
|
+
this.isActive = false;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
async enableDebugMode() {
|
|
@@ -16,9 +17,25 @@ export default class Debugger extends HTMLElement {
|
|
|
16
17
|
|
|
17
18
|
this.debuggerContainer = this.querySelector("#debugger-container");
|
|
18
19
|
this.closeDebugger = this.querySelector("#close-debugger");
|
|
19
|
-
this.
|
|
20
|
+
this.componentDetails = this.querySelector("#component-details");
|
|
21
|
+
this.componentDetailsTable = this.querySelector(".component-details-table");
|
|
22
|
+
this.componentDetailsList = this.querySelector(".component-details-list");
|
|
20
23
|
|
|
21
|
-
this.closeDebugger.addEventListener("click", () =>
|
|
24
|
+
this.closeDebugger.addEventListener("click", () => {
|
|
25
|
+
this.hideDebugger();
|
|
26
|
+
this.isActive = false;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
this.debuggerContainer.addEventListener("keypress", (event) => {
|
|
30
|
+
if (event.key === "Enter") {
|
|
31
|
+
this.applyChanges();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
this.applyChangesButton = await slice.build("Button", {
|
|
36
|
+
value: "Apply Changes",
|
|
37
|
+
onClickCallback: () => this.applyChanges(),
|
|
38
|
+
});
|
|
22
39
|
|
|
23
40
|
// Arrastrar y soltar
|
|
24
41
|
this.makeDraggable();
|
|
@@ -38,98 +55,100 @@ export default class Debugger extends HTMLElement {
|
|
|
38
55
|
);
|
|
39
56
|
}
|
|
40
57
|
|
|
41
|
-
// VISUAL
|
|
42
|
-
|
|
43
58
|
makeDraggable() {
|
|
44
|
-
let
|
|
59
|
+
let offset = {
|
|
60
|
+
x: 0,
|
|
61
|
+
y: 0,
|
|
62
|
+
};
|
|
45
63
|
let isDragging = false;
|
|
46
64
|
|
|
47
|
-
this.
|
|
65
|
+
const header = this.querySelector(".debugger-header");
|
|
66
|
+
|
|
67
|
+
header.addEventListener("mousedown", (event) => {
|
|
48
68
|
isDragging = true;
|
|
49
|
-
|
|
69
|
+
offset.x =
|
|
50
70
|
event.clientX - this.debuggerContainer.getBoundingClientRect().left;
|
|
51
|
-
|
|
71
|
+
offset.y =
|
|
52
72
|
event.clientY - this.debuggerContainer.getBoundingClientRect().top;
|
|
53
73
|
});
|
|
54
74
|
|
|
55
75
|
document.addEventListener("mousemove", (event) => {
|
|
56
76
|
if (isDragging) {
|
|
57
|
-
const x = event.clientX -
|
|
58
|
-
const y = event.clientY -
|
|
77
|
+
const x = event.clientX - offset.x;
|
|
78
|
+
const y = event.clientY - offset.y;
|
|
59
79
|
|
|
60
80
|
this.debuggerContainer.style.left = `${x}px`;
|
|
61
81
|
this.debuggerContainer.style.top = `${y}px`;
|
|
62
82
|
}
|
|
63
83
|
});
|
|
64
84
|
|
|
65
|
-
|
|
85
|
+
header.addEventListener("mouseup", () => {
|
|
66
86
|
isDragging = false;
|
|
67
87
|
});
|
|
68
88
|
}
|
|
69
89
|
|
|
70
90
|
handleDebugClick(event, component) {
|
|
71
91
|
event.preventDefault();
|
|
92
|
+
|
|
93
|
+
if (event.clientX > window.screen.width / 2) {
|
|
94
|
+
this.debuggerContainer.style.left = `calc(${event.clientX}px - 25%)`;
|
|
95
|
+
} else {
|
|
96
|
+
this.debuggerContainer.style.left = `${event.clientX}px`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (event.clientY > window.screen.height / 2) {
|
|
100
|
+
this.debuggerContainer.style.top = `calc(${event.clientY}px - 75%)`;
|
|
101
|
+
} else {
|
|
102
|
+
this.debuggerContainer.style.top = `${event.clientY}px`;
|
|
103
|
+
}
|
|
104
|
+
|
|
72
105
|
const sliceId = component.sliceId;
|
|
106
|
+
this.isActive = true;
|
|
73
107
|
|
|
74
108
|
const componentDetails = {
|
|
75
109
|
SliceId: sliceId,
|
|
76
110
|
ClassName: component.constructor.name,
|
|
77
|
-
|
|
111
|
+
ComponentProps: {},
|
|
78
112
|
};
|
|
113
|
+
this.selectedComponentSliceId = component.sliceId; // Almacena el sliceId del componente seleccionado
|
|
79
114
|
|
|
80
115
|
const realComponentProps = component.debuggerProps;
|
|
81
116
|
|
|
82
117
|
realComponentProps.forEach((attr) => {
|
|
83
|
-
//verify if the attr doesnt exist in the component, assign the value of _attr
|
|
84
118
|
if (component[attr] === undefined) {
|
|
85
|
-
componentDetails.
|
|
119
|
+
componentDetails.ComponentProps[attr] = component[`_${attr}`];
|
|
86
120
|
} else {
|
|
87
|
-
componentDetails.
|
|
121
|
+
componentDetails.ComponentProps[attr] = component[attr];
|
|
88
122
|
}
|
|
89
123
|
});
|
|
90
124
|
|
|
91
|
-
// Mostrar observedAttributes y sus valores
|
|
92
125
|
this.showComponentDetails(componentDetails);
|
|
93
126
|
}
|
|
94
127
|
|
|
95
128
|
showComponentDetails(details) {
|
|
96
129
|
this.componentDetailsList.innerHTML = "";
|
|
97
130
|
|
|
98
|
-
// Mostrar información general
|
|
99
131
|
Object.entries(details).forEach(([key, value]) => {
|
|
132
|
+
if (key === "ComponentProps") return;
|
|
100
133
|
const listItem = document.createElement("li");
|
|
101
134
|
listItem.textContent = `${key}: ${value}`;
|
|
102
135
|
this.componentDetailsList.appendChild(listItem);
|
|
103
136
|
});
|
|
104
137
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
details.ObservedAttributes
|
|
108
|
-
);
|
|
109
|
-
const observedAttributesWithoutValues = this.getAttributesWithoutValues(
|
|
110
|
-
details.ObservedAttributes
|
|
138
|
+
const ComponentPropsWithValues = this.getAttributesWithValues(
|
|
139
|
+
details.ComponentProps
|
|
111
140
|
);
|
|
112
141
|
|
|
113
|
-
if (
|
|
114
|
-
this.createTable(
|
|
115
|
-
"Attributes with Values",
|
|
116
|
-
observedAttributesWithValues,
|
|
117
|
-
details
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (observedAttributesWithoutValues.length > 0) {
|
|
122
|
-
this.createTable(
|
|
123
|
-
"Attributes without Values",
|
|
124
|
-
observedAttributesWithoutValues,
|
|
125
|
-
details
|
|
126
|
-
);
|
|
142
|
+
if (ComponentPropsWithValues.length > 0) {
|
|
143
|
+
this.createTable("", ComponentPropsWithValues, details);
|
|
127
144
|
}
|
|
128
145
|
|
|
129
146
|
this.debuggerContainer.classList.add("active");
|
|
147
|
+
this.debuggerContainer.appendChild(this.applyChangesButton); // Agregar el botón al debugger
|
|
130
148
|
}
|
|
131
149
|
|
|
132
150
|
createTable(title, attributes, details) {
|
|
151
|
+
this.componentDetailsTable.innerHTML = "";
|
|
133
152
|
const tableContainer = document.createElement("div");
|
|
134
153
|
tableContainer.classList.add("table-container");
|
|
135
154
|
|
|
@@ -140,6 +159,8 @@ export default class Debugger extends HTMLElement {
|
|
|
140
159
|
const table = document.createElement("table");
|
|
141
160
|
const thead = table.createTHead();
|
|
142
161
|
const tbody = table.createTBody();
|
|
162
|
+
thead.classList.add("slice_thead");
|
|
163
|
+
tbody.classList.add("slice_component-details");
|
|
143
164
|
|
|
144
165
|
const headerRow = thead.insertRow();
|
|
145
166
|
const headerCell1 = headerRow.insertCell(0);
|
|
@@ -154,11 +175,23 @@ export default class Debugger extends HTMLElement {
|
|
|
154
175
|
const cell2 = row.insertCell(1);
|
|
155
176
|
|
|
156
177
|
cell1.textContent = attr;
|
|
157
|
-
|
|
178
|
+
|
|
179
|
+
// Crear un elemento editable para la celda de valor
|
|
180
|
+
const valueInput = document.createElement("input");
|
|
181
|
+
valueInput.value = details.ComponentProps[attr]; // Asignar el valor actual
|
|
182
|
+
if (typeof details.ComponentProps[attr] === "function") {
|
|
183
|
+
valueInput.disabled = true;
|
|
184
|
+
}
|
|
185
|
+
cell2.appendChild(valueInput);
|
|
186
|
+
|
|
187
|
+
// Agregar evento de doble clic para permitir la edición
|
|
188
|
+
cell2.addEventListener("dblclick", () => {
|
|
189
|
+
valueInput.readOnly = false;
|
|
190
|
+
});
|
|
158
191
|
});
|
|
159
192
|
|
|
160
193
|
tableContainer.appendChild(table);
|
|
161
|
-
this.
|
|
194
|
+
this.componentDetailsTable.appendChild(tableContainer);
|
|
162
195
|
}
|
|
163
196
|
|
|
164
197
|
getAttributesWithValues(attributes) {
|
|
@@ -169,6 +202,46 @@ export default class Debugger extends HTMLElement {
|
|
|
169
202
|
return Object.keys(attributes).filter((attr) => attributes[attr] === null);
|
|
170
203
|
}
|
|
171
204
|
|
|
205
|
+
applyChanges() {
|
|
206
|
+
const inputCells = this.componentDetailsTable.querySelectorAll("td input");
|
|
207
|
+
const selectedComponent = slice.controller.getComponent(
|
|
208
|
+
this.selectedComponentSliceId
|
|
209
|
+
);
|
|
210
|
+
inputCells.forEach((inputCell) => {
|
|
211
|
+
const attributeName =
|
|
212
|
+
inputCell.parentElement.previousElementSibling.textContent;
|
|
213
|
+
let newValue = inputCell.value;
|
|
214
|
+
const oldValue = slice.controller.getComponent(
|
|
215
|
+
this.selectedComponentSliceId
|
|
216
|
+
)[attributeName];
|
|
217
|
+
|
|
218
|
+
// Verificar si el valor anterior y el nuevo valor son iguales como cadenas
|
|
219
|
+
if (String(newValue) !== String(oldValue)) {
|
|
220
|
+
//Verificar si es funcion para que no lo vuelva a guardar sin cambios
|
|
221
|
+
/*
|
|
222
|
+
if (typeof selectedComponent[attributeName] === 'function') {
|
|
223
|
+
try {
|
|
224
|
+
newValue = eval(`(${newValue})`);
|
|
225
|
+
} catch (error) {
|
|
226
|
+
console.error(`Error al analizar la función: ${error}`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
*/
|
|
231
|
+
if (typeof selectedComponent[attributeName] === "function") {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
console.log(
|
|
235
|
+
`Changing ${attributeName} from ${oldValue} to ${newValue}`
|
|
236
|
+
);
|
|
237
|
+
if (newValue === "true") newValue = true;
|
|
238
|
+
if (newValue === "false") newValue = false;
|
|
239
|
+
|
|
240
|
+
selectedComponent[attributeName] = newValue;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
172
245
|
hideDebugger() {
|
|
173
246
|
this.debuggerContainer.classList.remove("active");
|
|
174
247
|
}
|
|
@@ -7,12 +7,12 @@ export default class Logger {
|
|
|
7
7
|
this.logs = [];
|
|
8
8
|
this.logEnabled = sliceConfig.logger.enabled;
|
|
9
9
|
this.showLogsConfig = sliceConfig.logger.showLogs;
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
this.showLog = function showLog(log) {
|
|
12
12
|
if (!this.showLogsConfig) return;
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
const logType = log.logType;
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
Object.keys(this.showLogsConfig).forEach(logConfig => {
|
|
17
17
|
if (this.showLogsConfig[logConfig][logType] === true) {
|
|
18
18
|
switch (logConfig) {
|
|
@@ -38,7 +38,7 @@ export default class Logger {
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -47,14 +47,14 @@ export default class Logger {
|
|
|
47
47
|
let componentName;
|
|
48
48
|
|
|
49
49
|
try {
|
|
50
|
-
|
|
50
|
+
componentName = slice.controller.activeComponents.get(componentSliceId).constructor.name
|
|
51
51
|
} catch (error) {
|
|
52
|
-
|
|
52
|
+
componentName = componentSliceId;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
let componentCategory = slice.controller.getComponentCategory(componentName);
|
|
57
|
-
if(componentSliceId === "Slice") componentCategory = "Structural"
|
|
57
|
+
if (componentSliceId === "Slice") componentCategory = "Structural"
|
|
58
58
|
const log = new Log(logType, componentCategory, componentSliceId, message, error);
|
|
59
59
|
this.logs.push(log);
|
|
60
60
|
this.showLog(log);
|
|
@@ -82,11 +82,11 @@ export default class Logger {
|
|
|
82
82
|
this.logs = [];
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
getLogsByLogType(type) {
|
|
86
86
|
return this.logs.filter(log => log.logType === type);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
getLogsByComponentCategory(componentCategory) {
|
|
90
90
|
return this.logs.filter(log => log.componentCategory === componentCategory);
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -94,7 +94,7 @@ export default class Logger {
|
|
|
94
94
|
return this.logs.filter(log => log.componentSliceId === componentSliceId);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
}
|
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
import CustomStylesManager from "./CustomStylesManager/CustomStylesManager.js"
|
|
2
|
-
import ThemeManager from "./ThemeManager/ThemeManager.js"
|
|
1
|
+
import CustomStylesManager from "./CustomStylesManager/CustomStylesManager.js";
|
|
2
|
+
import ThemeManager from "./ThemeManager/ThemeManager.js";
|
|
3
3
|
|
|
4
4
|
export default class StylesManager {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.customStylesManager = new CustomStylesManager();
|
|
11
|
-
this.themeManager = new ThemeManager();
|
|
12
|
-
}
|
|
5
|
+
constructor() {
|
|
6
|
+
this.componentStyles = document.createElement("style");
|
|
7
|
+
this.componentStyles.id = "slice-component-styles";
|
|
8
|
+
document.head.appendChild(this.componentStyles);
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
setTheme(themeName){
|
|
21
|
-
this.themeManager.applyTheme(themeName);
|
|
22
|
-
}
|
|
10
|
+
this.customStylesManager = new CustomStylesManager();
|
|
11
|
+
this.themeManager = new ThemeManager();
|
|
12
|
+
}
|
|
23
13
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
async init() {
|
|
15
|
+
const sliceStyles = await slice.controller.fetchText(
|
|
16
|
+
"sliceStyles",
|
|
17
|
+
"styles"
|
|
18
|
+
);
|
|
19
|
+
this.componentStyles.innerText += sliceStyles;
|
|
20
|
+
slice.logger.logInfo("StylesManager", "sliceStyles loaded");
|
|
21
|
+
}
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.
|
|
23
|
+
handleInstanceStyles(instance, props) {
|
|
24
|
+
if (props.customCSS) {
|
|
25
|
+
this.customStylesManager.proccess(instance, props);
|
|
32
26
|
}
|
|
27
|
+
}
|
|
33
28
|
|
|
29
|
+
setTheme(themeName) {
|
|
30
|
+
this.themeManager.applyTheme(themeName);
|
|
31
|
+
}
|
|
34
32
|
|
|
33
|
+
//add a method that will add css as text to the componentStyles element
|
|
34
|
+
appendComponentStyles(cssText) {
|
|
35
|
+
this.componentStyles.appendChild(document.createTextNode(cssText));
|
|
36
|
+
}
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
registerComponentStyles(componentName, cssText) {
|
|
39
|
+
slice.controller.requestedStyles.add(componentName);
|
|
40
|
+
this.appendComponentStyles(cssText);
|
|
37
41
|
}
|
|
38
|
-
|
|
42
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.slice_button_container {
|
|
2
|
+
padding: 10px;
|
|
3
|
+
}
|
|
4
|
+
.slice_button_value {
|
|
5
|
+
user-select: none;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
}
|
|
8
|
+
.slice_button {
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
position: relative;
|
|
12
|
+
max-width: fit-content;
|
|
13
|
+
background-color: var(--primary-color);
|
|
14
|
+
color: var(--primary-color-contrast);
|
|
15
|
+
border-radius: var(--border-radius-slice);
|
|
16
|
+
border: var(--slice-border) solid var(--primary-color);
|
|
17
|
+
font-weight: 800;
|
|
18
|
+
min-width: 100%;
|
|
19
|
+
padding: 10px 0;
|
|
20
|
+
-webkit-transition-duration: 0.4s; /* Safari */
|
|
21
|
+
transition-duration: 0.4s;
|
|
22
|
+
}
|
|
23
|
+
.slice_button:after {
|
|
24
|
+
content: "";
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
border-radius: 100%;
|
|
28
|
+
background: #ffffff50;
|
|
29
|
+
position: absolute;
|
|
30
|
+
display: block;
|
|
31
|
+
opacity: 0;
|
|
32
|
+
scale: 10;
|
|
33
|
+
transition: all 1s;
|
|
34
|
+
}
|
|
35
|
+
.slice_button:active {
|
|
36
|
+
transform: translateY(5px);
|
|
37
|
+
}
|
|
38
|
+
.slice_button:active:after {
|
|
39
|
+
scale: 0;
|
|
40
|
+
padding: 0;
|
|
41
|
+
margin: 0;
|
|
42
|
+
opacity: 1;
|
|
43
|
+
transition: 0s;
|
|
44
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default class Button extends HTMLElement {
|
|
2
|
+
constructor(props) {
|
|
3
|
+
super();
|
|
4
|
+
slice.attachTemplate(this);
|
|
5
|
+
this.$value = this.querySelector(".slice_button_value");
|
|
6
|
+
this.$button = this.querySelector(".slice_button");
|
|
7
|
+
if (props.onClickCallback) {
|
|
8
|
+
this.onClickCallback = props.onClickCallback;
|
|
9
|
+
this.$button.addEventListener("click", () => this.onClickCallback());
|
|
10
|
+
//revisar esta verga por si habria q deletear o no
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
slice.controller.setComponentProps(this, props);
|
|
14
|
+
this.debuggerProps = ["value", "onClickCallback", "customColor"];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get value() {
|
|
18
|
+
return this._value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
set value(value) {
|
|
22
|
+
this._value = value;
|
|
23
|
+
this.$value.textContent = value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get customColor() {
|
|
27
|
+
return this._customColor;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
set customColor(value) {
|
|
31
|
+
this._customColor = value;
|
|
32
|
+
this.$button.style = `--primary-color: ${value};`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
handleButtonClick() {
|
|
36
|
+
this.onClickCallback();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
window.customElements.define("slice-button", Button);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
.title {
|
|
2
|
+
font-size: 20px;
|
|
3
|
+
font-weight: bold;
|
|
4
|
+
color: var(--font-primary-color);
|
|
5
|
+
text-align: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.slice-card {
|
|
9
|
+
width: 300px;
|
|
10
|
+
position: relative;
|
|
11
|
+
font-family: var(--font-family);
|
|
12
|
+
transition: all 300ms;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.slice-card:hover {
|
|
16
|
+
.card_cover {
|
|
17
|
+
transform: translateY(-90%);
|
|
18
|
+
box-shadow: 0px 10px 10px #00000050;
|
|
19
|
+
}
|
|
20
|
+
.card_info {
|
|
21
|
+
/* transform: translateY(20%); */
|
|
22
|
+
box-shadow: 0px -10px 10px #00000050;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.card_cover {
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 220px;
|
|
29
|
+
background: var(--primary-color);
|
|
30
|
+
display: flex;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
align-items: center;
|
|
33
|
+
position: absolute;
|
|
34
|
+
z-index: 1;
|
|
35
|
+
transition: all 400ms ease;
|
|
36
|
+
border-radius: var(--border-radius-slice);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.card_info {
|
|
40
|
+
width: 100%;
|
|
41
|
+
margin-top: 20px;
|
|
42
|
+
height: 220px;
|
|
43
|
+
color: var(--font-secondary-color);
|
|
44
|
+
background: var(--secondary-background-color);
|
|
45
|
+
position: absolute;
|
|
46
|
+
font-size: 20px;
|
|
47
|
+
transition: all 400ms cubic-bezier(0.5, 0, 0, 1);
|
|
48
|
+
border-radius: var(--border-radius-slice);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.card_info p {
|
|
52
|
+
padding: 0px 20px 20px 20px;
|
|
53
|
+
font-size: 20px;
|
|
54
|
+
display: -webkit-box;
|
|
55
|
+
display: -moz-box;
|
|
56
|
+
display: box;
|
|
57
|
+
-webkit-box-orient: vertical;
|
|
58
|
+
-moz-box-orient: vertical;
|
|
59
|
+
box-orient: vertical;
|
|
60
|
+
-webkit-line-clamp: 5;
|
|
61
|
+
line-clamp: 5;
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export default class Card extends HTMLElement {
|
|
2
|
+
constructor(props) {
|
|
3
|
+
super();
|
|
4
|
+
slice.attachTemplate(this);
|
|
5
|
+
this.$card = this.querySelector(".slice-card");
|
|
6
|
+
this.$title = this.querySelector(".title");
|
|
7
|
+
this.$text = this.querySelector(".text");
|
|
8
|
+
this.$cover = this.querySelector(".card_cover");
|
|
9
|
+
slice.controller.setComponentProps(this, props);
|
|
10
|
+
|
|
11
|
+
this.$card.addEventListener("click", () => {
|
|
12
|
+
this.isOpen = !this.isOpen;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
this.$card.addEventListener("mouseover", () => {
|
|
16
|
+
this.$cover.style.backgroundColor = this.$color.icon;
|
|
17
|
+
this.$icon.color = this.$color.card;
|
|
18
|
+
});
|
|
19
|
+
this.$card.addEventListener("mouseout", () => {
|
|
20
|
+
this.$cover.style.backgroundColor = this.$color.card;
|
|
21
|
+
this.$icon.color = this.$color.icon;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
this.debuggerProps = ["title", "text", "icon", "customColor", "isOpen"];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async init() {
|
|
28
|
+
if (this.isOpen === undefined) {
|
|
29
|
+
this.isOpen = false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!this.customColor) {
|
|
33
|
+
this.$color = {
|
|
34
|
+
icon: "var(--primary-color-contrast)",
|
|
35
|
+
card: "var(--primary-color)",
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!this._icon) {
|
|
40
|
+
this.icon.name = "youtube";
|
|
41
|
+
this.icon.iconStyle = "filled";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this.$icon = await slice.build("Icon", {
|
|
45
|
+
name: this.icon.name,
|
|
46
|
+
size: "150px",
|
|
47
|
+
color: this.$color.icon,
|
|
48
|
+
iconStyle: this._icon.iconStyle,
|
|
49
|
+
});
|
|
50
|
+
this.$cover.appendChild(this.$icon);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get title() {
|
|
54
|
+
return this._title;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
set title(value) {
|
|
58
|
+
this._title = value;
|
|
59
|
+
this.$title.textContent = value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get text() {
|
|
63
|
+
return this._text;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
set text(value) {
|
|
67
|
+
this._text = value;
|
|
68
|
+
this.$text.textContent = value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get icon() {
|
|
72
|
+
return this._icon;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
set icon(value) {
|
|
76
|
+
this._icon = value;
|
|
77
|
+
if (!this.$icon) return;
|
|
78
|
+
this.$icon.name = value.name;
|
|
79
|
+
this.$icon.iconStyle = value.iconStyle;
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get isOpen() {
|
|
85
|
+
return this._isOpen;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
set isOpen(boolean) {
|
|
89
|
+
this._isOpen = boolean;
|
|
90
|
+
if (boolean) {
|
|
91
|
+
this.$cover.style.zIndex = 0;
|
|
92
|
+
} else {
|
|
93
|
+
this.$cover.style.zIndex = 1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
get customColor() {
|
|
98
|
+
return this._customColor;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
set customColor(value) {
|
|
102
|
+
this._customColor = value;
|
|
103
|
+
this.$color = value;
|
|
104
|
+
if (value.card) {
|
|
105
|
+
this.$cover.style.backgroundColor = value.card;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
customElements.define("slice-card", Card);
|