-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4994 from jainaryan04/patch-1
add book recommendation
- Loading branch information
Showing
4 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const books = [ | ||
{ | ||
title: "To Kill a Mockingbird", | ||
author: "Harper Lee", | ||
genre: "Fiction", | ||
description: "A novel about racial injustice in the Deep South." | ||
}, | ||
{ | ||
title: "1984", | ||
author: "George Orwell", | ||
genre: "Dystopian", | ||
description: "A totalitarian regime uses surveillance to control its citizens." | ||
}, | ||
{ | ||
title: "The Great Gatsby", | ||
author: "F. Scott Fitzgerald", | ||
genre: "Classic", | ||
description: "A story of love, wealth, and social change in the 1920s." | ||
}, | ||
{ | ||
title: "The Catcher in the Rye", | ||
author: "J.D. Salinger", | ||
genre: "Fiction", | ||
description: "A young man struggles with the pressures of adulthood." | ||
} | ||
]; | ||
|
||
document.getElementById("recommend-btn").addEventListener("click", function() { | ||
const randomIndex = Math.floor(Math.random() * books.length); | ||
const book = books[randomIndex]; | ||
|
||
document.getElementById("book-title").textContent = book.title; | ||
document.getElementById("book-author").textContent = `Author: ${book.author}`; | ||
document.getElementById("book-genre").textContent = `Genre: ${book.genre}`; | ||
document.getElementById("book-description").textContent = book.description; | ||
|
||
document.getElementById("book-info").style.display = "block"; | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Book Recommendations</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
<body> | ||
<div class="book-container"> | ||
<!-- Back Button --> | ||
<button id="back-btn" onclick="window.history.back()">Go Back</button> | ||
|
||
<button id="recommend-btn">Get Random Book Recommendation</button> | ||
|
||
<div id="book-info" class="book-info"> | ||
<h2 id="book-title">Title</h2> | ||
<p id="book-author">Author</p> | ||
<p id="book-genre">Genre</p> | ||
<p id="book-description">Description</p> | ||
</div> | ||
</div> | ||
|
||
<script src="book.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
body { | ||
font-family: 'Poppins', sans-serif; | ||
background-color: #f0f8ff; | ||
text-align: center; | ||
margin: 50px; | ||
padding: 0; | ||
} | ||
|
||
.book-container { | ||
margin-top: 50px; | ||
} | ||
|
||
button { | ||
padding: 12px 30px; | ||
font-size: 18px; | ||
font-weight: 600; | ||
background-color: #FF6F61; | ||
color: white; | ||
border: none; | ||
border-radius: 12px; | ||
cursor: pointer; | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 10px; | ||
transition: all 0.3s ease; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
margin-bottom: 20px; | ||
} | ||
|
||
button:hover { | ||
background-color: #FFB03B; | ||
transform: translateY(-3px); | ||
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); | ||
} | ||
|
||
.book-info { | ||
margin-top: 20px; | ||
border: 2px solid #FF6F61; | ||
padding: 20px; | ||
border-radius: 12px; | ||
background-color: #fff7f1; | ||
display: none; | ||
text-align: left; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
h2 { | ||
font-size: 28px; | ||
color: #FF6F61; | ||
font-weight: 600; | ||
margin-bottom: 10px; | ||
text-transform: uppercase; | ||
letter-spacing: 2px; | ||
} | ||
|
||
p { | ||
font-size: 18px; | ||
color: #333; | ||
line-height: 1.5; | ||
} | ||
|
||
button:focus { | ||
outline: none; | ||
box-shadow: 0 0 8px rgba(255, 111, 97, 0.6); | ||
} | ||
|
||
.book-info { | ||
animation: fadeIn 0.5s ease; | ||
} | ||
|
||
@keyframes fadeIn { | ||
0% { | ||
opacity: 0; | ||
transform: translateY(20px); | ||
} | ||
100% { | ||
opacity: 1; | ||
transform: translateY(0); | ||
} | ||
} | ||
|
||
#back-btn { | ||
padding: 12px 30px; | ||
font-size: 18px; | ||
font-weight: 600; | ||
background-color: #FF6F61; | ||
color: white; | ||
border: none; | ||
border-radius: 12px; | ||
cursor: pointer; | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 10px; | ||
transition: all 0.3s ease; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
margin-bottom: 20px; | ||
} | ||
|
||
#back-btn:hover { | ||
background-color: #FFB03B; | ||
transform: translateY(-3px); | ||
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); | ||
} | ||
|