Skip to content

Commit

Permalink
fix: show books after clear search value
Browse files Browse the repository at this point in the history
  • Loading branch information
nnivxix committed Dec 17, 2023
1 parent 2b7344c commit 8850377
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ <h2>Sudah dibaca 📚</h2>

<footer>
<p>
Dibangun bersama dengan 💛 oleh
Dibangun dengan 💛 oleh
<a target="_blank" href="https://github.com/nnivxix">Hanasa</a> di 🇮🇩.
</p>
</footer>
Expand Down
9 changes: 6 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const clearSearch = document.getElementById("clearSearch");
const bookSubmit = document.getElementById("bookSubmit");
const formInput = document.getElementById("inputBook");
const inputSection = document.getElementById("input_section");
const bookItems = document.getElementsByClassName("book_item");

/**
*
Expand All @@ -32,6 +33,9 @@ clearSearch.addEventListener("click", function () {
clearSearch.style.display = "none";
inputSection.classList.remove("hidden");
inputSection.classList.add("flex");
for (const bookItem of bookItems) {
bookItem.style.display = "block";
}
});

/**
Expand Down Expand Up @@ -153,8 +157,7 @@ const filterByName = (title) => {
};

function findBookByName(searchValue) {
const bookItem = document.getElementsByClassName("book_item");
for (const book of bookItem) {
for (const book of bookItems) {
const itemTitle = book.querySelector(".item-title");
if (
itemTitle.textContent
Expand Down Expand Up @@ -215,7 +218,7 @@ function renderBook(book, selector) {
book.isComplete ? "Tandai sedang dibaca" : "Tandai sudah dibaca"
}</button>
<button onClick="editBook('${book.id}')">Perbaharui Buku</button>
<button onClick="deleteBook('${book.id}','${
<button class="deleteBook" onClick="deleteBook('${book.id}','${
book.title
}')">Hapus buku</button>
</div>
Expand Down
7 changes: 7 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--main-text-color: #636363;
--second-text-color: #1B263B;
--box-color: #D9D9D9;
--danger: #e83023;
--text-box-color: #868686;
--has-read: #84DD63;
--in-read: #A2D8E4;
Expand Down Expand Up @@ -194,6 +195,11 @@ color: var(--second-text-color);
.incompleted {
background-color: var(--in-read);
}
.deleteBook {
color: var(--danger);
border: 1px solid var(--danger) !important;
}


#searchBookTitle {
background-color: var(--box-color);
Expand All @@ -214,6 +220,7 @@ color: var(--second-text-color);
margin-right: 14px;
margin-top: 8px;
cursor: pointer;
display: none;
}

footer {
Expand Down

0 comments on commit 8850377

Please sign in to comment.