Skip to content

Commit c95d914

Browse files
author
isid555
committed
Search Functionality upgraded for invalid inputs
1 parent e9d9c6c commit c95d914

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

script.js

+10
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ function getProjectContent(project) {
6767

6868
function renderProjectList(projects) {
6969
projectsArea.innerHTML = ""
70+
71+
if (projects.length === 0) {
72+
const noResultsMessage = document.createElement("p");
73+
noResultsMessage.className = "no-results";
74+
noResultsMessage.innerText = "No results found";
75+
projectsArea.appendChild(noResultsMessage);
76+
return;
77+
}
78+
7079
projects.forEach((project) => {
7180
const projectCard = document.createElement("div");
7281
projectCard.className = "project-card";
@@ -93,6 +102,7 @@ function filterProjects(query) {
93102
project.name.toLowerCase().includes(query.toLowerCase()) ||
94103
project.description.toLowerCase().includes(query.toLowerCase())
95104
);
105+
96106
renderProjectList(filteredProjects);
97107
}
98108

style.css

+8
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ section.hero {
182182
color: black;
183183
font-size: 13px;
184184
}
185+
.no-results {
186+
font-size: 1.5rem;
187+
color: black;
188+
text-align: center;
189+
padding: 20px;
190+
font-weight: bold;
191+
}
192+
185193
.project-card {
186194
border: 1px solid black;
187195
border-radius: 6px;

0 commit comments

Comments
 (0)