@gudhub/ssg-web-components-library 1.0.83 → 1.0.84
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/package.json
CHANGED
|
@@ -10,6 +10,7 @@ class AiImageGenerator extends GHComponent {
|
|
|
10
10
|
this.imageBefore = this.querySelector('ai-image-compare.generated img#image-before');
|
|
11
11
|
this.imageAfter = this.querySelector('ai-image-compare.generated img#image-after');
|
|
12
12
|
this.placeholderImage = this.querySelector('.result img#placeholder');
|
|
13
|
+
this.actionButtons = this.querySelectorAll('.images-wrapper .btn');
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
async onServerRender() {
|
|
@@ -35,6 +36,7 @@ class AiImageGenerator extends GHComponent {
|
|
|
35
36
|
});
|
|
36
37
|
|
|
37
38
|
fileInput.addEventListener("change", async () => {
|
|
39
|
+
this.toggleButtonsVision('hide');
|
|
38
40
|
this.startContainer.classList.add("hidden");
|
|
39
41
|
this.resultContainer.classList.remove("hidden");
|
|
40
42
|
this.imageBefore.src = '';
|
|
@@ -42,16 +44,18 @@ class AiImageGenerator extends GHComponent {
|
|
|
42
44
|
const file = fileInput.files[0];
|
|
43
45
|
if (!file) return;
|
|
44
46
|
this.imageBefore.src = this.createBlobImageElement(file);
|
|
47
|
+
this.imageCompareGenerated.classList.add("hidden");
|
|
48
|
+
this.placeholderImage.classList.remove("hidden");
|
|
45
49
|
this.placeholderImage.src = this.createBlobImageElement(file);
|
|
46
50
|
|
|
47
51
|
this.lastFile = file;
|
|
48
52
|
const promptText = document.getElementById("prompt").value;
|
|
49
|
-
|
|
53
|
+
|
|
50
54
|
await this.sendToServer(file, promptText);
|
|
51
|
-
|
|
55
|
+
|
|
52
56
|
this.placeholderImage.classList.add("hidden");
|
|
53
57
|
this.imageCompareGenerated.classList.remove("hidden");
|
|
54
|
-
|
|
58
|
+
this.toggleButtonsVision('show');
|
|
55
59
|
});
|
|
56
60
|
|
|
57
61
|
regenerateBtn.addEventListener("click", async () => {
|
|
@@ -59,9 +63,11 @@ class AiImageGenerator extends GHComponent {
|
|
|
59
63
|
console.warn("No image has been uploaded yet.");
|
|
60
64
|
return;
|
|
61
65
|
}
|
|
62
|
-
|
|
66
|
+
|
|
67
|
+
this.toggleButtonsVision('hide');
|
|
63
68
|
const promptText = document.getElementById("prompt").value;
|
|
64
69
|
await this.sendToServer(this.lastFile, promptText);
|
|
70
|
+
this.toggleButtonsVision('show');
|
|
65
71
|
});
|
|
66
72
|
}
|
|
67
73
|
|
|
@@ -106,7 +112,7 @@ class AiImageGenerator extends GHComponent {
|
|
|
106
112
|
loader.classList.add("hidden");
|
|
107
113
|
}
|
|
108
114
|
}
|
|
109
|
-
|
|
115
|
+
|
|
110
116
|
downloadLatestBlobImage() {
|
|
111
117
|
const imageAfter = document.getElementById("image-after");
|
|
112
118
|
const imgElement = imageAfter.querySelector("img");
|
|
@@ -134,10 +140,15 @@ class AiImageGenerator extends GHComponent {
|
|
|
134
140
|
console.error("Failed to download image:", err);
|
|
135
141
|
});
|
|
136
142
|
}
|
|
137
|
-
|
|
143
|
+
|
|
138
144
|
createBlobImageElement(blob) {
|
|
139
145
|
return URL.createObjectURL(blob);
|
|
140
146
|
}
|
|
147
|
+
|
|
148
|
+
toggleButtonsVision(vision) {
|
|
149
|
+
this.actionButtons.forEach(btn => btn.classList.toggle('hidden', vision === 'hide'));
|
|
150
|
+
this.actionButtons.forEach(btn => console.log(btn.classList));
|
|
151
|
+
}
|
|
141
152
|
}
|
|
142
153
|
|
|
143
154
|
window.customElements.define('ai-image-generator', AiImageGenerator);
|
|
@@ -25,8 +25,6 @@ ai-image-generator {
|
|
|
25
25
|
img.placeholder-image {
|
|
26
26
|
width: 100%;
|
|
27
27
|
height: 100%;
|
|
28
|
-
max-width: 1058px;
|
|
29
|
-
max-height: 566px;
|
|
30
28
|
filter: blur(5px);
|
|
31
29
|
}
|
|
32
30
|
|
|
@@ -183,7 +181,7 @@ ai-image-generator {
|
|
|
183
181
|
}
|
|
184
182
|
|
|
185
183
|
.hidden {
|
|
186
|
-
display: none;
|
|
184
|
+
display: none !important;
|
|
187
185
|
}
|
|
188
186
|
|
|
189
187
|
@keyframes spin {
|