mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-06 19:46:52 +03:00
25 lines
660 B
TypeScript
25 lines
660 B
TypeScript
export function showToast(
|
|
message: string,
|
|
type: 'success' | 'error',
|
|
duration: number = 3000,
|
|
) {
|
|
let container = document.querySelector('.toast-container');
|
|
if (!container) {
|
|
container = document.createElement('div');
|
|
container.className = 'toast-container';
|
|
document.body.appendChild(container);
|
|
}
|
|
|
|
const toast = document.createElement('div');
|
|
toast.className = `toast toast-${type}`;
|
|
toast.textContent = message;
|
|
|
|
container.appendChild(toast);
|
|
setTimeout(() => toast.classList.add('visible'), 100);
|
|
|
|
setTimeout(() => {
|
|
toast.classList.remove('visible');
|
|
setTimeout(() => toast.remove(), 300);
|
|
}, duration);
|
|
}
|