2018-10-19 05:15:28 +00:00
|
|
|
<template lang="html">
|
2019-02-08 06:07:40 +00:00
|
|
|
<div
|
|
|
|
:class="['game-rating', { small, dark }]">
|
2018-10-25 06:33:15 +00:00
|
|
|
|
2019-02-08 06:44:43 +00:00
|
|
|
<span v-for="n in 5" :key="`star-${n}`">
|
2019-02-08 06:07:40 +00:00
|
|
|
<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,
|
2019-02-08 06:07:40 +00:00
|
|
|
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
|
|
|
|
2019-02-08 06:07:40 +00:00
|
|
|
roundedRating() {
|
|
|
|
return Math.round((this.rating / 20) * 2) / 2;
|
2018-10-25 06:33:15 +00:00
|
|
|
},
|
|
|
|
|
2019-02-08 06:07:40 +00:00
|
|
|
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>
|
|
|
|
@import "~styles/styles.scss";
|
|
|
|
|
2018-10-25 06:33:15 +00:00
|
|
|
.game-rating {
|
2019-02-08 06:07:40 +00:00
|
|
|
color: $color-orange;
|
|
|
|
font-size: 20px;
|
2018-10-19 05:15:28 +00:00
|
|
|
|
|
|
|
&.small {
|
2019-02-08 06:07:40 +00:00
|
|
|
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>
|