Skip to content
Open
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
150 changes: 59 additions & 91 deletions client/public/action.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Action Books</title>
<title>Book Categories</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
<style>
body {
Expand All @@ -13,118 +12,87 @@
padding: 20px;
background-color: #f4f4f4;
}

h1 {
text-align: center;
color: #007bff;
margin-bottom: 30px;

h3 {
color: rgb(227, 142, 31);
}

.category-title {
background-color: darkblue;
color: white;
padding: 10px;
border-radius: 5px;
text-align: center;
margin-bottom: 20px;
font-size: 24px;
h1 {
color: aliceblue;
}

.book-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
/* Grid and Card Styles */
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 20px;
}

.book {
margin: 10px;
background: #fff;
padding: 15px;
border-radius: 5px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
flex: 1 1 calc(45% - 20px); /* Two books per row */
max-width: calc(45% - 20px); /* Two books per row */
.card {
background: darkblue;
border-radius: 8px;
padding: 20px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

.book h4 {
margin: 0;
/* Hover Effects */
.card:hover {
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
background-color: #0056b3; /* Darker blue on hover */
color: white;
}

.button {
background-color: #1b6f4c;
color: white;
background-color: rgb(249, 249, 249);
color: rgb(177, 115, 2);
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 10px;
display: block;
text-align: center;
text-decoration: none;
transition: background-color 0.3s ease, color 0.3s ease;
}

/* Button Hover Effect */
.button:hover {
background-color: #f7b7a8;
}

footer {
text-align: center;
padding: 20px;
background: #333;
background-color: rgb(227, 142, 31);
color: white;
position: relative;
bottom: 0;
width: 100%;
}

.description {
color: #555;
margin-top: 5px;
font-size: 14px;
}
div{
box-shadow:10px 10px rgb(214, 230, 4) ;
}
div:hover{
color: #f45e13;
background-color: #007bff;
cursor: pointer;
}
</style>
</head>

<body >


<div class="category-title"> <h2>Action Books</h2></div>
<div id="book-list" class="book-list"></div>

<script>
const fetchBooks = async () => {
const response = await fetch('https://openlibrary.org/subjects/action.json?limit=50');
const data = await response.json();
return data.works;
};

const showBooks = async () => {
const actionBooks = await fetchBooks();
const bookList = document.getElementById('book-list');
actionBooks.forEach(book => {
const bookDiv = document.createElement('div');
bookDiv.className = 'book';
bookDiv.innerHTML = `
<h4>${book.title}</h4>
<p><strong>Author:</strong> ${book.authors.map(author => author.name).join(", ")}</p>

<p><strong>Cost:</strong> $${Math.floor(Math.random() * 20) + 10} (estimated price)</p>
`;
bookList.appendChild(bookDiv);
});
};

// Show the books on page load
showBooks();
</script>
<body>
<a href="quiz.html"><h3>Book Preference Quiz</h3></a>

<h1>Book Categories</h1>

<div class="grid">
<div class="card">
<h3>Action</h3>
<a class="button" href="action.html">Show Books</a>
</div>
<div class="card">
<h3>Thriller</h3>
<a class="button" href="thriller.html">Show Books</a>
</div>
<div class="card">
<h3>Fiction</h3>
<a class="button" href="fiction.html">Show Books</a>
</div>
<div class="card">
<h3>Tech</h3>
<a class="button" href="tech.html">Show Books</a>
</div>
<div class="card">
<h3>Philosophy</h3>
<a class="button" href="philosophy.html">Show Books</a>
</div>
<div class="card">
<h3>Manga</h3>
<a class="button" href="manga.html">Show Books</a>
</div>
</div>

</body>

</html>
71 changes: 36 additions & 35 deletions client/public/fiction.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,23 @@
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
flex: 1 1 calc(45% - 20px); /* Two books per row */
max-width: calc(45% - 20px); /* Two books per row */
transition: background-color 0.3s, color 0.3s;
}

.book h4 {
margin: 0;
}

.button {
background-color: #f76b45;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 10px;
display: block;
text-align: center;
.description {
color: #555;
margin-top: 5px;
font-size: 14px;
}

.button:hover {
background-color: #e65c39;
.book:hover {
color: #f45e13;
background-color: #007bff;
cursor: pointer;
}

footer {
Expand All @@ -75,20 +72,6 @@
bottom: 0;
width: 100%;
}

.description {
color: #555;
margin-top: 5px;
font-size: 14px;
}
div{
box-shadow:10px 10px rgb(214, 230, 4) ;
}
div:hover{
color: #f45e13;
background-color: #007bff;
cursor: pointer;
}
</style>
</head>

Expand All @@ -99,23 +82,41 @@

<script>
const fetchBooks = async () => {
// Fetching thriller books from Open Library
const response = await fetch('https://openlibrary.org/subjects/fiction.json?limit=50');
const data = await response.json();
return data.works;
try {
// Fetching thriller books from Open Library
const response = await fetch('https://openlibrary.org/subjects/fiction.json?limit=50');
if (!response.ok) {
throw new Error(`Failed to fetch data: ${response.statusText}`);
}
const data = await response.json();
return data.works;
} catch (error) {
console.error(error);
alert("Unable to load books at this time. Please try again later.");
return [];
}
};

const showBooks = async () => {
const thrillerBooks = await fetchBooks();
const bookList = document.getElementById('book-list');

thrillerBooks.forEach(book => {
const bookDiv = document.createElement('div');
bookDiv.className = 'book';
bookDiv.innerHTML = `
<h4>${book.title}</h4>
<p><strong>Author:</strong> ${book.authors.map(author => author.name).join(", ")}</p>
<p><strong>Cost:</strong> $${Math.floor(Math.random() * 20) + 10} (estimated price)</p>
`;

const title = document.createElement('h4');
title.textContent = book.title;
bookDiv.appendChild(title);

const authors = document.createElement('p');
authors.innerHTML = `<strong>Author:</strong> ${book.authors.map(author => author.name).join(", ")}`;
bookDiv.appendChild(authors);

const cost = document.createElement('p');
cost.innerHTML = `<strong>Cost:</strong> $${Math.floor(Math.random() * 20) + 10} (estimated price)`;
bookDiv.appendChild(cost);

bookList.appendChild(bookDiv);
});
};
Expand Down