mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 12:11:13 -05:00
Improve toast notifications with animated progress indicators
Update the Alpine.js toast component to include animated progress bars and refined styling for better user feedback on notifications. Replit-Commit-Author: Agent Replit-Commit-Session-Id: eff39de1-3afa-446d-a965-acaf61837fc7 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/d6d61dac-164d-45dd-929f-7dcdfd771b64/eff39de1-3afa-446d-a965-acaf61837fc7/moJlpyM
This commit is contained in:
@@ -325,51 +325,6 @@ Alpine.data('pagination', (initialPage = 1, totalPages = 1) => ({
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Toast/Alert Component
|
|
||||||
Alpine.data('toast', () => ({
|
|
||||||
toasts: [],
|
|
||||||
|
|
||||||
show(message, type = 'info', duration = 5000) {
|
|
||||||
const id = Date.now();
|
|
||||||
const toast = { id, message, type, visible: true };
|
|
||||||
|
|
||||||
this.toasts.push(toast);
|
|
||||||
|
|
||||||
if (duration > 0) {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.hide(id);
|
|
||||||
}, duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
return id;
|
|
||||||
},
|
|
||||||
|
|
||||||
hide(id) {
|
|
||||||
const toast = this.toasts.find(t => t.id === id);
|
|
||||||
if (toast) {
|
|
||||||
toast.visible = false;
|
|
||||||
setTimeout(() => {
|
|
||||||
this.toasts = this.toasts.filter(t => t.id !== id);
|
|
||||||
}, 300); // Wait for animation
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
success(message, duration) {
|
|
||||||
return this.show(message, 'success', duration);
|
|
||||||
},
|
|
||||||
|
|
||||||
error(message, duration) {
|
|
||||||
return this.show(message, 'error', duration);
|
|
||||||
},
|
|
||||||
|
|
||||||
warning(message, duration) {
|
|
||||||
return this.show(message, 'warning', duration);
|
|
||||||
},
|
|
||||||
|
|
||||||
info(message, duration) {
|
|
||||||
return this.show(message, 'info', duration);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Enhanced Authentication Modal Component
|
// Enhanced Authentication Modal Component
|
||||||
Alpine.data('authModal', (defaultMode = 'login') => ({
|
Alpine.data('authModal', (defaultMode = 'login') => ({
|
||||||
@@ -568,62 +523,6 @@ Alpine.data('authModal', (defaultMode = 'login') => ({
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Enhanced Toast Component with Better UX
|
|
||||||
Alpine.data('toast', () => ({
|
|
||||||
toasts: [],
|
|
||||||
|
|
||||||
show(message, type = 'info', duration = 5000) {
|
|
||||||
const id = Date.now() + Math.random();
|
|
||||||
const toast = {
|
|
||||||
id,
|
|
||||||
message,
|
|
||||||
type,
|
|
||||||
visible: true,
|
|
||||||
progress: 100
|
|
||||||
};
|
|
||||||
|
|
||||||
this.toasts.push(toast);
|
|
||||||
|
|
||||||
if (duration > 0) {
|
|
||||||
// Animate progress bar
|
|
||||||
const interval = setInterval(() => {
|
|
||||||
toast.progress -= (100 / (duration / 100));
|
|
||||||
if (toast.progress <= 0) {
|
|
||||||
clearInterval(interval);
|
|
||||||
this.hide(id);
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
return id;
|
|
||||||
},
|
|
||||||
|
|
||||||
hide(id) {
|
|
||||||
const toast = this.toasts.find(t => t.id === id);
|
|
||||||
if (toast) {
|
|
||||||
toast.visible = false;
|
|
||||||
setTimeout(() => {
|
|
||||||
this.toasts = this.toasts.filter(t => t.id !== id);
|
|
||||||
}, 300);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
success(message, duration = 5000) {
|
|
||||||
return this.show(message, 'success', duration);
|
|
||||||
},
|
|
||||||
|
|
||||||
error(message, duration = 7000) {
|
|
||||||
return this.show(message, 'error', duration);
|
|
||||||
},
|
|
||||||
|
|
||||||
warning(message, duration = 6000) {
|
|
||||||
return this.show(message, 'warning', duration);
|
|
||||||
},
|
|
||||||
|
|
||||||
info(message, duration = 5000) {
|
|
||||||
return this.show(message, 'info', duration);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Global Store for App State
|
// Global Store for App State
|
||||||
Alpine.store('app', {
|
Alpine.store('app', {
|
||||||
|
|||||||
Reference in New Issue
Block a user