Fix rating input

This commit is contained in:
Julien Nahum 2024-03-20 20:09:52 +01:00
parent a7a32134a6
commit 75cc4b19e1
1 changed files with 10 additions and 1 deletions

View File

@ -7,7 +7,7 @@
</template>
<div class="stars-outer">
<div v-for="i in numberOfStars" :key="i"
<div v-for="i in starsCount" :key="i"
class="cursor-pointer inline-block text-gray-200 dark:text-gray-800"
:class="{'!text-yellow-400 active-star':i<=compVal, '!text-yellow-200 !dark:text-yellow-800 hover-star':i>compVal && i<=hoverRating, '!cursor-not-allowed':disabled}"
role="button" @click="setRating(i)"
@ -66,6 +66,15 @@ export default {
}
},
computed: {
starsCount() {
if (!this.numberOfStars || this.numberOfStars < 1) {
return 5
}
return this.numberOfStars
}
},
methods: {
onMouseHover (i) {
this.hoverRating = (this.disabled) ? -1 : i