@wewear/virtual-try-on 1.4.2 → 1.4.3

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/index.js CHANGED
@@ -25,37 +25,35 @@
25
25
  if (!document.getElementById(styleId)) {
26
26
  const styles = document.createElement("style");
27
27
  styles.id = styleId;
28
- styles.innerHTML = `
29
- .${CSS_CLASSES.PREVIEW_BADGE} {
30
- position: absolute;
31
- top: 16px;
32
- right: 16px;
33
- background-color: rgba(0, 0, 0, 0.6);
34
- color: white;
35
- padding: 4px 8px;
36
- border-radius: 4px;
37
- font-size: 12px;
38
- font-weight: 600;
39
- z-index: 10;
40
- animation: ww-vto-pulse 2s infinite;
41
- pointer-events: none;
42
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
43
- }
44
-
45
- @keyframes ww-vto-pulse {
46
- 0% {
47
- transform: scale(1);
48
- opacity: 0.9;
49
- }
50
- 50% {
51
- transform: scale(1.05);
52
- opacity: 1;
53
- }
54
- 100% {
55
- transform: scale(1);
56
- opacity: 0.9;
57
- }
58
- }
28
+ styles.innerHTML = `
29
+ .${CSS_CLASSES.PREVIEW_BADGE} {
30
+ position: absolute;
31
+ top: 20px;
32
+ right: 20px;
33
+ background: rgba(31, 41, 55, 0.9);
34
+ backdrop-filter: blur(4px);
35
+ -webkit-backdrop-filter: blur(4px);
36
+ color: white;
37
+ padding: 6px 14px;
38
+ border-radius: 6px;
39
+ font-size: 12px;
40
+ font-weight: 600;
41
+ letter-spacing: 0.5px;
42
+ z-index: 10;
43
+ pointer-events: none;
44
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
45
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
46
+ animation: ww-vto-pulse 2s ease-in-out infinite;
47
+ }
48
+
49
+ @keyframes ww-vto-pulse {
50
+ 0%, 100% {
51
+ opacity: 0.9;
52
+ }
53
+ 50% {
54
+ opacity: 1;
55
+ }
56
+ }
59
57
  `;
60
58
  document.head.appendChild(styles);
61
59
  }
@@ -85,39 +83,43 @@
85
83
  const container = document.createElement("div");
86
84
  container.className = `${CSS_CLASSES.BUTTON_CONTAINER} ww-button-group`;
87
85
  const positionStyles = getPositionStyles(buttonPosition);
88
- container.style.cssText = `
89
- position: absolute;
90
- ${positionStyles}
91
- display: flex;
92
- border-radius: 9999px;
93
- background: white;
94
- padding: 4px;
95
- box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
96
- z-index: ${Z_INDEX.BUTTON};
86
+ container.style.cssText = `
87
+ position: absolute;
88
+ ${positionStyles}
89
+ display: flex;
90
+ gap: 4px;
91
+ border-radius: 100px;
92
+ background: white;
93
+ padding: 4px;
94
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
95
+ z-index: ${Z_INDEX.BUTTON};
96
+ transition: all 0.2s ease;
97
97
  `;
98
98
  // Camera button
99
99
  const cameraButton = document.createElement("button");
100
100
  cameraButton.type = "button";
101
101
  cameraButton.className = `${CSS_CLASSES.BUTTON} ww-camera-btn`;
102
102
  cameraButton.setAttribute("aria-label", "Virtual Try-On");
103
- cameraButton.style.cssText = `
104
- display: flex;
105
- width: 36px;
106
- height: 36px;
107
- cursor: pointer;
108
- align-items: center;
109
- justify-content: center;
110
- border-radius: 9999px;
111
- padding: 8px;
112
- border: none;
113
- background: transparent;
114
- color: currentColor;
103
+ cameraButton.style.cssText = `
104
+ display: flex;
105
+ width: 40px;
106
+ height: 40px;
107
+ cursor: pointer;
108
+ align-items: center;
109
+ justify-content: center;
110
+ border-radius: 100px;
111
+ padding: 0;
112
+ border: none;
113
+ background: white;
114
+ color: #000000;
115
+ transition: all 0.2s ease;
116
+ flex-shrink: 0;
115
117
  `;
116
- cameraButton.innerHTML = `
117
- <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-camera">
118
- <path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"></path>
119
- <circle cx="12" cy="13" r="3"></circle>
120
- </svg>
118
+ cameraButton.innerHTML = `
119
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: block;">
120
+ <path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"></path>
121
+ <circle cx="12" cy="13" r="3"></circle>
122
+ </svg>
121
123
  `;
122
124
  cameraButton.onclick = onCameraClick;
123
125
  container.appendChild(cameraButton);
@@ -129,27 +131,30 @@
129
131
  refreshButton.type = "button";
130
132
  refreshButton.className = "ww-refresh-btn";
131
133
  refreshButton.setAttribute("aria-label", "Refresh virtual try-on");
132
- refreshButton.style.cssText = `
133
- display: flex;
134
- width: 36px;
135
- height: 36px;
136
- cursor: pointer;
137
- align-items: center;
138
- justify-content: center;
139
- border-radius: 9999px;
140
- padding: 8px;
141
- border: none;
142
- background: transparent;
143
- color: currentColor;
134
+ refreshButton.style.cssText = `
135
+ display: flex;
136
+ width: 40px;
137
+ height: 40px;
138
+ cursor: pointer;
139
+ align-items: center;
140
+ justify-content: center;
141
+ border-radius: 100px;
142
+ padding: 0;
143
+ border: none;
144
+ background: white;
145
+ color: #333333;
146
+ transition: all 0.2s ease;
147
+ flex-shrink: 0;
144
148
  `;
145
- refreshButton.innerHTML = `
146
- <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-refresh-ccw">
147
- <path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"></path>
148
- <path d="M3 3v5h5"></path>
149
- <path d="M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"></path>
150
- <path d="M16 16h5v5"></path>
151
- </svg>
149
+ refreshButton.innerHTML = `
150
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: block;">
151
+ <path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"></path>
152
+ <path d="M3 3v5h5"></path>
153
+ <path d="M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"></path>
154
+ <path d="M16 16h5v5"></path>
155
+ </svg>
152
156
  `;
157
+ refreshButton.onclick = onRefreshClick;
153
158
  refreshButton.onclick = onRefreshClick;
154
159
  container.appendChild(refreshButton);
155
160
  }
@@ -159,30 +164,48 @@
159
164
  toggleButton.type = "button";
160
165
  toggleButton.className = "ww-toggle-btn";
161
166
  toggleButton.setAttribute("aria-label", isShowingVirtualTryOn ? "Show Original Image" : "Show Virtual Try-On");
162
- toggleButton.style.cssText = `
163
- display: flex;
164
- width: 36px;
165
- height: 36px;
166
- cursor: pointer;
167
- align-items: center;
168
- justify-content: center;
169
- border-radius: 9999px;
170
- padding: 8px;
171
- border: none;
172
- background: ${isShowingVirtualTryOn ? "rgba(0, 0, 0)" : "none"};
173
- color: ${isShowingVirtualTryOn ? "white" : "currentColor"};
167
+ toggleButton.style.cssText = `
168
+ display: flex;
169
+ width: 40px;
170
+ height: 40px;
171
+ cursor: pointer;
172
+ align-items: center;
173
+ justify-content: center;
174
+ border-radius: 100px;
175
+ padding: 0;
176
+ border: none;
177
+ background: ${isShowingVirtualTryOn ? "#333333" : "#e5e7eb"};
178
+ color: ${isShowingVirtualTryOn ? "white" : "#333333"};
179
+ transition: all 0.2s ease;
180
+ flex-shrink: 0;
174
181
  `;
175
- toggleButton.innerHTML = `
176
- <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scan-face">
177
- <path d="M3 7V5a2 2 0 0 1 2-2h2"></path>
178
- <path d="M17 3h2a2 2 0 0 1 2 2v2"></path>
179
- <path d="M21 17v2a2 2 0 0 1-2 2h-2"></path>
180
- <path d="M7 21H5a2 2 0 0 1-2-2v-2"></path>
181
- <path d="M8 14s1.5 2 4 2 4-2 4-2"></path>
182
- <path d="M9 9h.01"></path>
183
- <path d="M15 9h.01"></path>
184
- </svg>
182
+ toggleButton.innerHTML = `
183
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: block;">
184
+ <path d="M3 7V5a2 2 0 0 1 2-2h2"></path>
185
+ <path d="M17 3h2a2 2 0 0 1 2 2v2"></path>
186
+ <path d="M21 17v2a2 2 0 0 1-2 2h-2"></path>
187
+ <path d="M7 21H5a2 2 0 0 1-2-2v-2"></path>
188
+ <path d="M8 14s1.5 2 4 2 4-2 4-2"></path>
189
+ <path d="M9 9h.01"></path>
190
+ <path d="M15 9h.01"></path>
191
+ </svg>
185
192
  `;
193
+ toggleButton.onmouseover = () => {
194
+ if (isShowingVirtualTryOn) {
195
+ toggleButton.style.background = "#4a4a4a";
196
+ }
197
+ else {
198
+ toggleButton.style.background = "#d1d5db";
199
+ }
200
+ };
201
+ toggleButton.onmouseout = () => {
202
+ if (isShowingVirtualTryOn) {
203
+ toggleButton.style.background = "#333333";
204
+ }
205
+ else {
206
+ toggleButton.style.background = "#e5e7eb";
207
+ }
208
+ };
186
209
  toggleButton.onclick = onToggleClick;
187
210
  container.appendChild(toggleButton);
188
211
  }
@@ -209,49 +232,98 @@
209
232
  function createLoadingOverlay(text = "Processing...") {
210
233
  const overlay = document.createElement("div");
211
234
  overlay.className = "ww-loading-overlay";
212
- overlay.style.cssText = `
213
- position: absolute;
214
- top: 0;
215
- left: 0;
216
- width: 100%;
217
- height: 100%;
218
- background-color: rgba(0, 0, 0, 0.8);
219
- display: flex;
220
- flex-direction: column;
221
- align-items: center;
222
- justify-content: center;
223
- z-index: ${Z_INDEX.MODAL + 1};
224
- border-radius: inherit;
235
+ overlay.style.cssText = `
236
+ position: absolute;
237
+ top: 0;
238
+ left: 0;
239
+ width: 100%;
240
+ height: 100%;
241
+ background: linear-gradient(135deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.88) 100%);
242
+ backdrop-filter: blur(8px);
243
+ -webkit-backdrop-filter: blur(8px);
244
+ display: flex;
245
+ flex-direction: column;
246
+ align-items: center;
247
+ justify-content: center;
248
+ z-index: ${Z_INDEX.MODAL + 1};
249
+ border-radius: inherit;
250
+ animation: ww-fade-in 0.3s ease;
225
251
  `;
226
252
  // Add CSS animation to the document if not already added
227
253
  if (!document.getElementById("ww-loading-animation")) {
228
254
  const style = document.createElement("style");
229
255
  style.id = "ww-loading-animation";
230
- style.textContent = `
231
- @keyframes ww-pulse {
232
- 0%, 100% { opacity: 0.7; transform: scale(1); }
233
- 50% { opacity: 1; transform: scale(1.05); }
234
- }
235
- .ww-loading-overlay .ww-logo {
236
- animation: ww-pulse 2s ease-in-out infinite;
237
- }
256
+ style.textContent = `
257
+ @keyframes ww-fade-in {
258
+ from { opacity: 0; }
259
+ to { opacity: 1; }
260
+ }
261
+
262
+ @keyframes ww-pulse-logo {
263
+ 0%, 100% {
264
+ opacity: 0.8;
265
+ transform: scale(1);
266
+ }
267
+ 50% {
268
+ opacity: 1;
269
+ transform: scale(1.05);
270
+ }
271
+ }
272
+
273
+ @keyframes ww-spinner-rotate {
274
+ 0% { transform: rotate(0deg); }
275
+ 100% { transform: rotate(360deg); }
276
+ }
277
+
278
+ @keyframes ww-dot-bounce {
279
+ 0%, 80%, 100% {
280
+ transform: scale(0);
281
+ opacity: 0.5;
282
+ }
283
+ 40% {
284
+ transform: scale(1);
285
+ opacity: 1;
286
+ }
287
+ }
288
+
289
+ .ww-loading-logo {
290
+ animation: ww-pulse-logo 2s ease-in-out infinite;
291
+ }
292
+
293
+ .ww-loading-spinner {
294
+ animation: ww-spinner-rotate 1s linear infinite;
295
+ }
238
296
  `;
239
297
  document.head.appendChild(style);
240
298
  }
241
- overlay.innerHTML = `
242
- <div style="display: flex; flex-direction: column; align-items: center; gap: 24px; color: white;">
243
- <svg class="ww-logo" width="80" height="50" viewBox="0 0 214 135" fill="none" xmlns="http://www.w3.org/2000/svg">
244
- <g clip-path="url(#clip0_3624_12755)">
245
- <path d="M102.906 74.8679C102.906 77.9717 101.574 80.7453 98.9104 83.1887C96.6871 85.1918 93.9025 86.6997 90.5566 87.7123C87.695 88.5708 84.6462 89 81.4104 89C73.8821 89 68.0047 87.0189 63.7783 83.0566C59.5519 87.0189 53.6855 89 46.1792 89C42.9434 89 39.9057 88.5708 37.066 87.7123C33.7201 86.6997 30.9245 85.1918 28.6792 83.1887C26.0157 80.7453 24.684 77.9717 24.684 74.8679V41.6509H32.3774V74.8679C32.3774 76.2547 33.489 77.5645 35.7123 78.7972C37.3632 79.7217 39.0692 80.3711 40.8302 80.7453C42.5252 81.1195 44.3082 81.3066 46.1792 81.3066C48.0063 81.3066 49.7673 81.1195 51.4623 80.7453C53.2453 80.3711 54.9623 79.7217 56.6132 78.7972C58.8585 77.5645 59.9811 76.2547 59.9811 74.8679V41.6509H67.6085V74.8679C67.6085 76.2547 68.7311 77.5645 70.9764 78.7972C72.6274 79.7217 74.3443 80.3711 76.1274 80.7453C77.8223 81.1195 79.5833 81.3066 81.4104 81.3066C83.2814 81.3066 85.0755 81.1195 86.7925 80.7453C88.5314 80.3711 90.2264 79.7217 91.8774 78.7972C94.1006 77.5645 95.2123 76.2547 95.2123 74.8679V41.6509H102.906V74.8679ZM189.283 74.8679C189.283 77.9717 187.951 80.7453 185.288 83.1887C183.064 85.1918 180.28 86.6997 176.934 87.7123C174.072 88.5708 171.024 89 167.788 89C160.259 89 154.382 87.0189 150.156 83.0566C145.929 87.0189 140.063 89 132.557 89C129.321 89 126.283 88.5708 123.443 87.7123C120.097 86.6997 117.302 85.1918 115.057 83.1887C112.393 80.7453 111.061 77.9717 111.061 74.8679V41.6509H118.755V74.8679C118.755 76.2547 119.866 77.5645 122.09 78.7972C123.741 79.7217 125.447 80.3711 127.208 80.7453C128.903 81.1195 130.686 81.3066 132.557 81.3066C134.384 81.3066 136.145 81.1195 137.84 80.7453C139.623 80.3711 141.34 79.7217 142.991 78.7972C145.236 77.5645 146.358 76.2547 146.358 74.8679V41.6509H153.986V74.8679C153.986 76.2547 155.108 77.5645 157.354 78.7972C159.005 79.7217 160.722 80.3711 162.505 80.7453C164.2 81.1195 165.961 81.3066 167.788 81.3066C169.659 81.3066 171.453 81.1195 173.17 80.7453C174.909 80.3711 176.604 79.7217 178.255 78.7972C180.478 77.5645 181.59 76.2547 181.59 74.8679V41.6509H189.283V74.8679Z" fill="white"/>
246
- </g>
247
- <defs>
248
- <clipPath id="clip0_3624_12755">
249
- <rect width="214" height="135" fill="white"/>
250
- </clipPath>
251
- </defs>
252
- </svg>
253
- <div style="font-size: 16px; font-weight: 500; text-align: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;">${text}</div>
254
- </div>
299
+ overlay.innerHTML = `
300
+ <div style="display: flex; flex-direction: column; align-items: center; gap: 32px;">
301
+ <div style="position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center;">
302
+ <!-- Outer spinning circle -->
303
+ <div class="ww-loading-spinner" style="
304
+ position: absolute;
305
+ width: 120px;
306
+ height: 120px;
307
+ border: 3px solid transparent;
308
+ border-top: 3px solid #333333;
309
+ border-right: 3px solid #333333;
310
+ border-radius: 50%;
311
+ "></div>
312
+
313
+ <!-- Logo -->
314
+ <svg class="ww-loading-logo" width="80" height="50" viewBox="0 0 214 135" fill="none" xmlns="http://www.w3.org/2000/svg">
315
+ <path d="M102.906 74.8679C102.906 77.9717 101.574 80.7453 98.9104 83.1887C96.6871 85.1918 93.9025 86.6997 90.5566 87.7123C87.695 88.5708 84.6462 89 81.4104 89C73.8821 89 68.0047 87.0189 63.7783 83.0566C59.5519 87.0189 53.6855 89 46.1792 89C42.9434 89 39.9057 88.5708 37.066 87.7123C33.7201 86.6997 30.9245 85.1918 28.6792 83.1887C26.0157 80.7453 24.684 77.9717 24.684 74.8679V41.6509H32.3774V74.8679C32.3774 76.2547 33.489 77.5645 35.7123 78.7972C37.3632 79.7217 39.0692 80.3711 40.8302 80.7453C42.5252 81.1195 44.3082 81.3066 46.1792 81.3066C48.0063 81.3066 49.7673 81.1195 51.4623 80.7453C53.2453 80.3711 54.9623 79.7217 56.6132 78.7972C58.8585 77.5645 59.9811 76.2547 59.9811 74.8679V41.6509H67.6085V74.8679C67.6085 76.2547 68.7311 77.5645 70.9764 78.7972C72.6274 79.7217 74.3443 80.3711 76.1274 80.7453C77.8223 81.1195 79.5833 81.3066 81.4104 81.3066C83.2814 81.3066 85.0755 81.1195 86.7925 80.7453C88.5314 80.3711 90.2264 79.7217 91.8774 78.7972C94.1006 77.5645 95.2123 76.2547 95.2123 74.8679V41.6509H102.906V74.8679ZM189.283 74.8679C189.283 77.9717 187.951 80.7453 185.288 83.1887C183.064 85.1918 180.28 86.6997 176.934 87.7123C174.072 88.5708 171.024 89 167.788 89C160.259 89 154.382 87.0189 150.156 83.0566C145.929 87.0189 140.063 89 132.557 89C129.321 89 126.283 88.5708 123.443 87.7123C120.097 86.6997 117.302 85.1918 115.057 83.1887C112.393 80.7453 111.061 77.9717 111.061 74.8679V41.6509H118.755V74.8679C118.755 76.2547 119.866 77.5645 122.09 78.7972C123.741 79.7217 125.447 80.3711 127.208 80.7453C128.903 81.1195 130.686 81.3066 132.557 81.3066C134.384 81.3066 136.145 81.1195 137.84 80.7453C139.623 80.3711 141.34 79.7217 142.991 78.7972C145.236 77.5645 146.358 76.2547 146.358 74.8679V41.6509H153.986V74.8679C153.986 76.2547 155.108 77.5645 157.354 78.7972C159.005 79.7217 160.722 80.3711 162.505 80.7453C164.2 81.1195 165.961 81.3066 167.788 81.3066C169.659 81.3066 171.453 81.1195 173.17 80.7453C174.909 80.3711 176.604 79.7217 178.255 78.7972C180.478 77.5645 181.59 76.2547 181.59 74.8679V41.6509H189.283V74.8679Z" fill="white"/>
316
+ </svg>
317
+ </div>
318
+
319
+ <div style="font-size: 17px; font-weight: 500; text-align: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: white; letter-spacing: 0.5px; max-width: 280px;">${text}</div>
320
+
321
+ <div style="display: flex; gap: 10px; margin-top: 4px;">
322
+ <div style="width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out infinite;"></div>
323
+ <div style="width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out 0.2s infinite;"></div>
324
+ <div style="width: 10px; height: 10px; border-radius: 50%; background: #333333; animation: ww-dot-bounce 1.4s ease-in-out 0.4s infinite;"></div>
325
+ </div>
326
+ </div>
255
327
  `;
256
328
  return overlay;
257
329
  }
@@ -286,42 +358,63 @@
286
358
  alertDiv.className = `ww-alert ww-alert-${type}`;
287
359
  alertDiv.setAttribute("role", "alert" );
288
360
  alertDiv.setAttribute("aria-live", "assertive");
289
- alertDiv.style.cssText = `
290
- position: absolute;
291
- top: 16px;
292
- left: 50%;
293
- transform: translateX(-50%) translateY(-10px);
294
- background: ${"#FEE2E2" };
295
- color: ${"#B91C1C" };
296
- border: 1px solid ${"#F87171" };
297
- border-radius: 8px;
298
- padding: 12px 16px;
299
- z-index: 9999;
300
- font-size: 15px;
301
- font-weight: 500;
302
- box-shadow: 0 4px 12px rgba(0,0,0,0.1);
303
- display: flex;
304
- align-items: center;
305
- min-width: 220px;
306
- max-width: 90%;
307
- opacity: 0;
308
- transition: opacity 0.3s ease, transform 0.3s ease;
361
+ const bgColor = "linear-gradient(135deg, #fee2e2 0%, #fecaca 100%)"
362
+ ;
363
+ const textColor = "#991b1b" ;
364
+ const borderColor = "#f87171" ;
365
+ const iconColor = "#dc2626" ;
366
+ alertDiv.style.cssText = `
367
+ position: absolute;
368
+ top: 24px;
369
+ left: 50%;
370
+ transform: translateX(-50%) translateY(-20px);
371
+ background: ${bgColor};
372
+ color: ${textColor};
373
+ border: 1px solid ${borderColor};
374
+ border-radius: 12px;
375
+ padding: 16px 20px;
376
+ z-index: 9999;
377
+ font-size: 15px;
378
+ font-weight: 500;
379
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
380
+ backdrop-filter: blur(8px);
381
+ -webkit-backdrop-filter: blur(8px);
382
+ display: flex;
383
+ align-items: center;
384
+ gap: 12px;
385
+ min-width: 280px;
386
+ max-width: 90%;
387
+ opacity: 0;
388
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
309
389
  `;
310
- alertDiv.innerHTML = `
311
- <span style="flex: 1; line-height: 1.4;">${message}</span>
312
- <button type="button" aria-label="Close alert"
313
- style="
314
- background: none;
315
- border: none;
316
- font-size: 20px;
317
- color: inherit;
318
- cursor: pointer;
319
- margin-left: 12px;
320
- padding: 0;
321
- line-height: 1;
322
- ">
323
- &times;
324
- </button>
390
+ const icon = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="${iconColor}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
391
+ <circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/>
392
+ </svg>`
393
+ ;
394
+ alertDiv.innerHTML = `
395
+ ${icon}
396
+ <span style="flex: 1; line-height: 1.5;">${message}</span>
397
+ <button type="button" aria-label="Close alert"
398
+ style="
399
+ background: none;
400
+ border: none;
401
+ font-size: 22px;
402
+ color: ${textColor};
403
+ cursor: pointer;
404
+ padding: 0;
405
+ line-height: 1;
406
+ opacity: 0.7;
407
+ transition: opacity 0.2s ease;
408
+ width: 24px;
409
+ height: 24px;
410
+ display: flex;
411
+ align-items: center;
412
+ justify-content: center;
413
+ "
414
+ onmouseover="this.style.opacity='1'"
415
+ onmouseout="this.style.opacity='0.7'">
416
+ &times;
417
+ </button>
325
418
  `;
326
419
  // Close on button click
327
420
  (_a = alertDiv.querySelector("button")) === null || _a === void 0 ? void 0 : _a.addEventListener("click", () => {
@@ -333,10 +426,16 @@
333
426
  alertDiv.style.opacity = "1";
334
427
  alertDiv.style.transform = "translateX(-50%) translateY(0)";
335
428
  });
429
+ // Auto-dismiss after 8 seconds
430
+ setTimeout(() => {
431
+ if (alertDiv.parentElement) {
432
+ fadeOutAndRemove(alertDiv);
433
+ }
434
+ }, 8000);
336
435
  }
337
436
  function fadeOutAndRemove(element) {
338
437
  element.style.opacity = "0";
339
- element.style.transform = "translateX(-50%) translateY(-10px)";
438
+ element.style.transform = "translateX(-50%) translateY(-20px)";
340
439
  setTimeout(() => {
341
440
  element.remove();
342
441
  }, 300);
@@ -353,7 +452,6 @@
353
452
  this.originalProductImageUrl = null;
354
453
  this.isShowingVirtualTryOn = false;
355
454
  this.lastModelImage = null;
356
- this.cookieCheckInterval = null;
357
455
  this.cameraButton = null;
358
456
  this.iframeMessageListener = null;
359
457
  this.previewBadge = null;
@@ -443,47 +541,110 @@
443
541
  removeElements(`.${CSS_CLASSES.MODAL}`);
444
542
  const modal = document.createElement("div");
445
543
  modal.className = CSS_CLASSES.MODAL;
446
- modal.style.cssText = `
447
- position: fixed;
448
- top: 0;
449
- left: 0;
450
- width: 100%;
451
- height: 100%;
452
- background-color: rgba(0, 0, 0, 0.5);
453
- display: flex;
454
- justify-content: center;
455
- align-items: center;
456
- z-index: 1000;
544
+ modal.style.cssText = `
545
+ position: fixed;
546
+ top: 0;
547
+ left: 0;
548
+ width: 100%;
549
+ height: 100%;
550
+ background: linear-gradient(135deg, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.7) 100%);
551
+ backdrop-filter: blur(8px);
552
+ -webkit-backdrop-filter: blur(8px);
553
+ display: flex;
554
+ justify-content: center;
555
+ align-items: center;
556
+ z-index: 1000;
557
+ animation: ww-modal-fade-in 0.3s ease;
457
558
  `;
559
+ // Add fade-in animation
560
+ if (!document.getElementById("ww-modal-animation")) {
561
+ const style = document.createElement("style");
562
+ style.id = "ww-modal-animation";
563
+ style.textContent = `
564
+ @keyframes ww-modal-fade-in {
565
+ from { opacity: 0; }
566
+ to { opacity: 1; }
567
+ }
568
+ @keyframes ww-modal-scale-in {
569
+ from { transform: scale(0.95); opacity: 0; }
570
+ to { transform: scale(1); opacity: 1; }
571
+ }
572
+ `;
573
+ document.head.appendChild(style);
574
+ }
575
+ const iframeContainer = document.createElement("div");
576
+ iframeContainer.style.cssText = `
577
+ position: relative;
578
+ width: 90%;
579
+ height: 90%;
580
+ max-width: 480px;
581
+ max-height: 720px;
582
+ border-radius: 20px;
583
+ overflow: hidden;
584
+ box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3), 0 12px 24px rgba(0, 0, 0, 0.2);
585
+ animation: ww-modal-scale-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
586
+ background: white;
587
+ `;
458
588
  const iframe = document.createElement("iframe");
459
589
  iframe.src = url;
460
- iframe.style.cssText = `
461
- width: 90%;
462
- height: 90%;
463
- max-width: 800px;
464
- max-height: 600px;
465
- border: none;
466
- border-radius: 8px;
590
+ iframe.style.cssText = `
591
+ width: 100%;
592
+ height: 100%;
593
+ border: none;
467
594
  `;
468
595
  const closeButton = document.createElement("button");
469
- closeButton.innerText = "X";
470
- closeButton.style.cssText = `
471
- position: absolute;
472
- top: 10px;
473
- right: 10px;
474
- background: white;
475
- border: none;
476
- border-radius: 50%;
477
- width: 30px;
478
- height: 30px;
479
- cursor: pointer;
596
+ closeButton.innerHTML = `
597
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
598
+ <line x1="18" y1="6" x2="6" y2="18"></line>
599
+ <line x1="6" y1="6" x2="18" y2="18"></line>
600
+ </svg>
601
+ `;
602
+ closeButton.setAttribute("aria-label", "Close modal");
603
+ closeButton.style.cssText = `
604
+ position: absolute;
605
+ top: -48px;
606
+ right: 0;
607
+ background: rgba(255, 255, 255, 0.95);
608
+ backdrop-filter: blur(8px);
609
+ -webkit-backdrop-filter: blur(8px);
610
+ border: none;
611
+ border-radius: 50%;
612
+ width: 40px;
613
+ height: 40px;
614
+ cursor: pointer;
615
+ display: flex;
616
+ align-items: center;
617
+ justify-content: center;
618
+ color: #1f2937;
619
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
620
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
480
621
  `;
622
+ closeButton.onmouseover = () => {
623
+ closeButton.style.transform = "scale(1.1) rotate(90deg)";
624
+ closeButton.style.background = "#ef4444";
625
+ closeButton.style.color = "white";
626
+ };
627
+ closeButton.onmouseout = () => {
628
+ closeButton.style.transform = "scale(1) rotate(0deg)";
629
+ closeButton.style.background = "rgba(255, 255, 255, 0.95)";
630
+ closeButton.style.color = "#1f2937";
631
+ };
481
632
  closeButton.onclick = () => {
482
- modal.remove();
633
+ modal.style.opacity = "0";
634
+ iframeContainer.style.transform = "scale(0.95)";
635
+ iframeContainer.style.opacity = "0";
636
+ setTimeout(() => modal.remove(), 300);
483
637
  };
484
- modal.appendChild(iframe);
485
- modal.appendChild(closeButton);
638
+ iframeContainer.appendChild(iframe);
639
+ iframeContainer.appendChild(closeButton);
640
+ modal.appendChild(iframeContainer);
486
641
  document.body.appendChild(modal);
642
+ // Close on backdrop click
643
+ modal.onclick = (e) => {
644
+ if (e.target === modal) {
645
+ closeButton.click();
646
+ }
647
+ };
487
648
  }
488
649
  /**
489
650
  * Sets up listener for messages from the iframe
@@ -636,6 +797,19 @@
636
797
  if (!container.hasAttribute("data-ww-original-content")) {
637
798
  container.setAttribute("data-ww-original-content", container.innerHTML);
638
799
  }
800
+ // Capture and lock container dimensions before replacement to prevent layout shift
801
+ if (!container.hasAttribute("data-ww-container-locked")) {
802
+ const containerRect = container.getBoundingClientRect();
803
+ // Store original dimensions
804
+ container.setAttribute("data-ww-container-width", containerRect.width.toString());
805
+ container.setAttribute("data-ww-container-height", containerRect.height.toString());
806
+ // Lock the container dimensions
807
+ container.style.width = `${containerRect.width}px`;
808
+ container.style.height = `${containerRect.height}px`;
809
+ container.style.minWidth = `${containerRect.width}px`;
810
+ container.style.minHeight = `${containerRect.height}px`;
811
+ container.setAttribute("data-ww-container-locked", "true");
812
+ }
639
813
  // Capture original image dimensions before replacement to prevent layout shift
640
814
  const originalImg = container.querySelector("img");
641
815
  if (originalImg &&
@@ -726,11 +900,10 @@
726
900
  else if (originalRectHeight && originalRectHeight !== "0") {
727
901
  heightStyle = `${originalRectHeight}px`;
728
902
  }
729
- image.style.cssText = `
730
- width: ${widthStyle};
731
- height: ${heightStyle};
732
- object-fit: cover;
733
- border-radius: 8px;
903
+ image.style.cssText = `
904
+ width: ${widthStyle};
905
+ height: ${heightStyle};
906
+ object-fit: contain;
734
907
  `;
735
908
  // Prepend the image to ensure buttons are rendered on top
736
909
  container.prepend(image);
@@ -765,11 +938,7 @@
765
938
  removeElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);
766
939
  // Remove all modals
767
940
  removeElements(`.${CSS_CLASSES.MODAL}`);
768
- // Clear interval
769
- if (this.cookieCheckInterval !== null) {
770
- clearInterval(this.cookieCheckInterval);
771
- this.cookieCheckInterval = null;
772
- }
941
+ // Clear references
773
942
  this.cameraButton = null;
774
943
  // Remove message listener
775
944
  if (this.iframeMessageListener) {