-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
139 lines (117 loc) · 4.67 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!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">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Overpass">
<title>Frontend Mentor | Interactive rating component</title>
<style>
.attribution { font-size: 11px; text-align: center; }
.attribution a { color: hsl(228, 45%, 44%); }
body{
background-color:rgb(20,21,25);
height:100vh;
}
#card-parent{
display:flex;
justify-content: center;
align-items: center;
height:100%;
}
#card{
background-color:white;
width:400px;
height:400px;
background-image: linear-gradient(to top right, rgb(23,30,38), rgb(30,37,47));
border-radius:25px;
}
#star-img-circle{
margin-left:50px;
margin-top:50px;
width:30px;
height:30px;
border-radius: 50%;
background-color:rgb(39,46,56);
display: flex;
justify-content: center;
align-items: center;
}
#card-text{
font-size:15px;
font-weight:700;
color:hsl(0, 0%, 100%);
font-family: "Overpass";
margin:20px 50px;
}
.points{
width:30px;
height:30px;
border-radius: 50%;
/* display:inline-flex; Not usually in docs but helps if you want to make something inline and also center its content*/
justify-content: center;
align-items: center;
margin:15px;
/* vertical-align:top; Useful for spans*/
cursor: pointer;
border:0;
background-color:rgb(39,46,56);;
font-family: "Overpass";
}
.pointsHovered{
background-color:rgb(123,136,152)
}
.pointsSelected{
background-color:rgb(251,119,21)
}
</style>
<script>
function changeColorSelected(ele){
var points=document.querySelectorAll('.points')
points.forEach(point => point.className="points")
document.getElementById(ele.id).className+=" pointsSelected"
}
function changeColorHovered(ele){
var points=document.querySelectorAll('.points')
points.forEach(point => {if(!document.getElementById(point.id).className.includes("pointsSelected")) {point.className="points"}})
document.getElementById(ele.id).className+=" pointsHovered"
}
</script>
</head>
<body>
<div id="card-parent">
<div id="card">
<div id="star-img-circle">
<img src="./images/icon-star.svg">
</div>
<div id="card-text">
<p>How did we do?
<br><br>
<span id="paragraph-txt" style="font-weight:400; color:hsl(217, 12%, 63%)">Please let us know how we did with your support request. All feedback is appreciated
to help us improve our offering!</span></p>
</div>
<div id="points-parent" style="margin-top:10px; margin-left:35px">
<button id="p1" class="points" onclick="changeColorSelected(this)" onmouseover="changeColorHovered(this)" onmouseleave="changeColorHovered(this); document.getElementById(this.id).className.replace('pointsHovered','')">1</button>
<button id="p2" class="points" onclick="changeColorSelected(this)" onmouseover="changeColorHovered(this)" onmouseleave="changeColorHovered(this); document.getElementById(this.id).className.replace('pointsHovered','')">2</button>
<button id="p3" class="points" onclick="changeColorSelected(this)" onmouseover="changeColorHovered(this)" onmouseleave="changeColorHovered(this); document.getElementById(this.id).className.replace('pointsHovered','')">3</button>
<button id="p4" class="points" onclick="changeColorSelected(this)" onmouseover="changeColorHovered(this)" onmouseleave="changeColorHovered(this); document.getElementById(this.id).className.replace('pointsHovered','')">4</button>
<button id="p5" class="points" onclick="changeColorSelected(this)" onmouseover="changeColorHovered(this)" onmouseleave="changeColorHovered(this); document.getElementById(this.id).className.replace('pointsHovered','')">5</button>
</div>
</div>
</div>
<!-- Rating state start -->
1 2 3 4 5
Submit
<!-- Rating state end -->
<!-- Thank you state start -->
You selected <!-- Add rating here --> out of 5
Thank you!
We appreciate you taking the time to give a rating. If you ever need more support,
don’t hesitate to get in touch!
<!-- Thank you state end -->
<div class="attribution">
Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank">Frontend Mentor</a>.
Coded by <a href="https://github.com/pujxn" target="_blank">pujxn</a>.
</div>
</body>
</html>