/**
* StreamFlow - Toast Notification Component
*/
const TOAST_DURATION = 4000;
/**
* Show a toast notification
* @param {string} message - Toast message
* @param {string} type - Toast type: 'success', 'error', 'info'
*/
export function showToast(message, type = 'info') {
const container = document.getElementById('toastContainer');
if (!container) return;
const toast = document.createElement('div');
toast.className = `toast toast--${type}`;
toast.innerHTML = `
${escapeHtml(message)}
`;
container.appendChild(toast);
// Auto-remove after duration
setTimeout(() => {
toast.style.animation = 'slideIn 0.3s ease reverse';
setTimeout(() => toast.remove(), 300);
}, TOAST_DURATION);
}
/**
* Get icon SVG path for toast type
* @param {string} type - Toast type
* @returns {string} SVG path
*/
function getToastIcon(type) {
switch (type) {
case 'success':
return '';
case 'error':
return '';
default:
return '';
}
}
/**
* Escape HTML special characters
* @param {string} str - Input string
* @returns {string} Escaped string
*/
function escapeHtml(str) {
if (!str) return '';
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}