-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnotification.js
More file actions
27 lines (23 loc) · 973 Bytes
/
notification.js
File metadata and controls
27 lines (23 loc) · 973 Bytes
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
export const notification = (msg, type) => {
const notification = document.querySelector('.notification');
const notificationImg = document.querySelector('.notification-icon');
const notificationType = document.querySelector('.notification-type');
const notificationMsg = document.querySelector('.notification-message');
notificationImg.style.width = '20px'
notificationImg.style.height = '20px'
if (type === 'error') {
notificationImg.src = './assets/error.png';
} else if (type === 'warning') {
notificationImg.src = './assets/warning.png';
} else if (type === 'success') {
notificationImg.src = './assets/success.png';
}
notificationType.textContent = type;
notificationMsg.textContent = msg;
setTimeout(() => {
notification.classList.add('notification-active');
}, 100);
setTimeout(() => {
notification.classList.remove('notification-active');
}, 3000);
};