1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Make star rating in marketplace interactive

Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
Panu Horsmalahti 2020-12-10 16:16:16 +02:00
parent 9f77b060c8
commit caa1d31e09
2 changed files with 22 additions and 6 deletions

View File

@ -4,6 +4,17 @@
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="marketplace.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script>
function onRating(rating) {
Array.from(document.querySelectorAll(".fa-star")).forEach((starNode, index) => {
if (index < rating) {
starNode.classList.add("checked");
} else {
starNode.classList.remove("checked");
}
});
}
</script>
</head>
<body>
<h3>Lens Marketplace</h3>
@ -17,12 +28,12 @@
35 installs
</div>
<div>|</div>
<div>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star"></span>
<div class="stars">
<span class="fa fa-star checked" onclick="onRating(1)"></span>
<span class="fa fa-star checked" onclick="onRating(2)"></span>
<span class="fa fa-star checked" onclick="onRating(3)"></span>
<span class="fa fa-star checked" onclick="onRating(4)"></span>
<span class="fa fa-star" onclick="onRating(5)"></span>
<span>(8)</span>
</div>
<div>|</div>

View File

@ -28,6 +28,11 @@ ul {
padding: 0;
}
.stars {
user-select: none;
cursor: pointer;
}
.checked {
color: orange;
}