Skip to content

Commit

Permalink
Merge pull request #45 from manisacharya/search-card-fix
Browse files Browse the repository at this point in the history
Search card issue fix
  • Loading branch information
aparna03dubey authored Oct 30, 2023
2 parents c0ccf97 + ba86f02 commit 567614d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ <h1>Add Your Card</h1>
<div class="search-container">
<input type="text" id="searchInput" onkeyup="searchCards()" placeholder="Search for names...">
</div>

<!-- Add empty state when search result is empty -->
<div id="empty-state"></div>

<div class="cardholder">
<div class="card">
<div class="name">
Expand Down Expand Up @@ -369,13 +373,15 @@ <h2>Varsha Awasthi</h2>
// Get the name in the card and convert it to lowercase
var name = card.querySelector('.name h2').innerText.toLowerCase();

document.getElementById('empty-state').innerHTML ="";
// Check if the input value is present in the card name
if (name.includes(input)) {
// If yes, display the card
card.style.display = 'block';
card.style.display = 'flex'; // Fix issue of displaying different html content of card
} else {
// If not, hide the card
card.style.display = 'none';
document.getElementById('empty-state').innerHTML ="<h1>Card not found!!</h1>";
}
});
}
Expand Down
10 changes: 10 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ a {
color: #7300ff;
}

#empty-state {
font-size: larger;
font-weight: bolder;
color: aliceblue;
display: flex;
width: 100%;
justify-content: center;
animation: color-animation 5s infinite;
}

@keyframes border-animation {
0% {
border-color: rgb(160, 140, 212);
Expand Down

0 comments on commit 567614d

Please sign in to comment.