@wix/ditto-codegen-public 1.0.39 → 1.0.41
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/examples-apps/custom-element/src/widgets/custom-elements/countdown-timer/widget.tsx +332 -0
- package/dist/out.js +252 -104
- package/package.json +2 -2
- package/dist/examples-apps/chart-widget/.nvmrc +0 -1
- package/dist/examples-apps/chart-widget/README.md +0 -21
- package/dist/examples-apps/chart-widget/assets/chart-widget/thumbnail.png +0 -0
- package/dist/examples-apps/chart-widget/package-lock.json +0 -6329
- package/dist/examples-apps/chart-widget/package.json +0 -30
- package/dist/examples-apps/chart-widget/src/env.d.ts +0 -4
- package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/common.ts +0 -20
- package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/element/bar-chart.tsx +0 -53
- package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/element/pie-chart.tsx +0 -40
- package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/element.json +0 -20
- package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/element.tsx +0 -53
- package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/panel/chart-type.tsx +0 -47
- package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/panel/slice.tsx +0 -72
- package/dist/examples-apps/chart-widget/src/site/widgets/custom-elements/chart-widget/panel.tsx +0 -90
- package/dist/examples-apps/chart-widget/tsconfig.json +0 -8
- package/dist/examples-apps/chart-widget/wix.config.json +0 -5
package/dist/examples-apps/custom-element/src/widgets/custom-elements/countdown-timer/widget.tsx
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
interface CountdownTimerData {
|
|
2
|
+
title: string;
|
|
3
|
+
endDateTime: string;
|
|
4
|
+
targetUrl?: string;
|
|
5
|
+
isActive: boolean;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface TimeRemaining {
|
|
10
|
+
days: number;
|
|
11
|
+
hours: number;
|
|
12
|
+
minutes: number;
|
|
13
|
+
seconds: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default class extends HTMLElement {
|
|
17
|
+
private intervalId: number | null = null;
|
|
18
|
+
private timerData: CountdownTimerData | null = null;
|
|
19
|
+
|
|
20
|
+
public connectedCallback(): void {
|
|
21
|
+
this.loadTimerData();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public disconnectedCallback(): void {
|
|
25
|
+
if (this.intervalId !== null) {
|
|
26
|
+
clearInterval(this.intervalId);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private async loadTimerData(): Promise<void> {
|
|
31
|
+
try {
|
|
32
|
+
const timerData: CountdownTimerData = {
|
|
33
|
+
title: 'Special Offer Ends Soon!',
|
|
34
|
+
endDateTime: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString(),
|
|
35
|
+
targetUrl: undefined,
|
|
36
|
+
isActive: true,
|
|
37
|
+
description: undefined
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
this.timerData = timerData;
|
|
41
|
+
this.render();
|
|
42
|
+
this.startCountdown();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('Failed to load timer data:', error);
|
|
45
|
+
this.renderError();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private calculateTimeRemaining(endDate: string): TimeRemaining | null {
|
|
50
|
+
const now = new Date().getTime();
|
|
51
|
+
const end = new Date(endDate).getTime();
|
|
52
|
+
const difference = end - now;
|
|
53
|
+
|
|
54
|
+
if (difference <= 0) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const days = Math.floor(difference / (1000 * 60 * 60 * 24));
|
|
59
|
+
const hours = Math.floor((difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
60
|
+
const minutes = Math.floor((difference % (1000 * 60 * 60)) / (1000 * 60));
|
|
61
|
+
const seconds = Math.floor((difference % (1000 * 60)) / 1000);
|
|
62
|
+
|
|
63
|
+
return { days, hours, minutes, seconds };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private startCountdown(): void {
|
|
67
|
+
if (!this.timerData || !this.timerData.isActive) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.intervalId = window.setInterval(() => {
|
|
72
|
+
this.updateCountdown();
|
|
73
|
+
}, 1000);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private updateCountdown(): void {
|
|
77
|
+
if (!this.timerData) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const timeRemaining = this.calculateTimeRemaining(this.timerData.endDateTime);
|
|
82
|
+
|
|
83
|
+
if (timeRemaining === null) {
|
|
84
|
+
this.renderExpired();
|
|
85
|
+
if (this.intervalId !== null) {
|
|
86
|
+
clearInterval(this.intervalId);
|
|
87
|
+
this.intervalId = null;
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.renderCountdown(timeRemaining);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private render(): void {
|
|
96
|
+
if (!this.timerData) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const timeRemaining = this.calculateTimeRemaining(this.timerData.endDateTime);
|
|
101
|
+
|
|
102
|
+
if (timeRemaining === null) {
|
|
103
|
+
this.renderExpired();
|
|
104
|
+
} else {
|
|
105
|
+
this.renderCountdown(timeRemaining);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private renderCountdown(timeRemaining: TimeRemaining): void {
|
|
110
|
+
if (!this.timerData) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const containerStyle = `
|
|
115
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
116
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
117
|
+
color: white;
|
|
118
|
+
padding: 24px;
|
|
119
|
+
border-radius: 12px;
|
|
120
|
+
text-align: center;
|
|
121
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
|
122
|
+
max-width: 500px;
|
|
123
|
+
margin: 0 auto;
|
|
124
|
+
`;
|
|
125
|
+
|
|
126
|
+
const titleStyle = `
|
|
127
|
+
font-size: 24px;
|
|
128
|
+
font-weight: 700;
|
|
129
|
+
margin: 0 0 8px 0;
|
|
130
|
+
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
|
131
|
+
`;
|
|
132
|
+
|
|
133
|
+
const descriptionStyle = `
|
|
134
|
+
font-size: 16px;
|
|
135
|
+
opacity: 0.9;
|
|
136
|
+
margin: 0 0 24px 0;
|
|
137
|
+
line-height: 1.4;
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
const timerGridStyle = `
|
|
141
|
+
display: grid;
|
|
142
|
+
grid-template-columns: repeat(4, 1fr);
|
|
143
|
+
gap: 16px;
|
|
144
|
+
margin: 24px 0;
|
|
145
|
+
`;
|
|
146
|
+
|
|
147
|
+
const timeUnitStyle = `
|
|
148
|
+
background: rgba(255, 255, 255, 0.2);
|
|
149
|
+
border-radius: 8px;
|
|
150
|
+
padding: 16px 8px;
|
|
151
|
+
backdrop-filter: blur(10px);
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
const numberStyle = `
|
|
155
|
+
font-size: 32px;
|
|
156
|
+
font-weight: 800;
|
|
157
|
+
margin: 0;
|
|
158
|
+
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
|
159
|
+
`;
|
|
160
|
+
|
|
161
|
+
const labelStyle = `
|
|
162
|
+
font-size: 12px;
|
|
163
|
+
text-transform: uppercase;
|
|
164
|
+
letter-spacing: 1px;
|
|
165
|
+
margin: 4px 0 0 0;
|
|
166
|
+
opacity: 0.8;
|
|
167
|
+
`;
|
|
168
|
+
|
|
169
|
+
const buttonStyle = `
|
|
170
|
+
background: rgba(255, 255, 255, 0.2);
|
|
171
|
+
color: white;
|
|
172
|
+
border: 2px solid rgba(255, 255, 255, 0.3);
|
|
173
|
+
padding: 12px 24px;
|
|
174
|
+
border-radius: 6px;
|
|
175
|
+
font-size: 16px;
|
|
176
|
+
font-weight: 600;
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
transition: all 0.3s ease;
|
|
179
|
+
text-decoration: none;
|
|
180
|
+
display: inline-block;
|
|
181
|
+
margin-top: 16px;
|
|
182
|
+
backdrop-filter: blur(10px);
|
|
183
|
+
`;
|
|
184
|
+
|
|
185
|
+
const buttonHoverStyle = `
|
|
186
|
+
background: rgba(255, 255, 255, 0.3);
|
|
187
|
+
border-color: rgba(255, 255, 255, 0.5);
|
|
188
|
+
transform: translateY(-2px);
|
|
189
|
+
`;
|
|
190
|
+
|
|
191
|
+
const responsiveStyle = `
|
|
192
|
+
@media (max-width: 480px) {
|
|
193
|
+
.timer-grid {
|
|
194
|
+
grid-template-columns: repeat(2, 1fr);
|
|
195
|
+
gap: 12px;
|
|
196
|
+
}
|
|
197
|
+
.time-number {
|
|
198
|
+
font-size: 24px;
|
|
199
|
+
}
|
|
200
|
+
.timer-container {
|
|
201
|
+
padding: 16px;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
`;
|
|
205
|
+
|
|
206
|
+
this.innerHTML = `
|
|
207
|
+
<style>
|
|
208
|
+
${responsiveStyle}
|
|
209
|
+
.timer-button:hover {
|
|
210
|
+
${buttonHoverStyle}
|
|
211
|
+
}
|
|
212
|
+
</style>
|
|
213
|
+
<div class="timer-container" style="${containerStyle}" data-testid="countdown-timer">
|
|
214
|
+
<h2 style="${titleStyle}">${this.escapeHtml(this.timerData.title)}</h2>
|
|
215
|
+
${this.timerData.description ? `<p style="${descriptionStyle}">${this.escapeHtml(this.timerData.description)}</p>` : ''}
|
|
216
|
+
|
|
217
|
+
<div class="timer-grid" style="${timerGridStyle}">
|
|
218
|
+
<div style="${timeUnitStyle}">
|
|
219
|
+
<div class="time-number" style="${numberStyle}">${timeRemaining.days.toString().padStart(2, '0')}</div>
|
|
220
|
+
<div style="${labelStyle}">Days</div>
|
|
221
|
+
</div>
|
|
222
|
+
<div style="${timeUnitStyle}">
|
|
223
|
+
<div class="time-number" style="${numberStyle}">${timeRemaining.hours.toString().padStart(2, '0')}</div>
|
|
224
|
+
<div style="${labelStyle}">Hours</div>
|
|
225
|
+
</div>
|
|
226
|
+
<div style="${timeUnitStyle}">
|
|
227
|
+
<div class="time-number" style="${numberStyle}">${timeRemaining.minutes.toString().padStart(2, '0')}</div>
|
|
228
|
+
<div style="${labelStyle}">Minutes</div>
|
|
229
|
+
</div>
|
|
230
|
+
<div style="${timeUnitStyle}">
|
|
231
|
+
<div class="time-number" style="${numberStyle}">${timeRemaining.seconds.toString().padStart(2, '0')}</div>
|
|
232
|
+
<div style="${labelStyle}">Seconds</div>
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
${this.timerData.targetUrl ? `
|
|
237
|
+
<a href="${this.escapeHtml(this.timerData.targetUrl)}"
|
|
238
|
+
class="timer-button"
|
|
239
|
+
style="${buttonStyle}"
|
|
240
|
+
role="button"
|
|
241
|
+
aria-label="Take action before timer expires">
|
|
242
|
+
Don't Miss Out!
|
|
243
|
+
</a>
|
|
244
|
+
` : ''}
|
|
245
|
+
</div>
|
|
246
|
+
`;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private renderExpired(): void {
|
|
250
|
+
if (!this.timerData) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const containerStyle = `
|
|
255
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
256
|
+
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
|
|
257
|
+
color: white;
|
|
258
|
+
padding: 24px;
|
|
259
|
+
border-radius: 12px;
|
|
260
|
+
text-align: center;
|
|
261
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
|
262
|
+
max-width: 500px;
|
|
263
|
+
margin: 0 auto;
|
|
264
|
+
`;
|
|
265
|
+
|
|
266
|
+
const titleStyle = `
|
|
267
|
+
font-size: 24px;
|
|
268
|
+
font-weight: 700;
|
|
269
|
+
margin: 0 0 16px 0;
|
|
270
|
+
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
|
271
|
+
`;
|
|
272
|
+
|
|
273
|
+
const messageStyle = `
|
|
274
|
+
font-size: 18px;
|
|
275
|
+
margin: 0;
|
|
276
|
+
opacity: 0.9;
|
|
277
|
+
`;
|
|
278
|
+
|
|
279
|
+
this.innerHTML = `
|
|
280
|
+
<div style="${containerStyle}" data-testid="countdown-timer-expired">
|
|
281
|
+
<h2 style="${titleStyle}">⏰ Time's Up!</h2>
|
|
282
|
+
<p style="${messageStyle}">${this.escapeHtml(this.timerData.title)} has ended.</p>
|
|
283
|
+
${this.timerData.targetUrl ? `
|
|
284
|
+
<a href="${this.escapeHtml(this.timerData.targetUrl)}"
|
|
285
|
+
style="
|
|
286
|
+
background: rgba(255, 255, 255, 0.2);
|
|
287
|
+
color: white;
|
|
288
|
+
border: 2px solid rgba(255, 255, 255, 0.3);
|
|
289
|
+
padding: 12px 24px;
|
|
290
|
+
border-radius: 6px;
|
|
291
|
+
font-size: 16px;
|
|
292
|
+
font-weight: 600;
|
|
293
|
+
cursor: pointer;
|
|
294
|
+
text-decoration: none;
|
|
295
|
+
display: inline-block;
|
|
296
|
+
margin-top: 16px;
|
|
297
|
+
backdrop-filter: blur(10px);
|
|
298
|
+
"
|
|
299
|
+
role="button">
|
|
300
|
+
Learn More
|
|
301
|
+
</a>
|
|
302
|
+
` : ''}
|
|
303
|
+
</div>
|
|
304
|
+
`;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
private renderError(): void {
|
|
308
|
+
const containerStyle = `
|
|
309
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
310
|
+
background: #f8f9fa;
|
|
311
|
+
color: #6c757d;
|
|
312
|
+
padding: 24px;
|
|
313
|
+
border-radius: 12px;
|
|
314
|
+
text-align: center;
|
|
315
|
+
border: 2px dashed #dee2e6;
|
|
316
|
+
max-width: 500px;
|
|
317
|
+
margin: 0 auto;
|
|
318
|
+
`;
|
|
319
|
+
|
|
320
|
+
this.innerHTML = `
|
|
321
|
+
<div style="${containerStyle}" data-testid="countdown-timer-error">
|
|
322
|
+
<p style="margin: 0; font-size: 16px;">⚠️ Unable to load countdown timer</p>
|
|
323
|
+
</div>
|
|
324
|
+
`;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
private escapeHtml(text: string): string {
|
|
328
|
+
const div = document.createElement('div');
|
|
329
|
+
div.textContent = text;
|
|
330
|
+
return div.innerHTML;
|
|
331
|
+
}
|
|
332
|
+
}
|