-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a Book component which inherit from BookList.js
- Loading branch information
1 parent
52ead46
commit 16ab140
Showing
4 changed files
with
107 additions
and
90 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,57 @@ | ||
.book-item { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
width: auto; | ||
padding: 10px 20px; | ||
border-bottom: 1px solid #ccc; | ||
background-color: #fff; | ||
list-style-type: none; | ||
} | ||
|
||
.book-item:nth-child(even) { | ||
background-color: #f2f2f2; | ||
} | ||
|
||
.book-item:hover { | ||
background-color: #dbe4f8; | ||
} | ||
|
||
.book-item button { | ||
background-color: #fff; | ||
color: red; | ||
border: 1px solid red; | ||
padding: 8px 12px; | ||
border-radius: 3px; | ||
cursor: pointer; | ||
transition: background-color 0.3s ease; | ||
} | ||
|
||
.book-item button:hover { | ||
background-color: #fdd; | ||
} | ||
|
||
.book-item .highlight { | ||
background-color: rgba(150, 182, 238, 0.605); | ||
border-radius: 5px; | ||
padding: 0 0.5px; | ||
} | ||
|
||
.book-item .book-info { | ||
flex: 1; | ||
text-align: left; | ||
} | ||
|
||
.book-item .book-actions { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.book-item .star-icon { | ||
width: 24px; | ||
height: 24px; | ||
margin: 0 20px; | ||
cursor: pointer; | ||
transition: color 0.3s ease; | ||
color: #fca510; | ||
} |
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,41 @@ | ||
import { TbStar } from 'react-icons/tb' | ||
import { TbStarFilled } from 'react-icons/tb' | ||
import './Book.css' | ||
|
||
const book = ({ book, index, onHandleDeleteBook, onToggleFavoriteBook }) => { | ||
return ( | ||
<> | ||
<li className="book-item" key={book.id} data-testid={book.id}> | ||
<div className="book-info"> | ||
<span>{++index}. </span> | ||
<span>{'"'}</span> | ||
<span>{book.title}</span> | ||
<span> | ||
{'" '} | ||
by <strong>{book.authors}</strong> | ||
</span> | ||
</div> | ||
<div className="book-actions"> | ||
<span | ||
onClick={() => onToggleFavoriteBook(book.id)} | ||
data-testid={`isFavorite_${book.isFavorite}`} | ||
> | ||
{book.isFavorite ? ( | ||
<TbStarFilled className="star-icon" /> | ||
) : ( | ||
<TbStar className="star-icon" /> | ||
)} | ||
</span> | ||
<button | ||
onClick={() => onHandleDeleteBook(book.id)} | ||
data-testid="delete_book_btn" | ||
> | ||
Delete | ||
</button> | ||
</div> | ||
</li> | ||
</> | ||
) | ||
} | ||
|
||
export default book |
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