From 7775dd798e29b05a01f2cf15d1284d7d3577b5a3 Mon Sep 17 00:00:00 2001 From: Rohan Sircar Date: Tue, 5 Nov 2019 21:48:13 +0530 Subject: [PATCH] Added code for chat card Chat card displayed only when at least one user selected User box highlighted when selected Hover color for user box added --- chatto/src/main/resources/static/css/chat.css | 12 +++++++++++ chatto/src/main/resources/static/js/chat.js | 8 ++++++++ chatto/src/main/resources/templates/chat.html | 20 +++++++++++++------ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/chatto/src/main/resources/static/css/chat.css b/chatto/src/main/resources/static/css/chat.css index e29194f..50c704b 100644 --- a/chatto/src/main/resources/static/css/chat.css +++ b/chatto/src/main/resources/static/css/chat.css @@ -7,6 +7,18 @@ html { background: linear-gradient(to right, #91EAE4, #86A8E7, #7F7FD5); } +.user-box:hover { + background-color: rgba(0, 0, 0, 0.1); +} + +.active:hover { + background-color: rgba(0, 0, 0, 0.4); +} + +.no-user-selected-h2 { + color: rgba(255, 255, 255, 0.4); +} + .chat { margin-top: auto; margin-bottom: auto; diff --git a/chatto/src/main/resources/static/js/chat.js b/chatto/src/main/resources/static/js/chat.js index 971e0c7..d6cdaec 100644 --- a/chatto/src/main/resources/static/js/chat.js +++ b/chatto/src/main/resources/static/js/chat.js @@ -57,8 +57,16 @@ for (let i = 0; i < userBoxes.length; i++) { let current = document.getElementsByClassName('user-box active'); if (current.length > 0) { current[0].className = current[0].className.replace(" active", ""); + } // Add the active class to the current/clicked button + else if (current.length == 0) { + document.getElementById('no-user-selected').hidden = true; + document.getElementById('chat-card').hidden = false; + } + let words = this.innerText.split("\n"); + // console.log(words); + document.getElementById('user-name-span').innerText = 'Chat with ' + words[1]; this.className += " active"; }) } diff --git a/chatto/src/main/resources/templates/chat.html b/chatto/src/main/resources/templates/chat.html index 71dce53..a6cb09e 100644 --- a/chatto/src/main/resources/templates/chat.html +++ b/chatto/src/main/resources/templates/chat.html @@ -44,7 +44,7 @@
-
+
@@ -91,7 +91,16 @@
-
+
+
+
+
+

Please select a user

+
+
+
+
+