Skip to content

Commit

Permalink
finished project
Browse files Browse the repository at this point in the history
  • Loading branch information
shahidafridi-321 committed Jul 6, 2024
1 parent e62011b commit e8d679c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
33 changes: 28 additions & 5 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ let displayBtn = document.querySelector('.displayBtn');
let displayContainer = document.querySelector('.output-display');



// event listener to the newbook button
newBook.addEventListener('click', () => {

Expand Down Expand Up @@ -86,6 +87,9 @@ newBook.addEventListener('click', () => {
});


// added an event listener to display button
displayBtn.addEventListener('click', display);

// function for displaying the books on the page
function display() {
myLibrary.forEach((item) => {
Expand All @@ -101,24 +105,43 @@ function display() {
});
}
// its a helper function created for creating elements
// It's a helper function created for creating elements
function createElements(container, e) {
let title = document.createElement('p');
let author = document.createElement('p');
let pages = document.createElement('p');
let read = document.createElement('p');

title.textContent = `Book Name : ${e.title}`;
author.textContent = `Written By : ${e.author}`;
// Setting content in elements
title.textContent = `Book Name: ${e.title}`;
author.textContent = `Written By: ${e.author}`;
pages.textContent = `Contains ${e.pages} Pages`;
read.textContent = `Read ? : ${e.read}`;
read.textContent = `Read? : ${e.read}`;

container.appendChild(title);
container.appendChild(author);
container.appendChild(pages);
container.appendChild(read);

let deletBtn = document.createElement('button');
deletBtn.textContent = 'Delete';
deletBtn.classList.add('delete-btn');
container.appendChild(deletBtn);

deletBtn.addEventListener('click', () => {
container.remove();
displayBtn.style.display = 'block';
});
}


// function for deleting the book
// let delBtn = document.querySelector('.delete-btn');
// delBtn.

function deleteBook() {

}

// added an event listener to display button
displayBtn.addEventListener('click', display);


7 changes: 5 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ h6 {

.newBook,
.subBtn,
.displayBtn {
.displayBtn,
.delete-btn {
width: auto;
justify-self: center;
background: none;
Expand All @@ -124,10 +125,12 @@ h6 {
font-family: roboto mono;
font-weight: bold;
transition: 0.8s all;
margin-top: 10px;
}

.newBook:hover,
.displayBtn:hover {
.displayBtn:hover,
.delete-btn:hover{
background: #e879f9;
color: #0f172a;
transition: 0.8s all;
Expand Down

0 comments on commit e8d679c

Please sign in to comment.