gamebrary/src/components/GameDetail/GameRating.vue

52 lines
1,009 B
Vue
Raw Normal View History

2018-10-19 05:15:28 +00:00
<template lang="html">
<div
:class="['game-rating', { small, dark }]">
<template v-for="n in 5">
<i class="fas fa-star" v-if="(roundedRating - n) + 1 >= 1" />
<i class="fas fa-star-half" v-if="(roundedRating - n) + 1 === .5" />
</template>
2018-10-19 05:15:28 +00:00
</div>
</template>
<script>
2018-12-21 21:52:11 +00:00
import { mapGetters } from 'vuex';
2018-11-02 01:42:43 +00:00
2018-10-19 05:15:28 +00:00
export default {
props: {
rating: Number,
small: Boolean,
placeholder: Boolean,
2018-10-19 05:15:28 +00:00
},
computed: {
2018-12-21 21:52:11 +00:00
...mapGetters(['darkModeEnabled']),
2018-11-02 01:42:43 +00:00
roundedRating() {
return Math.round((this.rating / 20) * 2) / 2;
},
dark() {
return this.darkModeEnabled || this.placeholder;
}
2018-10-19 05:15:28 +00:00
},
};
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
@import "~styles/styles.scss";
.game-rating {
color: $color-orange;
font-size: 20px;
2018-10-19 05:15:28 +00:00
&.small {
font-size: 12px;
2018-10-19 05:15:28 +00:00
}
2018-11-02 01:42:43 +00:00
&.dark {
color: $color-dark-gray !important;
}
2018-10-19 05:15:28 +00:00
}
</style>