mirror of
https://github.com/gosticks/vue-webshop.git
synced 2025-10-16 12:05:40 +00:00
Added OxyRating simple vue rating module using stars.
This commit is contained in:
parent
2e27d19765
commit
979c6e13c1
51
src/components/UIComponents/OxyRating.vue
Normal file
51
src/components/UIComponents/OxyRating.vue
Normal file
@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<div class="rating-indicator">
|
||||
<i v-for="(_, index) in totalStart" :class="iconForStar(index)">
|
||||
</i>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const numberStars = 5
|
||||
|
||||
export default {
|
||||
props: {
|
||||
editable: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
},
|
||||
rating: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
totalStart: numberStars
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
iconForStar: function (index) {
|
||||
let v = (this.rating - 1.0) - index
|
||||
console.debug(index, v, this.rating)
|
||||
if (v >= -0.3) {
|
||||
return 'ion-ios-star'
|
||||
} else if (v >= -0.5) {
|
||||
return 'ion-ios-star-half'
|
||||
}
|
||||
return 'ion-ios-star-outline'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.rating-indicator {
|
||||
font-size: 2rem;
|
||||
color: #888;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user