From ffb361c2407cf624810ab5552a89a80a42282ccd Mon Sep 17 00:00:00 2001 From: Mathanraj Date: Fri, 6 Oct 2023 14:56:02 +0530 Subject: [PATCH] Added no profile text --- css/style.css | 9 +++++++++ index.html | 1 + js/script.js | 14 ++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/css/style.css b/css/style.css index bea9cde..1fcf60c 100644 --- a/css/style.css +++ b/css/style.css @@ -62,6 +62,14 @@ h1 { padding: 20px; } +#no-profile +{ + text-align: center; + padding: 20px; + font-family: "PT Serif", serif; + display: none; +} + .profile { background-color: var(--clr-secondary); border-radius: 10px; @@ -75,6 +83,7 @@ h1 { .profile:hover { background-color: var(--clr-profile-hover); } + .pfp img { width: 100px; height: 100px; diff --git a/index.html b/index.html index 54fca11..a96c322 100644 --- a/index.html +++ b/index.html @@ -33,6 +33,7 @@

Dev Profiles

+
No Profile Found
diff --git a/js/script.js b/js/script.js index 65a0a07..d55192c 100644 --- a/js/script.js +++ b/js/script.js @@ -1,21 +1,27 @@ const searchInput = document.getElementById('searchInput'); const profiles = document.querySelectorAll('.profile'); - +const noProfileDiv = document.getElementById('no-profile'); searchInput.addEventListener('input', filterProfiles); function filterProfiles() { const query = searchInput.value.toLowerCase(); - + let hasMatchingProfile = false; profiles.forEach((profile) => { const name = profile.querySelector('.name').textContent.toLowerCase(); const skills = profile.querySelector('.skills').textContent.toLowerCase(); - if (name.includes(query) || skills.includes(query)) { - profile.style.display = 'block'; // Show matching profiles + hasMatchingProfile = true; + profile.style.display = 'block'; // Show matching profiles } else { profile.style.display = 'none'; // Hide non-matching profiles } }); + if (hasMatchingProfile) { + noProfileDiv.style.display = 'none'; + } else { + noProfileDiv.style.display = 'block'; + } + }