added rate input vue component

pull/49/head
A1Gard 3 months ago
parent fc33d4ed2a
commit 5eff6259d9

@ -28,6 +28,9 @@ app.component('address-input', addressInput);
import NsCard from "../client-vue/NsCard.vue";
app.component('ns-card', NsCard);
import RateInput from "../client-vue/RateInput.vue";
app.component('rate-input', RateInput);
app.use(ToastPlugin);
app.use(store);

@ -0,0 +1,78 @@
<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>
Loading…
Cancel
Save