-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
87 lines (87 loc) · 3.46 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="icon"
type="image/png"
sizes="32x32"
href="./images/favicon-32x32.png"
/>
<title>Frontend Mentor | Interactive rating component</title>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<main>
<section>
<div class="card">
<div class="rating star">
<img src="images/icon-star.svg" alt="icon-star" />
</div>
<p class="large bold">How did we do?</p>
<p class="dim small">
Please let us know how we did with your support request.
All feedback is appreciated to help us improve our
offering!
</p>
<div class="rating-container">
<div class="rating dim">1</div>
<div class="rating dim">2</div>
<div class="rating dim">3</div>
<div class="rating dim">4</div>
<div class="rating dim">5</div>
</div>
<button>Submit</button>
</div>
<div class="card final hidden">
<img
style="margin: auto;"
src="images/illustration-thank-you.svg"
alt="illustration-thank-you"
/>
<p class="final-rating">
You selected <span></span> out of 5
</p>
<p class="large bold">Thank you!</p>
<p class="dim small">
We appreciate you taking the time to give a rating. If
you ever need more support, don’t hesitate to get in
touch!
</p>
</div>
</section>
<footer style="padding: 4px;">
Challenge by
<a
href="https://www.frontendmentor.io/challenges/interactive-rating-component-koxpeBUmI"
target="_blank"
>Frontend Mentor</a
>. Coded by <a href="https://github.com/stressedball/interactive-rating-component-main">TS</a>.
</footer>
</main>
</body>
<script>
let final_rating;
const ratings = document.querySelectorAll(".rating");
ratings.forEach((rating) =>
rating.addEventListener("click", (e) => {
ratings.forEach((r) => r.classList.remove("selected"));
e.target.classList.add("selected");
final_rating = rating.textContent;
})
);
const submit = document.querySelector("button");
submit.addEventListener("click", () => {
if (!final_rating) alert("Sorry. Please select a rating.");
else {
document.querySelector(".hidden").classList.remove("hidden");
document
.querySelector(".card:not(.hidden)")
.classList.add("hidden");
document.querySelector("p.final-rating span").textContent =
final_rating;
}
});
</script>
</html>