forked from fdnd-task/progressive-enhancement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rating.html
117 lines (112 loc) · 3.5 KB
/
rating.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
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Rating / Progressive Enhancement / FDND</title>
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"
rel="stylesheet"
/>
<link href="assets/styles.css" rel="stylesheet" />
<style>
/* CSS-code hier */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
svg {
width: 5em;
margin: 0.5em;
transition: fill 0.3s ease;
}
svg:hover path,
.rating-form .filled path {
fill: #66e5bf;
}
.rating-form {
display: flex;
align-items: center;
}
.rating-form svg {
cursor: pointer;
}
</style>
</head>
<body>
<h1>Rating</h1>
<form method="post" class="rating-form">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" class="star">
<path
fill="none"
stroke="#66E5BF"
stroke-width="2"
d="M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798z"
></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" class="star">
<path
fill="none"
stroke="#66E5BF"
stroke-width="2"
d="M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798z"
></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" class="star">
<path
fill="none"
stroke="#66E5BF"
stroke-width="2"
d="M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798z"
></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" class="star">
<path
fill="none"
stroke="#66E5BF"
stroke-width="2"
d="M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798z"
></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" class="star">
<path
fill="none"
stroke="#66E5BF"
stroke-width="2"
d="M32 12.408l-11.056-1.607-4.944-10.018-4.944 10.018-11.056 1.607 8 7.798-1.889 11.011 9.889-5.199 9.889 5.199-1.889-11.011 8-7.798z"
></path>
</svg>
</form>
<details>
<summary>Demo video</summary>
<video
src="assets/rating.mp4"
width="271"
height="110"
controls
muted
autoplay
loop
>
<a href="assets/rating.mp4">assets/rating.mp4</a>
</video>
</details>
<script>
document.addEventListener('DOMContentLoaded', function () {
const stars = document.querySelectorAll('.star');
stars.forEach((star) => {
star.addEventListener('click', function () {
stars.forEach((s) => s.classList.remove('filled'));
this.classList.add('filled');
let prev = this.previousElementSibling;
while (prev) {
prev.classList.add('filled');
prev = prev.previousElementSibling;
}
});
});
});
</script>
</body>
</html>