gamebrary/src/components/GameDetail/GameRating.vue

51 lines
1 KiB
Vue
Raw Normal View History

2018-10-19 05:15:28 +00:00
<template lang="html">
<div :class="['game-rating', { small, dark }]">
2019-02-08 06:44:43 +00:00
<span v-for="n in 5" :key="`star-${n}`">
<i class="fas fa-star" v-if="(roundedRating - n) + 1 >= 1" />
<i class="fas fa-star-half" v-if="(roundedRating - n) + 1 === .5" />
2019-02-08 06:44:43 +00:00
</span>
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;
2019-02-08 06:44:43 +00:00
},
2018-10-19 05:15:28 +00:00
},
};
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
2019-04-05 19:16:32 +00:00
@import "~styles/styles.scss";
2018-10-19 05:15:28 +00:00
.game-rating {
color: $color-orange;
font-size: 20px;
margin: $gp / 4 0;
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>