Skip to content

5 star rating page added #229

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

Merged
merged 1 commit into from
Jun 6, 2024
Merged
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
161 changes: 161 additions & 0 deletions src/img/review.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Roboto", sans-serif;
}

html, body {
display: grid;
height: 100%;
place-items: center;
text-align: center;
background: #121026;
}

.container {
position: relative;
width: 400px;
background: #252041;
padding: -11px 30px;
border: 1px solid #444;
border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.container .post{
display: none;
}
.container .text{
font-size: 25px;
color: #666;
font-weight: 500;
}
.container .edit{
font-size: 16px;
right: 10px;
top: 5px;
position: absolute;
color: #666;
font-weight: 500;
cursor: pointer;

}

.container .star-widget input {
display: none;
}

.star-widget label {
font-size: 40px;
color: #444;
padding: 10px;
float: right;
transition: color 1s;
}

.star-widget input:not(:checked) ~ label:hover,
.star-widget input:not(:checked) ~ label:hover ~ label {
color: rgb(255, 0, 255);
}

.star-widget input:checked ~ label {
color:yellow;
;
}

.star-widget input#rate-5:checked ~ label,
.star-widget input#rate-5:checked ~ label ~ label,
.star-widget input#rate-4:checked ~ label,
.star-widget input#rate-4:checked ~ label ~ label,
.star-widget input#rate-3:checked ~ label,
.star-widget input#rate-3:checked ~ label ~ label,
.star-widget input#rate-2:checked ~ label,
.star-widget input#rate-2:checked ~ label ~ label,
.star-widget input#rate-1:checked ~ label,
.star-widget input#rate-1:checked ~ label ~ label {
color: rgb(0, 255, 229);
}
.container form{
display: none;
}
input:checked ~ form{
display: block;
}
form header{
width: 100%;
font-size: 25px;
color: #fe7;
font-weight: 500;
margin: 5px 0 20px 0;
text-align: center;
transition: all 0.2s ease;
}
form .textarea textarea{
height: 100%;
width: 100%;
outline: none;
color: #eee;
border: 1px solid #333;
background: #222;
padding: 10px;
font-size: 17px;
resize: none;

}

form .btn{
height: 45px;
width: 100%;
margin: 15px 0;

}
form .btn button{
height: 100%;
width: 100%;
border: 1px solid #444;
outline: none;
background: #222;
color: #999;
font-size: 17px;
font-weight: 500;
text-transform: uppercase;
cursor: pointer;
}
form .btn button:hover{
background: #1b1b1b;

}
#rate-1:checked ~ form header:before{
content: "I just hate it";
}
#rate-2:checked ~ form header:before{
content: "I don't like it";
}
#rate-3:checked ~ form header:before{
content: "It's alright";
}
#rate-4:checked ~ form header:before{
content: "I like it";
}
#rate-5:checked ~ form header:before{
content: "I just love it";
}
.review-text {
text-align: center;
margin-bottom: 20px;
}

.review-text h2 {
font-size: 24px;
margin-bottom: 10px;
color: white;

}

.review-text p {
font-size: 16px;
color: #555;
}
111 changes: 111 additions & 0 deletions src/img/review.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Review Page</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<link rel="stylesheet" href="review.css">
<style>
.container {
position: relative;
text-align: center;
color: white;
}
.background-image {
width: 164%;
height: 200%;
border-radius: 10px;
box-shadow: 0px 0px 20pxrgba(32, 13, 58, 0.4);
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.centered h2 {
font-size: 36px;
margin: -124;
}
.centered p {
font-size: 18px;
margin: 86px -141px 35px -145px;
}
</style>
</head>
<body>
<div class="container">
<img src="1.jpg" alt="Background" class="background-image">
<div class="centered">
<h2>Here's the Review Form</h2>
<p>Thank you for visiting the website! Please tell us how we can improve your experience</p>
</div>
</div>
<div class="container">
<div class="post" style="display: none;">
<div class="text">Thanks for rating us!</div>
<div class="edit">EDIT</div>
</div>
<div class="star-widget">
<input type="radio" name="rate" id="rate-5">
<label for="rate-5" class="fas fa-star"></label>
<input type="radio" name="rate" id="rate-4">
<label for="rate-4" class="fas fa-star"></label>
<input type="radio" name="rate" id="rate-3">
<label for="rate-3" class="fas fa-star"></label>
<input type="radio" name="rate" id="rate-2">
<label for="rate-2" class="fas fa-star"></label>
<input type="radio" name="rate" id="rate-1">
<label for="rate-1" class="fas fa-star"></label>
<form action="#">
<header></header>
<div class="textarea">
<textarea cols="30" placeholder="Describe your experience.."></textarea>
</div>
<div class="btn">
<button type="submit">Post</button>
</div>
</form>
</div>
</div>
<script>
const btn = document.querySelector("button");
const post = document.querySelector(".post");
const widget = document.querySelector(".star-widget");
const editBtn = document.querySelector(".edit");
const textArea = document.querySelector("textarea");
const ratings = document.querySelectorAll('input[name="rate"]');

btn.onclick = (e) => {
e.preventDefault();
let ratingSelected = false;
for (const rating of ratings) {
if (rating.checked) {
ratingSelected = true;
break;
}
}

if (!ratingSelected) {
alert("Please select a star rating.");
return;
}

if (textArea.value.trim() === "") {
alert("Please describe your experience.");
return;
}

widget.style.display = "none";
post.style.display = "block";
}

editBtn.onclick = () => {
widget.style.display = "block";
post.style.display = "none";
}
</script>
</body>
</html>
Loading