Skip to content

Commit

Permalink
feat: ratings component (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanericNetwork authored Dec 20, 2023
2 parents b7e23ee + 3bb3916 commit a52b548
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tabWidth": 2
}
53 changes: 53 additions & 0 deletions src/resources/vue/components/rating.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>
<div class="rating">
<icon
v-for="i in fullStars"
:key="'full' + i"
icon="full-star"
color="white"
size="50"
></icon>
<icon v-if="hasHalfStar" icon="half-star" color="white" size="50"></icon>
<icon
v-for="i in emptyStars"
:key="'empty' + i"
icon="empty-star"
color="white"
size="50"
></icon>
</div>
</template>

<script>
import Icon from "./icon.vue";
export default {
components: {
Icon,
},
props: {
rating: {
type: Number,
required: true,
},
},
computed: {
fullStars() {
return Math.floor(this.rating);
},
hasHalfStar() {
return this.rating % 1 !== 0;
},
emptyStars() {
return 5 - Math.ceil(this.rating);
},
},
};
</script>

<style>
.rating {
display: flex;
align-items: center;
}
</style>

0 comments on commit a52b548

Please sign in to comment.