39 lines
867 B
JavaScript
39 lines
867 B
JavaScript
/**
|
||
* Toast notification system
|
||
*/
|
||
|
||
/**
|
||
* Show toast notification
|
||
* @param {string} message - Message to display
|
||
* @param {string} type - Type of notification (success, error, info)
|
||
*/
|
||
export function showNotification(message, type = 'info') {
|
||
const container = document.getElementById('toastContainer');
|
||
|
||
// Create toast element
|
||
const toast = document.createElement('div');
|
||
toast.className = `toast toast-${type}`;
|
||
|
||
// Icon based on type
|
||
const icons = {
|
||
success: '✓',
|
||
error: '✕',
|
||
info: 'ℹ'
|
||
};
|
||
|
||
toast.innerHTML = `
|
||
<span class="toast-icon">${icons[type] || 'ℹ'}</span>
|
||
<span>${message}</span>
|
||
`;
|
||
|
||
container.appendChild(toast);
|
||
|
||
// Auto-remove after 3 seconds
|
||
setTimeout(() => {
|
||
toast.classList.add('hiding');
|
||
setTimeout(() => {
|
||
container.removeChild(toast);
|
||
}, 300);
|
||
}, 3000);
|
||
}
|