ga-toasts 1.0.0
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/.htaccess +75 -0
- package/README.md +554 -0
- package/REDIRECT_SETUP.md +149 -0
- package/ga-toasts.d.ts +99 -0
- package/images/gennie_logo.png +0 -0
- package/index.html +1034 -0
- package/package.json +23 -0
- package/robots.txt +54 -0
- package/sitemap.xml +47 -0
- package/src/demo.css +698 -0
- package/src/demo.js +467 -0
- package/src/toasts.css +1644 -0
- package/src/toasts.js +1005 -0
- package/src/variables.css +480 -0
- package/vercel.json +50 -0
package/src/demo.js
ADDED
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
|
|
2
|
+
// Global variables
|
|
3
|
+
let currentPosition = 'top-end';
|
|
4
|
+
let currentTheme = 'light';
|
|
5
|
+
|
|
6
|
+
// Basic toast functions
|
|
7
|
+
function showSuccess() {
|
|
8
|
+
GaToasts.success('🎉 Amazing! Your action completed successfully!', { title: 'Success' });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function showError() {
|
|
12
|
+
GaToasts.error('😞 Oops! Something went wrong. Please try again.', { title: 'Error' });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function showWarning() {
|
|
16
|
+
GaToasts.warning('⚠️ Heads up! Please check your input before proceeding.', { title: 'Warning' });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function showInfo() {
|
|
20
|
+
GaToasts.info('💡 Here is some useful information for you.', { title: 'Info' });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function showPrimary() {
|
|
24
|
+
GaToasts.show({
|
|
25
|
+
type: 'primary',
|
|
26
|
+
title: 'Primary Notification',
|
|
27
|
+
message: 'This is a primary notification'
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function showSecondary() {
|
|
32
|
+
GaToasts.show({
|
|
33
|
+
type: 'secondary',
|
|
34
|
+
title: 'Secondary Notification',
|
|
35
|
+
message: 'This is a secondary notification'
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function showCompact() {
|
|
40
|
+
GaToasts.show({
|
|
41
|
+
type: 'info',
|
|
42
|
+
title: 'New Message',
|
|
43
|
+
message: 'You have received a new message from John Doe. Click to view details.',
|
|
44
|
+
compact: true,
|
|
45
|
+
duration: 5000
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Advanced features
|
|
50
|
+
function showWithTitle() {
|
|
51
|
+
GaToasts.show({
|
|
52
|
+
title: 'New Message',
|
|
53
|
+
message: 'You have received a new message from John Doe. Click to view details.',
|
|
54
|
+
type: 'info',
|
|
55
|
+
duration: 5000
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
function showWithActions() {
|
|
61
|
+
GaToasts.show({
|
|
62
|
+
message: 'File uploaded successfully!',
|
|
63
|
+
type: 'success',
|
|
64
|
+
actions: [
|
|
65
|
+
{
|
|
66
|
+
text: 'View File',
|
|
67
|
+
class: 'ga-btn-primary',
|
|
68
|
+
click: function () {
|
|
69
|
+
alert('Opening file...');
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
text: 'Dismiss',
|
|
74
|
+
class: 'ga-btn-secondary',
|
|
75
|
+
click: function (e, toast) {
|
|
76
|
+
GaToasts.close(toast);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function showConfirmation() {
|
|
84
|
+
GaToasts.confirm('Are you sure you want to delete this item?', {
|
|
85
|
+
onConfirm: function () {
|
|
86
|
+
GaToasts.success('Item deleted successfully!');
|
|
87
|
+
},
|
|
88
|
+
onCancel: function () {
|
|
89
|
+
GaToasts.info('Deletion cancelled.');
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function showLoading() {
|
|
95
|
+
const loadingToast = GaToasts.loading('Processing your request...');
|
|
96
|
+
|
|
97
|
+
// Simulate loading completion
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
GaToasts.close(loadingToast);
|
|
100
|
+
GaToasts.success('Request completed successfully!');
|
|
101
|
+
}, 3000);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function showCustomIcon() {
|
|
105
|
+
GaToasts.show({
|
|
106
|
+
message: 'Custom icon toast',
|
|
107
|
+
type: 'info',
|
|
108
|
+
icon: '<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function showModern() {
|
|
113
|
+
GaToasts.modern('This is a modern toast with enhanced styling!');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function showSwipeToClose() {
|
|
117
|
+
GaToasts.show({
|
|
118
|
+
title: 'Swipe to close',
|
|
119
|
+
message: 'On touch devices, drag this toast left or right to dismiss it.',
|
|
120
|
+
type: 'info',
|
|
121
|
+
swipeToClose: true
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Variants and sizes
|
|
126
|
+
function showFilled() {
|
|
127
|
+
GaToasts.show({
|
|
128
|
+
message: 'Filled variant toast',
|
|
129
|
+
type: 'success',
|
|
130
|
+
variant: 'filled'
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function showLight() {
|
|
135
|
+
GaToasts.show({
|
|
136
|
+
message: 'Light variant toast',
|
|
137
|
+
type: 'info',
|
|
138
|
+
variant: 'light'
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function showSmall() {
|
|
143
|
+
GaToasts.show({
|
|
144
|
+
message: 'Small toast',
|
|
145
|
+
type: 'warning',
|
|
146
|
+
size: 'sm'
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function showLarge() {
|
|
151
|
+
GaToasts.show({
|
|
152
|
+
message: 'Large toast with more content and better visibility',
|
|
153
|
+
type: 'primary',
|
|
154
|
+
size: 'lg'
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function showGlassmorphism() {
|
|
159
|
+
GaToasts.show({
|
|
160
|
+
message: 'Glassmorphism effect toast',
|
|
161
|
+
type: 'info',
|
|
162
|
+
glassmorphism: true
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function showGradient() {
|
|
167
|
+
const toast = GaToasts.show({
|
|
168
|
+
message: 'Gradient border toast',
|
|
169
|
+
type: 'primary'
|
|
170
|
+
});
|
|
171
|
+
toast.addClass('ga-toast-gradient-border');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Animations
|
|
175
|
+
function showFade() {
|
|
176
|
+
GaToasts.show({
|
|
177
|
+
message: 'Fade animation toast',
|
|
178
|
+
title: 'Fade',
|
|
179
|
+
type: 'info',
|
|
180
|
+
animation: 'fade'
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function showSlide() {
|
|
185
|
+
GaToasts.show({
|
|
186
|
+
message: 'Slide animation toast',
|
|
187
|
+
title: 'Slide',
|
|
188
|
+
type: 'success',
|
|
189
|
+
animation: 'slide'
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function showBounce() {
|
|
194
|
+
GaToasts.show({
|
|
195
|
+
message: 'Bounce animation toast',
|
|
196
|
+
title: 'Bounce',
|
|
197
|
+
type: 'warning',
|
|
198
|
+
animation: 'bounce'
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function showScale() {
|
|
203
|
+
GaToasts.show({
|
|
204
|
+
message: 'Scale animation toast',
|
|
205
|
+
title: 'Scale',
|
|
206
|
+
type: 'info',
|
|
207
|
+
animation: 'scale'
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function showShake() {
|
|
212
|
+
const toast = GaToasts.show({
|
|
213
|
+
message: 'Shake effect toast',
|
|
214
|
+
title: 'Shake',
|
|
215
|
+
type: 'error'
|
|
216
|
+
});
|
|
217
|
+
toast.addClass('ga-toast-shake');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function showHeartbeat() {
|
|
221
|
+
const toast = GaToasts.show({
|
|
222
|
+
message: 'Heartbeat effect toast',
|
|
223
|
+
title: 'Heartbeat',
|
|
224
|
+
type: 'success'
|
|
225
|
+
});
|
|
226
|
+
toast.addClass('ga-toast-heartbeat');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Position control
|
|
230
|
+
function setPosition(position) {
|
|
231
|
+
currentPosition = position;
|
|
232
|
+
document.querySelectorAll('.position-btn').forEach(btn => {
|
|
233
|
+
btn.classList.remove('active');
|
|
234
|
+
});
|
|
235
|
+
if (window.event && window.event.target) {
|
|
236
|
+
window.event.target.classList.add('active');
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function showAtPosition() {
|
|
241
|
+
GaToasts.show({
|
|
242
|
+
message: `Toast at ${currentPosition} position`,
|
|
243
|
+
title: 'Position',
|
|
244
|
+
type: 'info',
|
|
245
|
+
position: currentPosition
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Theme control with persistence
|
|
250
|
+
function setTheme(theme, sourceButton) {
|
|
251
|
+
currentTheme = theme;
|
|
252
|
+
document.documentElement.setAttribute('data-ga-theme', theme);
|
|
253
|
+
try {
|
|
254
|
+
localStorage.setItem('ga-theme', theme);
|
|
255
|
+
} catch (e) {
|
|
256
|
+
// ignore storage errors
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const buttons = document.querySelectorAll('.theme-btn');
|
|
260
|
+
buttons.forEach(btn => {
|
|
261
|
+
btn.classList.remove('active');
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
if (sourceButton) {
|
|
265
|
+
sourceButton.classList.add('active');
|
|
266
|
+
} else {
|
|
267
|
+
buttons.forEach(btn => {
|
|
268
|
+
if (btn.dataset.theme === theme) {
|
|
269
|
+
btn.classList.add('active');
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function showThemedToast() {
|
|
276
|
+
GaToasts.show({
|
|
277
|
+
message: `Toast with ${currentTheme} theme`,
|
|
278
|
+
title: 'Theme',
|
|
279
|
+
type: 'info'
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Progress and timing
|
|
284
|
+
function showWithProgress() {
|
|
285
|
+
GaToasts.show({
|
|
286
|
+
message: 'Toast with progress bar',
|
|
287
|
+
title: 'Progress',
|
|
288
|
+
type: 'info',
|
|
289
|
+
progress: true,
|
|
290
|
+
duration: 5000
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function showPauseOnHover() {
|
|
295
|
+
GaToasts.show({
|
|
296
|
+
message: 'Hover to pause countdown',
|
|
297
|
+
title: 'Pause',
|
|
298
|
+
type: 'success',
|
|
299
|
+
pauseOnHover: true,
|
|
300
|
+
duration: 5000
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function showLongDuration() {
|
|
305
|
+
GaToasts.show({
|
|
306
|
+
message: 'This toast will stay for 10 seconds',
|
|
307
|
+
title: 'Long',
|
|
308
|
+
type: 'warning',
|
|
309
|
+
duration: 10000
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function showNoAutoClose() {
|
|
314
|
+
GaToasts.show({
|
|
315
|
+
message: 'This toast will not auto-close',
|
|
316
|
+
title: 'No Auto Close',
|
|
317
|
+
type: 'info',
|
|
318
|
+
duration: 0,
|
|
319
|
+
closable: true
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function showClickToClose() {
|
|
324
|
+
GaToasts.show({
|
|
325
|
+
message: 'Click anywhere on this toast to close it',
|
|
326
|
+
type: 'info',
|
|
327
|
+
clickToClose: true
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function showBackgroundFill() {
|
|
332
|
+
GaToasts.show({
|
|
333
|
+
message: 'Toast with background fill effect',
|
|
334
|
+
type: 'primary',
|
|
335
|
+
progressBackground: true,
|
|
336
|
+
duration: 5000
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Toast management
|
|
341
|
+
function showMultiple() {
|
|
342
|
+
const types = ['success', 'info', 'warning', 'error'];
|
|
343
|
+
types.forEach((type, index) => {
|
|
344
|
+
setTimeout(() => {
|
|
345
|
+
GaToasts.show({
|
|
346
|
+
message: `Toast ${index + 1} - ${type}`,
|
|
347
|
+
type: type
|
|
348
|
+
});
|
|
349
|
+
}, index * 500);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function updateToast() {
|
|
354
|
+
const toast = GaToasts.show({
|
|
355
|
+
id: 'updateable-toast',
|
|
356
|
+
message: 'Initial message - will update in 2 seconds',
|
|
357
|
+
type: 'info',
|
|
358
|
+
duration: 0
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
setTimeout(() => {
|
|
362
|
+
GaToasts.update('updateable-toast', {
|
|
363
|
+
message: 'Message updated successfully!',
|
|
364
|
+
type: 'success'
|
|
365
|
+
});
|
|
366
|
+
}, 2000);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function closeAll() {
|
|
370
|
+
GaToasts.closeAll();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function getCount() {
|
|
374
|
+
const count = GaToasts.getCount();
|
|
375
|
+
GaToasts.info(`There are currently ${count} toasts visible`);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function clearByType() {
|
|
379
|
+
GaToasts.clear('info');
|
|
380
|
+
GaToasts.info('All info toasts have been cleared');
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function showStack() {
|
|
384
|
+
// Show multiple toasts in a stack
|
|
385
|
+
for (let i = 1; i <= 5; i++) {
|
|
386
|
+
setTimeout(() => {
|
|
387
|
+
GaToasts.show({
|
|
388
|
+
message: `Stacked toast ${i}`,
|
|
389
|
+
type: 'info',
|
|
390
|
+
size: 'sm'
|
|
391
|
+
});
|
|
392
|
+
}, i * 200);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Initialize demo
|
|
397
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
398
|
+
// Restore saved theme or respect system preference
|
|
399
|
+
try {
|
|
400
|
+
const savedTheme = localStorage.getItem('ga-theme');
|
|
401
|
+
if (savedTheme) {
|
|
402
|
+
setTheme(savedTheme);
|
|
403
|
+
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
404
|
+
setTheme('dark');
|
|
405
|
+
} else {
|
|
406
|
+
setTheme('light');
|
|
407
|
+
}
|
|
408
|
+
} catch (e) {
|
|
409
|
+
setTheme('light');
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Add copy buttons to all code blocks
|
|
413
|
+
document.querySelectorAll('.code-block').forEach(block => {
|
|
414
|
+
const pre = block.querySelector('pre');
|
|
415
|
+
if (!pre) return;
|
|
416
|
+
const btn = document.createElement('button');
|
|
417
|
+
btn.type = 'button';
|
|
418
|
+
btn.className = 'code-copy-btn';
|
|
419
|
+
btn.textContent = 'Copy';
|
|
420
|
+
btn.addEventListener('click', function () {
|
|
421
|
+
const text = pre.innerText;
|
|
422
|
+
navigator.clipboard.writeText(text).then(() => {
|
|
423
|
+
GaToasts.success('Code copied to clipboard!', { title: 'Copied' });
|
|
424
|
+
}).catch(() => {
|
|
425
|
+
GaToasts.error('Unable to copy code.', { title: 'Error' });
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
block.appendChild(btn);
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// Keyboard shortcuts for common toasts
|
|
432
|
+
document.addEventListener('keydown', function (e) {
|
|
433
|
+
if (!e.altKey || e.shiftKey || e.ctrlKey || e.metaKey) return;
|
|
434
|
+
const key = e.key.toLowerCase();
|
|
435
|
+
switch (key) {
|
|
436
|
+
case 's':
|
|
437
|
+
e.preventDefault();
|
|
438
|
+
showSuccess();
|
|
439
|
+
break;
|
|
440
|
+
case 'e':
|
|
441
|
+
e.preventDefault();
|
|
442
|
+
showError();
|
|
443
|
+
break;
|
|
444
|
+
case 'w':
|
|
445
|
+
e.preventDefault();
|
|
446
|
+
showWarning();
|
|
447
|
+
break;
|
|
448
|
+
case 'i':
|
|
449
|
+
e.preventDefault();
|
|
450
|
+
showInfo();
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
// Show welcome toast
|
|
456
|
+
setTimeout(() => {
|
|
457
|
+
GaToasts.show({
|
|
458
|
+
title: 'Welcome to GA Toasts! 🎉',
|
|
459
|
+
message: 'Discover the power of beautiful, modern toast notifications. Use the controls and keyboard shortcuts to explore all the features. (Alt+S: success, Alt+E: error, Alt+W: warning, Alt+I: info)',
|
|
460
|
+
type: 'success',
|
|
461
|
+
duration: 6000,
|
|
462
|
+
position: 'top-center'
|
|
463
|
+
});
|
|
464
|
+
}, 1000);
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
|