forked from CodeYourFuture/Full-Stack-Project-Assessment
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #37 from RbAvci/RB/Video_voting_buttons
NW6 | Rabia Avci | Full-Stack-Project | Week-3 | Video voting buttons
- Loading branch information
Showing
6 changed files
with
132 additions
and
51 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 |
---|---|---|
@@ -1,21 +1,24 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/icon.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Video Recommendations</title> | ||
<link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" | ||
rel="stylesheet" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" | ||
/> | ||
</head> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/icon.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Video Recommendations</title> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" | ||
rel="stylesheet"> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/index.jsx"></script> | ||
</body> | ||
|
||
</html> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/index.jsx"></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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const RatingDisplay = ({ videoId, rating, onUpdate }) => { | ||
const handleRating = (updatedRating) => { | ||
fetch(`/api/videos/${videoId}/rating`, { | ||
method: "PUT", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
}, | ||
|
||
body: JSON.stringify({ | ||
rating: updatedRating, | ||
}), | ||
}) | ||
.then((response) => { | ||
if (!response.ok) { | ||
throw new Error("Failed to update the video rating"); | ||
} | ||
return response.json(); | ||
}) | ||
.then((data) => { | ||
onUpdate(videoId, data.data.rating); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div>{rating}</div> | ||
<div> | ||
<button onClick={() => handleRating(rating + 1)}> | ||
Thumbs-up! <i className="fa fa-thumbs-up"></i> | ||
</button> | ||
<button onClick={() => handleRating(rating - 1)}> | ||
Thumbs-down! <i className="fa fa-thumbs-down"></i> | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RatingDisplay; |
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 |
---|---|---|
@@ -1,38 +1,38 @@ | ||
:root { | ||
--primary-color: #007bff; | ||
--container-width: 90%; | ||
--gap-size: 20px; | ||
--primary-color: #007bff; | ||
--container-width: 90%; | ||
--gap-size: 20px; | ||
} | ||
|
||
.video-list-container { | ||
padding: 20px; | ||
margin: 0 auto; | ||
width: var(--container-width); | ||
padding: 20px; | ||
margin: 0 auto; | ||
width: var(--container-width); | ||
} | ||
|
||
.video-list { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); | ||
gap: var(--gap-size); | ||
display: grid; | ||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); | ||
gap: var(--gap-size); | ||
} | ||
|
||
.video-item { | ||
padding: 10px; | ||
border: 1px solid #ddd; | ||
border-radius: 5px; | ||
background-color: #f9f9f9; | ||
padding: 10px; | ||
border: 1px solid #ddd; | ||
border-radius: 5px; | ||
background-color: #f9f9f9; | ||
} | ||
|
||
.video-title { | ||
font-size: 18px; | ||
margin-bottom: 10px; | ||
font-family: Arial, sans-serif; | ||
font-size: 18px; | ||
margin-bottom: 10px; | ||
font-family: Arial, sans-serif; | ||
} | ||
|
||
.video-title a { | ||
color: var(--primary-color); | ||
color: var(--primary-color); | ||
} | ||
|
||
.video-title a:hover { | ||
text-decoration: underline; | ||
text-decoration: underline; | ||
} |
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
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