From bc4149a7dc56a1872c03c097124f7bfe0b6ebcc2 Mon Sep 17 00:00:00 2001 From: Oleksandra Zarubina Date: Wed, 27 May 2026 20:26:01 +0300 Subject: [PATCH] add solution --- src/scripts/main.js | 47 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index 35d0d8f74..0c385ede0 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,7 +1,28 @@ 'use strict'; const pushNotification = (posTop, posRight, title, description, type) => { - // write code here + const notification = document.createElement('div'); + + notification.className = `notification ${type}`; + notification.style.top = `${posTop}px`; + notification.style.right = `${posRight}px`; + + const titleEl = document.createElement('h2'); + + titleEl.className = 'title'; + titleEl.textContent = title; + + const descEl = document.createElement('p'); + + descEl.textContent = description; + + notification.appendChild(titleEl); + notification.appendChild(descEl); + document.body.appendChild(notification); + + setTimeout(() => { + notification.style.display = 'none'; + }, 2000); }; pushNotification( @@ -27,3 +48,27 @@ pushNotification( 'Message example.\n ' + 'Notification should contain title and description.', 'warning', ); + +pushNotification( + 10, + 10, + 'Title of Success message', + 'Message example.\n ' + 'Notification should contain title and description.', + 'success', +); + +pushNotification( + 150, + 10, + 'Title of Error message', + 'Message example.\n ' + 'Notification should contain title and description.', + 'error', +); + +pushNotification( + 290, + 10, + 'Title of Warning message', + 'Message example.\n ' + 'Notification should contain title and description.', + 'warning', +);