mirror of https://github.com/4xmen/xshop.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.5 KiB
Vue
79 lines
1.5 KiB
Vue
<template>
|
|
<div id="rate-input">
|
|
<div class="float-end" @mouseleave="hoverIndex = 0">
|
|
<template v-for="i in 5">
|
|
<i :class="hoverClass(i)" @mouseenter="hovering(i)" @click="val = i"></i>
|
|
</template>
|
|
</div>
|
|
<div class="p-2">
|
|
{{this.xtitle}}
|
|
</div>
|
|
</div>
|
|
<input type="hidden" :name="xname" v-model="val">
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: "rate-input",
|
|
components: {},
|
|
data: () => {
|
|
return {
|
|
hoverIndex: 0,
|
|
val: 0,
|
|
}
|
|
},
|
|
props: {
|
|
xtitle:{
|
|
default: 'rate',
|
|
type: String,
|
|
},
|
|
xname:{
|
|
default: null,
|
|
},
|
|
xvalue:{
|
|
default: 0,
|
|
},
|
|
},
|
|
mounted() {
|
|
this.val = this.xvalue;
|
|
},
|
|
computed: {},
|
|
methods: {
|
|
hovering(i) {
|
|
this.hoverIndex = i;
|
|
},
|
|
hoverClass(i) {
|
|
if (this.hoverIndex >= i) {
|
|
return 'ri-star-fill';
|
|
} else {
|
|
if (this.val >= i){
|
|
return 'ri-star-fill selected';
|
|
}
|
|
return 'ri-star-line';
|
|
}
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
#rate-input {
|
|
|
|
i {
|
|
cursor: pointer;
|
|
font-size: 25px;
|
|
color: gray;
|
|
transition: 250ms;
|
|
}
|
|
|
|
.ri-star-fill {
|
|
color: goldenrod;
|
|
|
|
&.selected{
|
|
color:var(--xshop-primary);
|
|
}
|
|
}
|
|
}
|
|
|
|
</style>
|