-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.js
More file actions
40 lines (34 loc) · 1.19 KB
/
module.js
File metadata and controls
40 lines (34 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
export function showErrToast(message, duration = 3000) {
let container = document.getElementById('toast-container');
if (!container) {
container = document.createElement('div');
container.id = 'toast-container';
document.body.appendChild(container);
}
const errToast = document.createElement('div');
errToast.className = 'toast-err';
errToast.textContent = message;
container.appendChild(errToast);
setTimeout(() => errToast.classList.add('show'), 100);
setTimeout(() => {
errToast.classList.remove('show');
setTimeout(() => errToast.remove(), 400);
}, duration);
};
export function showInfToast(message, duration = 3000) {
let container = document.getElementById('toast-container');
if (!container) {
container = document.createElement('div');
container.id = 'toast-container';
document.body.appendChild(container);
}
const infToast = document.createElement('div');
infToast.className = 'toast-inf';
infToast.textContent = message;
container.appendChild(infToast);
setTimeout(() => infToast.classList.add('show'), 100);
setTimeout(() => {
infToast.classList.remove('show');
setTimeout(() => infToast.remove(), 400);
}, duration);
};