17 lines
636 B
JavaScript
Executable file
17 lines
636 B
JavaScript
Executable file
// toast.js — shared toast notification utility
|
||
|
||
export function showToast(message, type = 'info', duration = 3000) {
|
||
const container = document.getElementById('toast-container');
|
||
if (!container) return;
|
||
|
||
const icons = { success: '✓', error: '✕', info: 'ℹ' };
|
||
const toast = document.createElement('div');
|
||
toast.className = `toast ${type}`;
|
||
toast.textContent = `${icons[type] ?? 'ℹ'} ${message}`;
|
||
container.appendChild(toast);
|
||
|
||
setTimeout(() => {
|
||
toast.style.cssText += 'opacity:0;transform:translateY(8px);transition:opacity .3s,transform .3s';
|
||
setTimeout(() => toast.remove(), 300);
|
||
}, duration);
|
||
}
|