2020-08-10 12:35:19 +00:00
|
|
|
<template>
|
2020-08-10 14:33:28 +00:00
|
|
|
<div class="row" v-if="isLoaded">
|
2020-08-10 12:35:19 +00:00
|
|
|
<div class="col-sm-6 col-md-4 mb-5" v-for="game of games" v-bind:key="game.name">
|
2020-08-10 12:49:25 +00:00
|
|
|
<a :href="game.url">
|
|
|
|
<div class="item">
|
|
|
|
<div class="item-image">
|
|
|
|
<img class="item-image-main" :src="game.image" />
|
|
|
|
<img class="item-image-icon" :src="game.platform" />
|
|
|
|
</div>
|
|
|
|
<div class="item-details">
|
|
|
|
<div>
|
2020-08-10 12:35:19 +00:00
|
|
|
<h5 style="display: inline-block;">{{game.name}}</h5>
|
2020-08-10 12:49:25 +00:00
|
|
|
</div>
|
|
|
|
<div v-if="game.metacritic != null" class="item-counts">{{game.metacritic}}%</div>
|
2020-08-10 12:35:19 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-08-10 12:49:25 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
2020-08-10 14:33:28 +00:00
|
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-center" v-else>
|
2020-08-10 12:53:37 +00:00
|
|
|
<div class="spinner-border" role="status">
|
|
|
|
<span class="sr-only">Loading...</span>
|
2020-08-10 12:35:19 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style>
|
2020-08-10 14:33:28 +00:00
|
|
|
.spinner-border {
|
|
|
|
width: 3rem;
|
|
|
|
height: 3rem;
|
|
|
|
}
|
2020-08-10 12:35:19 +00:00
|
|
|
|
2020-08-10 14:33:28 +00:00
|
|
|
.item {
|
|
|
|
height: 100%;
|
|
|
|
background: #222;
|
|
|
|
border-radius: 10px;
|
|
|
|
}
|
2020-08-10 12:35:19 +00:00
|
|
|
|
2020-08-10 14:33:28 +00:00
|
|
|
.item-image {
|
|
|
|
display: block;
|
|
|
|
padding-bottom: 60%;
|
|
|
|
/* 60% sirky */
|
|
|
|
position: relative;
|
|
|
|
}
|
2020-08-10 12:35:19 +00:00
|
|
|
|
2020-08-10 14:33:28 +00:00
|
|
|
.item-image-main {
|
|
|
|
border-radius: 10px 10px 0 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
top: 0;
|
|
|
|
object-fit: cover;
|
|
|
|
}
|
2020-08-10 12:35:19 +00:00
|
|
|
|
2020-08-10 14:33:28 +00:00
|
|
|
.item-image-icon {
|
|
|
|
position: absolute;
|
|
|
|
left: 10px;
|
|
|
|
top: 10px;
|
|
|
|
width: 30px;
|
|
|
|
height: auto;
|
|
|
|
}
|
2020-08-10 12:49:25 +00:00
|
|
|
|
2020-08-10 14:33:28 +00:00
|
|
|
.item-details {
|
|
|
|
padding: 10px;
|
|
|
|
display: flex;
|
|
|
|
align-items: flex-start;
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
|
|
|
|
|
|
|
.item-counts {
|
|
|
|
border: 1px solid green;
|
|
|
|
color: green;
|
|
|
|
padding: 4px;
|
|
|
|
font-size: 12px;
|
|
|
|
font-weight: 600;
|
|
|
|
}
|
2020-08-10 12:35:19 +00:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<script>
|
2020-08-10 14:33:28 +00:00
|
|
|
import axios from "axios";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isLoaded: true,
|
|
|
|
games: []
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.getGames();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getGames() {
|
|
|
|
this.isLoaded = false;
|
|
|
|
axios.get("https://api.gabenparadise.com/api/data").then(response => {
|
|
|
|
console.log(response);
|
|
|
|
if (response.status === 200) {
|
|
|
|
this.isLoaded = true;
|
|
|
|
this.games = response.data;
|
|
|
|
}
|
|
|
|
});
|
2020-08-10 12:35:19 +00:00
|
|
|
}
|
2020-08-10 14:33:28 +00:00
|
|
|
}
|
|
|
|
};
|
2020-08-10 12:49:25 +00:00
|
|
|
</script>
|