From de4797af987543a2462896b1053d33b6779fc670 Mon Sep 17 00:00:00 2001 From: Kiran Date: Mon, 21 Oct 2024 21:12:32 +0530 Subject: [PATCH 1/5] Feedback form - Toast msg addition --- assets/css/style.css | 12 ++++++------ assets/js/script.js | 33 ++++++++++++++++++++++++--------- index.html | 8 +++++++- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index 672db37f..c9d52755 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -677,14 +677,10 @@ button { cursor: pointer; } -button:hover { - background-color: #45a049; -} - -.feedbackPopUp { +.feedbackRequestPopUps { position: fixed; transform: translate(120%); - transition: all 1s ease-in-out; + transition: all 0.1s ease-in-out; right: 20px; bottom: 100px; background-color: hsl(357, 100%, 75%); @@ -696,6 +692,10 @@ button:hover { z-index: 1000; } +button:hover { + background-color: #45a049; +} + .PopUpDisplay { transition: all 1.5s ease-in-out; transform: translate(0); diff --git a/assets/js/script.js b/assets/js/script.js index 8ac10063..ab107c29 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -93,7 +93,7 @@ document.getElementById('closeModal').onclick = function() { document.getElementById('nextToFeedback').onclick = function() { const selectedEmoji = document.querySelector('.emoji.selected'); if (!selectedEmoji) { - alert('Please select an emotion!'); + selectEmotionPopUpDisplay() return; } selectedEmotion = selectedEmoji.dataset.value; @@ -110,7 +110,7 @@ document.querySelectorAll('.emoji').forEach(emoji => { document.getElementById('nextToEmail').onclick = function() { if (!document.getElementById('feedback').value) { - alert('Please provide your feedback!'); + selectFeedbackRequestPopUp() return; } document.getElementById('step2').style.display = 'none'; @@ -129,7 +129,7 @@ document.getElementById('backToFeedback').onclick = function() { window.onload = () => { if (sessionStorage.getItem('showPopUp') === 'true') { - popUpDisplay(); + feedbackPopUpSuccessDisplay() sessionStorage.removeItem('showPopUp'); } }; @@ -143,11 +143,26 @@ document.getElementById('feedbackForm').onsubmit = function(event) { window.location.reload(); }; -const popUpDisplay = () => { +const showAndHidePopUp = (selector, delayShow = 100, delayHide = 3000, showTranslate = 'translate(0)', hideTranslate = 'translate(120%)') => { setTimeout(() => { - document.querySelector('.feedbackPopUp').style.transform = 'translate(0)'; + const element = document.querySelector(selector) + if (element) { + element.style.transform = showTranslate setTimeout(() => { - document.querySelector('.feedbackPopUp').style.transform = 'translate(120%)'; - }, 3000); - }, 1000); -}; \ No newline at end of file + element.style.transform = hideTranslate + }, delayHide) + } + }, delayShow) +} + +const selectFeedbackRequestPopUp = () => { + showAndHidePopUp('.feedbackRequestPopUp', 100, 3000) +} + +const feedbackPopUpSuccessDisplay = () => { + showAndHidePopUp('.feedbackPopUpSuccess', 100, 3000) +} + +const selectEmotionPopUpDisplay = () => { + showAndHidePopUp('.selectEmotionPopUp', 100, 3000) +} \ No newline at end of file diff --git a/index.html b/index.html index bb7c10f4..04f1fd7d 100644 --- a/index.html +++ b/index.html @@ -267,11 +267,17 @@

Your Email

-
+
Thank you for your Feedback
+
+ Please select an emotion! +
+
+ Please provide your feedback! +