gamebrary/src/components/GameDetail/GameRating.vue

77 lines
1.8 KiB
Vue
Raw Normal View History

<!-- eslint-disable -->
2018-10-19 05:15:28 +00:00
<template lang="html">
<div :class="['game-rating', ratingClass, { 'small': small}]">
<span class="rating">
{{ formattedRating }}
</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="4 3 91 111">
<path d="M49 3L4 29v52l45 26 46-26V29zm0 95L12 77V34l37-21 38 21v43zm0 0" />
</svg>
2018-10-19 05:15:28 +00:00
</div>
</template>
<script>
export default {
props: {
rating: Number,
small: Boolean,
},
computed: {
ratingClass() {
const gameRating = Number(this.rating);
if (gameRating === 100) { return 'master'; }
if (gameRating >= 90) { return 'amazing'; }
if (gameRating >= 80) { return 'great'; }
if (gameRating >= 70) { return 'good'; }
if (gameRating >= 60) { return 'okay'; }
return 'bad';
},
formattedRating() {
return isNaN(this.rating)
? '?'
: parseInt(this.rating, 10);
2018-10-19 05:15:28 +00:00
},
},
};
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
@import "~styles/styles.scss";
.game-rating {
2018-10-19 05:15:28 +00:00
width: 100px;
height: 115px;
position: relative;
2018-10-19 05:15:28 +00:00
&.small {
width: 34px;
height: 39px;
2018-10-19 05:15:28 +00:00
.rating {
font-size: 20px;
2018-10-19 05:15:28 +00:00
}
}
&.master { fill: #0e9246; color: #0e9246; }
&.amazing { fill: #7dbb42; color: #7dbb42; }
&.great { fill: #fecc09; color: #fecc09; }
&.good { fill: #f68e1e; color: #f68e1e; }
&.okay { fill: #ee4723; color: #ee4723; }
&.bad { fill: #bc2025; color: #bc2025; }
2018-10-19 05:15:28 +00:00
.rating {
2018-10-19 05:15:28 +00:00
position: absolute;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 48px;
font-weight: bold;
2018-10-19 05:15:28 +00:00
}
}
</style>