Skip to content

Commit 978394b

Browse files
committed
Readinglist homework
1 parent e952894 commit 978394b

3 files changed

Lines changed: 47 additions & 4 deletions

File tree

Sprint-3/reading-list/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
<title>Reading list app</title>
88
</head>
99
<body>
10-
<div id="content">
11-
<ul id="reading-list"></ul>
12-
</div>
10+
<h1>My Reading List</h1>
11+
<div id="book-list"></div>
1312
<script src="script.js"></script>
1413
</body>
1514
</html>

Sprint-3/reading-list/script.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,25 @@ const books = [
2121
},
2222
];
2323

24+
function readingList(books) {
25+
const bookList = document.getElementById("book-list");
26+
27+
books.forEach((book) => {
28+
const card = document.createElement("div");
29+
card.classList.add("book-card");
30+
card.classList.add(book.alreadyRead ? "read" : "unread");
31+
32+
card.innerHTML = `
33+
<img src="${book.bookCoverImage}" alt="${book.title}" />
34+
<div>
35+
<h2>${book.title}</h2>
36+
<p>By ${book.author}</p>
37+
<p>${book.alreadyRead ? "Already read ✅" : "Not read yet 📖"}</p>
38+
</div>
39+
`;
40+
41+
bookList.appendChild(card);
42+
});
43+
}
44+
45+
readingList(books);

Sprint-3/reading-list/style.css

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ body {
1212
"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
1313
}
1414

15+
.book-card {
16+
padding: 20px;
17+
margin: 15px;
18+
border-radius: 8px;
19+
display: flex;
20+
align-items: center;
21+
gap: 20px;
22+
}
23+
24+
.book-card img {
25+
height: 150px;
26+
width: auto;
27+
}
28+
29+
.read {
30+
background-color: green;
31+
}
32+
33+
.unread {
34+
background-color: red;
35+
}
36+
1537
.site-footer {
1638
margin-top: 4em;
1739
}
@@ -133,7 +155,7 @@ body {
133155
height: 37px;
134156
}
135157

136-
.colorButton {
158+
.colorBtn {
137159
margin-bottom: 20px;
138160
margin-right: 20px;
139161
width: 100px;

0 commit comments

Comments
 (0)