Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search List added for components #18

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions components.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
</ul>
<form class="d-flex" role="search">
<input class="form-control me-3" type="search" placeholder="Search for the components"
aria-label="Search" />
<button class="btn btn-outline-success" type="submit">
aria-label="Search" id="searchInput" />
<button class="btn btn-outline-success" type="button" onclick="searchComponents()">
Search
</button>
</form>
Expand All @@ -39,26 +39,32 @@
</nav>

<div class="wrapper">
<!-- card-1 -->
<div class="card">

<div class="poster"><a href="components/Login_page/login.html"><img src="images/pexels-bich-tran-2481177.jpg" alt="" /></a></div>
<div class="poster"><a href="components/Login_page/login.html"><img
src="images/pexels-bich-tran-2481177.jpg" alt="" /></a></div>
<div class="details">
<h1>Login Page</h1>
<h2>By : 12Kishan</h2>
</div>
</div>

<!-- card-2 -->
<div class="card">
<div class="poster"><a href="components/contact_form/index.html"><img src="images/contact.png" alt="" /></a></div>
<div class="poster"><a href="components/contact_form/index.html"><img src="images/contact.png" alt="" /></a>
</div>
<div class="details">
<h1>Contact Form</h1>
<h1>Contact Form</h1>
<h2>By : NaitikPatel-325</h2>
</div>
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
crossorigin="anonymous"></script>

<script src="script.js"></script>
</body>

</html>
19 changes: 19 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function searchComponents() {
const searchInput = document.getElementById("searchInput").value.toLowerCase();
const cards = document.querySelectorAll(".card");


cards.forEach(card => {
const title = card.querySelector(".details h1").textContent.toLowerCase();
const author = card.querySelector(".details h2").textContent.toLowerCase();
console.log(title, author);

if (title.includes(searchInput) || author.includes(searchInput)) {
card.style.display = "block";
foundResults = true;
} else {
card.style.display = "none";
}
});

}
Loading