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/.htaccess
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# GA Toasts - SEO Redirect Rules
|
|
2
|
+
# Handle www/non-www subdomain redirects and canonical URLs
|
|
3
|
+
|
|
4
|
+
# Enable rewrite engine
|
|
5
|
+
RewriteEngine On
|
|
6
|
+
|
|
7
|
+
# Force HTTPS redirect (uncomment when SSL is available)
|
|
8
|
+
RewriteCond %{HTTPS} off
|
|
9
|
+
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
|
10
|
+
|
|
11
|
+
# Canonical redirect: www to non-www (recommended for SEO)
|
|
12
|
+
RewriteCond %{HTTP_HOST} ^www\.ga-toasts\.com$ [NC]
|
|
13
|
+
RewriteRule ^(.*)$ https://ga-toasts.com/$1 [R=301,L]
|
|
14
|
+
|
|
15
|
+
# Alternative: non-www to www (uncomment if you prefer www)
|
|
16
|
+
# RewriteCond %{HTTP_HOST} ^ga-toasts\.com$ [NC]
|
|
17
|
+
# RewriteRule ^(.*)$ https://www.ga-toasts.com/$1 [R=301,L]
|
|
18
|
+
|
|
19
|
+
# Additional www redirect patterns
|
|
20
|
+
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
|
|
21
|
+
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
|
|
22
|
+
|
|
23
|
+
# Handle both HTTP and HTTPS www redirects
|
|
24
|
+
RewriteCond %{HTTPS} on
|
|
25
|
+
RewriteCond %{HTTP_HOST} ^www\.ga-toasts\.com$ [NC]
|
|
26
|
+
RewriteRule ^(.*)$ https://ga-toasts.com/$1 [R=301,L]
|
|
27
|
+
|
|
28
|
+
RewriteCond %{HTTPS} off
|
|
29
|
+
RewriteCond %{HTTP_HOST} ^www\.ga-toasts\.com$ [NC]
|
|
30
|
+
RewriteRule ^(.*)$ https://ga-toasts.com/$1 [R=301,L]
|
|
31
|
+
|
|
32
|
+
# Remove trailing slashes (optional - helps with duplicate content)
|
|
33
|
+
RewriteCond %{REQUEST_FILENAME} !-d
|
|
34
|
+
RewriteCond %{REQUEST_URI} (.+)/$
|
|
35
|
+
RewriteRule ^ %1 [R=301,L]
|
|
36
|
+
|
|
37
|
+
# Add trailing slash to directories (optional)
|
|
38
|
+
RewriteCond %{REQUEST_FILENAME} -d
|
|
39
|
+
RewriteCond %{REQUEST_URI} !/$
|
|
40
|
+
RewriteRule ^(.*)$ $1/ [R=301,L]
|
|
41
|
+
|
|
42
|
+
# Cache control for better performance
|
|
43
|
+
<IfModule mod_expires.c>
|
|
44
|
+
ExpiresActive On
|
|
45
|
+
ExpiresByType text/css "access plus 1 year"
|
|
46
|
+
ExpiresByType application/javascript "access plus 1 year"
|
|
47
|
+
ExpiresByType image/png "access plus 1 year"
|
|
48
|
+
ExpiresByType image/jpg "access plus 1 year"
|
|
49
|
+
ExpiresByType image/jpeg "access plus 1 year"
|
|
50
|
+
ExpiresByType image/gif "access plus 1 year"
|
|
51
|
+
ExpiresByType image/svg+xml "access plus 1 year"
|
|
52
|
+
ExpiresByType text/html "access plus 1 hour"
|
|
53
|
+
</IfModule>
|
|
54
|
+
|
|
55
|
+
# Security headers
|
|
56
|
+
<IfModule mod_headers.c>
|
|
57
|
+
Header always set X-Content-Type-Options nosniff
|
|
58
|
+
Header always set X-Frame-Options DENY
|
|
59
|
+
Header always set X-XSS-Protection "1; mode=block"
|
|
60
|
+
Header always set Referrer-Policy "strict-origin-when-cross-origin"
|
|
61
|
+
Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
|
|
62
|
+
</IfModule>
|
|
63
|
+
|
|
64
|
+
# Gzip compression
|
|
65
|
+
<IfModule mod_deflate.c>
|
|
66
|
+
AddOutputFilterByType DEFLATE text/plain
|
|
67
|
+
AddOutputFilterByType DEFLATE text/html
|
|
68
|
+
AddOutputFilterByType DEFLATE text/xml
|
|
69
|
+
AddOutputFilterByType DEFLATE text/css
|
|
70
|
+
AddOutputFilterByType DEFLATE application/xml
|
|
71
|
+
AddOutputFilterByType DEFLATE application/xhtml+xml
|
|
72
|
+
AddOutputFilterByType DEFLATE application/rss+xml
|
|
73
|
+
AddOutputFilterByType DEFLATE application/javascript
|
|
74
|
+
AddOutputFilterByType DEFLATE application/x-javascript
|
|
75
|
+
</IfModule>
|
package/README.md
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
# 🍞 GA Toasts
|
|
2
|
+
|
|
3
|
+
A modern, accessible, and feature-rich toast notification library for web applications. Built with pure vanilla JavaScript (no dependencies), GA Toasts provides beautiful, customizable notifications with smooth animations and excellent user experience.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
**Live Demo:** [https://harshad-pindoriya.github.io/gatoasts/](https://harshad-pindoriya.github.io/gatoasts/)
|
|
11
|
+
|
|
12
|
+
## ✨ Features
|
|
13
|
+
|
|
14
|
+
- 🎨 **Modern Design** - Beautiful glassmorphism effects, gradients, and smooth animations
|
|
15
|
+
- ♿ **Accessible** - Built with accessibility in mind, supporting screen readers and keyboard navigation
|
|
16
|
+
- 📱 **Responsive** - Fully responsive design that works on all device sizes
|
|
17
|
+
- 🎭 **Multiple Variants** - Support for filled, light, and default variants
|
|
18
|
+
- ⚡ **Performance** - Lightweight and optimized for performance (no jQuery dependency)
|
|
19
|
+
- 🔧 **Customizable** - Highly customizable with CSS variables and themes
|
|
20
|
+
- 🎯 **Multiple Positions** - 9 different positioning options
|
|
21
|
+
- 🎪 **Animation Effects** - Fade, slide, bounce, and scale animations
|
|
22
|
+
- ⏱️ **Smart Timing** - Auto-close with pause on hover functionality
|
|
23
|
+
- 📊 **Progress Indicators** - Visual progress bars and background fills
|
|
24
|
+
- 🎨 **Theme Support** - Light, dark, and system theme modes
|
|
25
|
+
- 🔄 **Toast Management** - Update, close, and manage multiple toasts
|
|
26
|
+
- 🚀 **Zero Dependencies** - Pure vanilla JavaScript with no external libraries required
|
|
27
|
+
|
|
28
|
+
## 🚀 Quick Start
|
|
29
|
+
|
|
30
|
+
### Installation
|
|
31
|
+
|
|
32
|
+
1. **Download the files:**
|
|
33
|
+
```bash
|
|
34
|
+
# Clone or download the repository
|
|
35
|
+
git clone https://github.com/your-username/ga-toasts.git
|
|
36
|
+
cd ga-toasts
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. **Include the library:**
|
|
40
|
+
```html
|
|
41
|
+
<!-- GA Toasts CSS -->
|
|
42
|
+
<link rel="stylesheet" href="src/variables.css">
|
|
43
|
+
<link rel="stylesheet" href="src/toasts.css">
|
|
44
|
+
|
|
45
|
+
<!-- GA Toasts JavaScript (Pure Vanilla JS - No Dependencies) -->
|
|
46
|
+
<script src="src/toasts.js"></script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Note:** No external dependencies required! The library exposes a single global `GaToasts` object in the browser.
|
|
50
|
+
|
|
51
|
+
3. **Initialize (optional):**
|
|
52
|
+
```javascript
|
|
53
|
+
// Auto-initializes on document ready
|
|
54
|
+
// Manual initialization if needed (usually not required)
|
|
55
|
+
GaToasts.init && GaToasts.init();
|
|
56
|
+
|
|
57
|
+
GaToasts.success('Hello World!');
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Basic Usage
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
// Simple success toast (title is required)
|
|
64
|
+
GaToasts.success('Operation completed successfully!', { title: 'Success' });
|
|
65
|
+
|
|
66
|
+
// Simple error toast (title is required)
|
|
67
|
+
GaToasts.error('Something went wrong!', { title: 'Error' });
|
|
68
|
+
|
|
69
|
+
// Simple warning toast (title is required)
|
|
70
|
+
GaToasts.warning('Please check your input', { title: 'Warning' });
|
|
71
|
+
|
|
72
|
+
// Simple info toast (title is required)
|
|
73
|
+
GaToasts.info('Here is some information', { title: 'Info' });
|
|
74
|
+
|
|
75
|
+
// Custom toast (title is required)
|
|
76
|
+
GaToasts.show({
|
|
77
|
+
title: 'Custom Toast',
|
|
78
|
+
message: 'This is a custom toast notification',
|
|
79
|
+
type: 'info',
|
|
80
|
+
duration: 5000
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 📚 API Reference
|
|
85
|
+
|
|
86
|
+
### Core Methods
|
|
87
|
+
|
|
88
|
+
#### `GaToasts.show(options)`
|
|
89
|
+
|
|
90
|
+
Creates and displays a toast notification.
|
|
91
|
+
|
|
92
|
+
**Parameters:**
|
|
93
|
+
- `options` (Object) - Configuration object
|
|
94
|
+
|
|
95
|
+
**Options:**
|
|
96
|
+
```javascript
|
|
97
|
+
{
|
|
98
|
+
id: 'unique-id', // Unique identifier
|
|
99
|
+
title: 'Toast Title', // Toast title (REQUIRED)
|
|
100
|
+
message: 'Toast message', // Toast message content (optional)
|
|
101
|
+
type: 'info', // Toast type: 'success', 'error', 'warning', 'info', 'primary', 'secondary'
|
|
102
|
+
duration: 5000, // Auto-close duration in ms (0 = no auto-close)
|
|
103
|
+
closable: true, // Show close button
|
|
104
|
+
position: 'top-end', // Position: 'top-start', 'top-center', 'top-end', 'middle-start', 'middle-center', 'middle-end', 'bottom-start', 'bottom-center', 'bottom-end'
|
|
105
|
+
icon: '<svg>...</svg>', // Custom icon HTML
|
|
106
|
+
actions: [], // Action buttons array
|
|
107
|
+
size: 'md', // Size: 'xs', 'sm', 'md', 'lg', 'xl'
|
|
108
|
+
variant: '', // Variant: '', 'filled', 'light'
|
|
109
|
+
animation: 'slide', // Animation: 'fade', 'slide', 'bounce', 'scale'
|
|
110
|
+
clickToClose: false, // Close on click
|
|
111
|
+
progress: true, // Show progress bar
|
|
112
|
+
progressBackground: true, // Show background fill
|
|
113
|
+
pauseOnHover: true, // Pause countdown on hover
|
|
114
|
+
glassmorphism: true // Enable glassmorphism effect
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### `GaToasts.success(message, options)`
|
|
119
|
+
|
|
120
|
+
Creates a success toast.
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
GaToasts.success('Operation completed!', {
|
|
124
|
+
title: 'Success',
|
|
125
|
+
duration: 3000,
|
|
126
|
+
position: 'top-center'
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### `GaToasts.error(message, options)`
|
|
131
|
+
|
|
132
|
+
Creates an error toast.
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
GaToasts.error('Something went wrong!', {
|
|
136
|
+
title: 'Error',
|
|
137
|
+
duration: 8000,
|
|
138
|
+
closable: true
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### `GaToasts.warning(message, options)`
|
|
143
|
+
|
|
144
|
+
Creates a warning toast.
|
|
145
|
+
|
|
146
|
+
```javascript
|
|
147
|
+
GaToasts.warning('Please check your input', {
|
|
148
|
+
title: 'Warning',
|
|
149
|
+
duration: 6000
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### `GaToasts.info(message, options)`
|
|
154
|
+
|
|
155
|
+
Creates an info toast.
|
|
156
|
+
|
|
157
|
+
```javascript
|
|
158
|
+
GaToasts.info('Here is some information', {
|
|
159
|
+
title: 'Info',
|
|
160
|
+
duration: 4000
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### `GaToasts.confirm(message, options)`
|
|
165
|
+
|
|
166
|
+
Creates a confirmation toast with action buttons.
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
GaToasts.confirm('Are you sure you want to delete this item?', {
|
|
170
|
+
onConfirm: function() {
|
|
171
|
+
console.log('Confirmed');
|
|
172
|
+
},
|
|
173
|
+
onCancel: function() {
|
|
174
|
+
console.log('Cancelled');
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### `GaToasts.loading(message, options)`
|
|
180
|
+
|
|
181
|
+
Creates a loading toast.
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
const loadingToast = GaToasts.loading('Processing...');
|
|
185
|
+
|
|
186
|
+
// Close when done
|
|
187
|
+
setTimeout(() => {
|
|
188
|
+
GaToasts.close(loadingToast);
|
|
189
|
+
GaToasts.success('Done!');
|
|
190
|
+
}, 3000);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Management Methods
|
|
194
|
+
|
|
195
|
+
#### `GaToasts.close(toast)`
|
|
196
|
+
|
|
197
|
+
Closes a specific toast.
|
|
198
|
+
|
|
199
|
+
```javascript
|
|
200
|
+
const toast = GaToasts.show({ message: 'Test' });
|
|
201
|
+
GaToasts.close(toast);
|
|
202
|
+
// or
|
|
203
|
+
GaToasts.close('#toast-id');
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
#### `GaToasts.closeAll()`
|
|
207
|
+
|
|
208
|
+
Closes all visible toasts.
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
GaToasts.closeAll();
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### `GaToasts.clear(type)`
|
|
215
|
+
|
|
216
|
+
Clears all toasts of a specific type.
|
|
217
|
+
|
|
218
|
+
```javascript
|
|
219
|
+
GaToasts.clear('error'); // Clear only error toasts
|
|
220
|
+
GaToasts.clear(); // Clear all toasts
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### `GaToasts.update(toastId, options)`
|
|
224
|
+
|
|
225
|
+
Updates an existing toast.
|
|
226
|
+
|
|
227
|
+
```javascript
|
|
228
|
+
const toast = GaToasts.show({
|
|
229
|
+
id: 'updateable-toast',
|
|
230
|
+
message: 'Initial message',
|
|
231
|
+
type: 'info'
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Update after 2 seconds
|
|
235
|
+
setTimeout(() => {
|
|
236
|
+
GaToasts.update('updateable-toast', {
|
|
237
|
+
message: 'Updated message!',
|
|
238
|
+
type: 'success'
|
|
239
|
+
});
|
|
240
|
+
}, 2000);
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### `GaToasts.getCount(type)`
|
|
244
|
+
|
|
245
|
+
Gets the count of visible toasts.
|
|
246
|
+
|
|
247
|
+
```javascript
|
|
248
|
+
const totalCount = GaToasts.getCount();
|
|
249
|
+
const errorCount = GaToasts.getCount('error');
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### `GaToasts.exists(toastId)`
|
|
253
|
+
|
|
254
|
+
Checks if a toast exists.
|
|
255
|
+
|
|
256
|
+
```javascript
|
|
257
|
+
if (GaToasts.exists('my-toast')) {
|
|
258
|
+
console.log('Toast exists');
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### `GaToasts.get(toastId)`
|
|
263
|
+
|
|
264
|
+
Gets a toast element by ID.
|
|
265
|
+
|
|
266
|
+
```javascript
|
|
267
|
+
const toast = GaToasts.get('my-toast');
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Utility Methods
|
|
271
|
+
|
|
272
|
+
#### `GaToasts.modern(message, options)`
|
|
273
|
+
|
|
274
|
+
Creates a modern-styled toast with enhanced features.
|
|
275
|
+
|
|
276
|
+
```javascript
|
|
277
|
+
GaToasts.modern('Modern toast with enhanced styling!', {
|
|
278
|
+
type: 'success',
|
|
279
|
+
glassmorphism: true
|
|
280
|
+
});
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### `GaToasts.notification(title, message, options)`
|
|
284
|
+
|
|
285
|
+
Creates a notification-style toast.
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
GaToasts.notification('New Message', 'You have a new message from John', {
|
|
289
|
+
type: 'info',
|
|
290
|
+
duration: 5000
|
|
291
|
+
});
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### `GaToasts.setDefaults(defaults)`
|
|
295
|
+
|
|
296
|
+
Sets global default options.
|
|
297
|
+
|
|
298
|
+
```javascript
|
|
299
|
+
GaToasts.setDefaults({
|
|
300
|
+
position: 'top-center',
|
|
301
|
+
duration: 3000,
|
|
302
|
+
animation: 'fade'
|
|
303
|
+
});
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## 🎨 Customization
|
|
307
|
+
|
|
308
|
+
### CSS Variables
|
|
309
|
+
|
|
310
|
+
GA Toasts uses CSS custom properties for easy theming:
|
|
311
|
+
|
|
312
|
+
```css
|
|
313
|
+
:root {
|
|
314
|
+
/* Colors */
|
|
315
|
+
--ga-primary: #0073aa;
|
|
316
|
+
--ga-success: #00a32a;
|
|
317
|
+
--ga-error: #d63638;
|
|
318
|
+
--ga-warning: #dba617;
|
|
319
|
+
--ga-info: #72aee6;
|
|
320
|
+
|
|
321
|
+
/* Spacing */
|
|
322
|
+
--ga-space-sm: 8px;
|
|
323
|
+
--ga-space-md: 16px;
|
|
324
|
+
--ga-space-lg: 24px;
|
|
325
|
+
|
|
326
|
+
/* Typography */
|
|
327
|
+
--ga-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
328
|
+
--ga-text-sm: 14px;
|
|
329
|
+
--ga-text-base: 16px;
|
|
330
|
+
|
|
331
|
+
/* Animations */
|
|
332
|
+
--ga-duration-300: 300ms;
|
|
333
|
+
--ga-ease-out: cubic-bezier(0, 0, 0.2, 1);
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Themes
|
|
338
|
+
|
|
339
|
+
#### Light Theme (Default)
|
|
340
|
+
```html
|
|
341
|
+
<html data-ga-theme="light">
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
#### Dark Theme
|
|
345
|
+
```html
|
|
346
|
+
<html data-ga-theme="dark">
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
#### System Theme
|
|
350
|
+
```html
|
|
351
|
+
<html data-ga-theme="system">
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Custom Styling
|
|
355
|
+
|
|
356
|
+
```css
|
|
357
|
+
/* Custom toast styles */
|
|
358
|
+
.ga-toast.my-custom-toast {
|
|
359
|
+
background: linear-gradient(135deg, #667eea, #764ba2);
|
|
360
|
+
border: 2px solid #fff;
|
|
361
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.ga-toast.my-custom-toast .ga-toast-title {
|
|
365
|
+
color: white;
|
|
366
|
+
font-weight: 700;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.ga-toast.my-custom-toast .ga-toast-body {
|
|
370
|
+
color: rgba(255, 255, 255, 0.9);
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## 📱 Responsive Design
|
|
375
|
+
|
|
376
|
+
GA Toasts automatically adapts to different screen sizes:
|
|
377
|
+
|
|
378
|
+
- **Desktop**: Full-width toasts with all features
|
|
379
|
+
- **Tablet**: Optimized spacing and sizing
|
|
380
|
+
- **Mobile**: Full-width toasts with simplified layout
|
|
381
|
+
|
|
382
|
+
### Mobile Optimizations
|
|
383
|
+
|
|
384
|
+
- Touch-friendly close buttons
|
|
385
|
+
- Optimized spacing for small screens
|
|
386
|
+
- Simplified animations for better performance
|
|
387
|
+
- Stacked layout for multiple toasts
|
|
388
|
+
|
|
389
|
+
## ♿ Accessibility
|
|
390
|
+
|
|
391
|
+
GA Toasts is built with accessibility in mind:
|
|
392
|
+
|
|
393
|
+
- **Screen Reader Support**: Proper ARIA labels and roles
|
|
394
|
+
- **Keyboard Navigation**: Full keyboard support
|
|
395
|
+
- **High Contrast**: Support for high contrast mode
|
|
396
|
+
- **Reduced Motion**: Respects user's motion preferences
|
|
397
|
+
- **Focus Management**: Proper focus handling
|
|
398
|
+
|
|
399
|
+
### Accessibility Features
|
|
400
|
+
|
|
401
|
+
```javascript
|
|
402
|
+
// Toast with proper ARIA attributes
|
|
403
|
+
GaToasts.show({
|
|
404
|
+
message: 'Important notification',
|
|
405
|
+
type: 'error',
|
|
406
|
+
role: 'alert', // For screen readers
|
|
407
|
+
duration: 0 // Don't auto-close important messages
|
|
408
|
+
});
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
## 🎪 Animation Effects
|
|
412
|
+
|
|
413
|
+
### Built-in Animations
|
|
414
|
+
|
|
415
|
+
1. **Fade** - Smooth opacity transition
|
|
416
|
+
2. **Slide** - Slides in from the side
|
|
417
|
+
3. **Bounce** - Bouncy entrance effect
|
|
418
|
+
4. **Scale** - Scales up from center
|
|
419
|
+
|
|
420
|
+
### Custom Animations
|
|
421
|
+
|
|
422
|
+
```css
|
|
423
|
+
/* Custom shake animation */
|
|
424
|
+
.ga-toast-shake {
|
|
425
|
+
animation: shake 0.5s ease-in-out;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
@keyframes shake {
|
|
429
|
+
0%, 100% { transform: translateX(0); }
|
|
430
|
+
10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
|
|
431
|
+
20%, 40%, 60%, 80% { transform: translateX(2px); }
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
## 🔧 Advanced Usage
|
|
436
|
+
|
|
437
|
+
### Action Buttons
|
|
438
|
+
|
|
439
|
+
```javascript
|
|
440
|
+
GaToasts.show({
|
|
441
|
+
message: 'File uploaded successfully!',
|
|
442
|
+
type: 'success',
|
|
443
|
+
actions: [
|
|
444
|
+
{
|
|
445
|
+
text: 'View File',
|
|
446
|
+
class: 'ga-btn-primary',
|
|
447
|
+
click: function(e, toast) {
|
|
448
|
+
// Handle view action
|
|
449
|
+
window.open('/file.pdf');
|
|
450
|
+
GaToasts.close(toast);
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
text: 'Dismiss',
|
|
455
|
+
class: 'ga-btn-secondary',
|
|
456
|
+
click: function(e, toast) {
|
|
457
|
+
GaToasts.close(toast);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
]
|
|
461
|
+
});
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Custom Icons
|
|
465
|
+
|
|
466
|
+
```javascript
|
|
467
|
+
GaToasts.show({
|
|
468
|
+
message: 'Custom icon toast',
|
|
469
|
+
type: 'info',
|
|
470
|
+
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>'
|
|
471
|
+
});
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### Progress Indicators
|
|
475
|
+
|
|
476
|
+
```javascript
|
|
477
|
+
// Toast with progress bar
|
|
478
|
+
GaToasts.show({
|
|
479
|
+
message: 'Processing...',
|
|
480
|
+
type: 'info',
|
|
481
|
+
progress: true,
|
|
482
|
+
duration: 5000
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
// Toast with background fill
|
|
486
|
+
GaToasts.show({
|
|
487
|
+
message: 'Uploading file...',
|
|
488
|
+
type: 'primary',
|
|
489
|
+
progressBackground: true,
|
|
490
|
+
duration: 10000
|
|
491
|
+
});
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### Toast Stacks
|
|
495
|
+
|
|
496
|
+
```javascript
|
|
497
|
+
// Show multiple toasts in a stack
|
|
498
|
+
for (let i = 1; i <= 5; i++) {
|
|
499
|
+
setTimeout(() => {
|
|
500
|
+
GaToasts.show({
|
|
501
|
+
message: `Stacked toast ${i}`,
|
|
502
|
+
type: 'info',
|
|
503
|
+
size: 'sm'
|
|
504
|
+
});
|
|
505
|
+
}, i * 200);
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
## 🌐 Browser Support
|
|
510
|
+
|
|
511
|
+
- **Chrome** 60+
|
|
512
|
+
- **Firefox** 55+
|
|
513
|
+
- **Safari** 12+
|
|
514
|
+
- **Edge** 79+
|
|
515
|
+
- **IE** 11+ (with polyfills for modern features)
|
|
516
|
+
|
|
517
|
+
**Note:** Since we removed jQuery dependency, the library is now lighter and faster while maintaining the same browser support.
|
|
518
|
+
|
|
519
|
+
## 📦 File Structure
|
|
520
|
+
|
|
521
|
+
```
|
|
522
|
+
ga-toasts/
|
|
523
|
+
├── src/
|
|
524
|
+
│ ├── toasts.js # JavaScript functionality
|
|
525
|
+
│ ├── toasts.css # Main toast styles
|
|
526
|
+
│ └── variables.css # CSS custom properties
|
|
527
|
+
├── index.html # Interactive demo page
|
|
528
|
+
└── README.md # This documentation
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
## 🤝 Contributing
|
|
532
|
+
|
|
533
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
534
|
+
|
|
535
|
+
1. Fork the repository
|
|
536
|
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
537
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
538
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
539
|
+
5. Open a Pull Request
|
|
540
|
+
|
|
541
|
+
## 📄 License
|
|
542
|
+
|
|
543
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
544
|
+
|
|
545
|
+
## 🙏 Acknowledgments
|
|
546
|
+
|
|
547
|
+
- Modern CSS features for beautiful styling
|
|
548
|
+
- Web accessibility guidelines for inclusive design
|
|
549
|
+
- Vanilla JavaScript community for inspiration
|
|
550
|
+
- Open source community for continuous improvement
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
Made with ❤️ by the GA Toasts team
|