Skip to content

LONDON | 25-ITP-MAY | TEWODROS BEKERE | SPRINT-3 | Reading-List-App #732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
6 changes: 4 additions & 2 deletions Sprint-3/reading-list/index.html
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you run the test? All tests fails at the moment. Please refactor the code accordingly!

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Title here</title>
<title>Reading list app</title>
</head>
<body>
<div id="content">
<ul id="reading-list"></ul>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hint: You will need to use this id reading-list to match the test cases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see the changed files and new commits!


<ul id="reading-list-app"></ul>

</div>
<script src="script.js"></script>
</body>
Expand Down
26 changes: 26 additions & 0 deletions Sprint-3/reading-list/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,29 @@ const books = [
},
];

function readingListApp(books) {
const container = document.getElementById("reading-list-app");
if (!container) return;

for (let i = 0; i < books.length; i++) {
const book = books[i];

const bookItem = document.createElement("div");
bookItem.className = "book";
bookItem.style.backgroundColor = book.alreadyRead ? "green" : "red";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works fine but it's best to keep styles in the css file rather then modifying in the DOM. I would recommend using class to change the colour. Can you refactor the code accordingly?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


const bookInfo = document.createElement("div");
bookInfo.innerHTML = `<strong>${book.title}</strong> by <strong>${book.author}</strong>`;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

innerHTML has a potential security issue. It's better to avoid using it. FYI, find more in this link. Can you refactor the code with an alternative property?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


const img = document.createElement("img");
img.src = book.bookCoverImage;
img.alt = `${book.title} cover`;

bookItem.appendChild(bookInfo);

bookItem.appendChild(img);
container.appendChild(bookItem);
}
}

readingListApp(books);
54 changes: 50 additions & 4 deletions Sprint-3/reading-list/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Lesson: 1,2
* Class: Scotland 2017
*/

/*
html,
body {
font-family: "Source Sans Pro", -apple-system, system-ui, BlinkMacSystemFont,
Expand Down Expand Up @@ -68,7 +68,7 @@ body {
border-radius: 0;
}

/* Headings */
/* Headings
.heading-underline {
position: relative;
margin-bottom: 2em;
Expand All @@ -90,7 +90,7 @@ body {
background: #ce5f31;
}

/* Article */
/* Article *
.article {
margin-bottom: 2em;
}
Expand Down Expand Up @@ -156,4 +156,50 @@ body {
.navbar-brand > img {
max-height: 80px;
}
}
} */
html,
body {
font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
padding: 2rem;

}

.book {
display: block;
align-items: left;
margin-bottom: 1.5rem;
padding: 1rem;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #f9f9f9;
}

.book img {
height: 320px;
margin-right: 0rem;
border-radius: 4px;
margin-top: 10px;
margin-left: -1rem;
margin-bottom: -16px;
}

.book-info h3 {
margin: 0;
font-size: 1.2rem;
}

.book-info p {
margin: 0.3rem 0;
}

.read {
color: green;
font-weight: bold;
}

.unread {
color: red;
font-weight: bold;
}