Platforms updates

This commit is contained in:
Roman Cervantes 2019-04-17 22:43:22 -07:00
parent 78b49ec644
commit b12d608c41
3 changed files with 137 additions and 36 deletions

View file

@ -0,0 +1,107 @@
<template lang="html">
<div @click="changePlatform" :class="['platform', { dark: darkModeEnabled }]">
<div class="platform-logo" :style="style">
<img
:src='`/static/img/platforms/${platformData.code}.svg`'
:alt="platformData.name"
/>
</div>
<h4>
{{ platformData.name }}
<small v-if="ownedPlatform(platformData.code)">
({{ getGameCount(platformData.code) }} Games)
</small>
</h4>
</div>
</template>
<script>
import { mapState, mapGetters } from 'vuex';
export default {
props: {
platformData: Object,
},
computed: {
...mapState(['gameLists', 'platform', 'settings']),
...mapGetters(['darkModeEnabled']),
style() {
return `background-color: ${this.platformData.hex || '#fff'}`;
},
},
methods: {
changePlatform() {
this.$store.commit('SET_PLATFORM', this.platformData);
this.$router.push({ name: 'game-board' });
},
ownedPlatform(platformCode) {
return this.gameLists && this.gameLists[platformCode];
},
getGameCount(platform) {
return this.gameLists[platform]
.map((list) => list.games.length)
.reduce((totalCount, listCount) => totalCount + listCount);
},
},
};
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
@import "~styles/styles.scss";
.platform {
display: grid;
grid-template-columns: 100px auto;
grid-gap: $gp;
align-items: center;
margin-bottom: $gp / 2;
cursor: pointer;
border-radius: $border-radius;
transition: 100ms all ease;
color: $color-darker-gray;
&:hover {
transition: 100ms all ease;
background-color: rgba(255, 255, 255, .2);
}
&.dark {
color: $color-gray;
&:hover {
background-color: $color-darker-gray;
}
}
}
.platform-logo {
padding: $gp / 2;
min-height: 50px;
justify-content: center;
align-items: center;
display: flex;
align-items: center;
border-radius: $border-radius;
img {
margin: 0 auto;
width: 100%;
height: auto;
}
}
small {
color: $color-dark-gray;
@media($small) {
display: flex;
}
}
</style>

View file

@ -1,6 +1,6 @@
<template lang="html">
<div :class="['platforms-page', { dark: darkModeEnabled }]">
<div :class="['platform-list', { reverse: sortedByGeneration }]">
<div :class="['platforms', { reverse: sortedByGeneration }]">
<div v-for="(group, label) in filteredPlatforms" :key="label">
<h4 v-if="sortedByGeneration">{{ groupLabel(label) }}</h4>
@ -12,7 +12,7 @@
</div>
</div>
<div class="open-source-message">
<footer>
<small>
Gamebrary is free and open source, consider helping its development by
<a href="https://www.paypal.me/RomanCervantes/5" target="_blank">
@ -30,7 +30,7 @@
</small>
<igdb-credit gray />
</div>
</footer>
</div>
</template>
@ -126,15 +126,14 @@ export default {
&.dark {
color: $color-gray;
h4 {
background-color: $color-darkest-gray;
}
}
}
h4 {
position: sticky;
top: $gp;
}
.platform-list {
.platforms {
display: flex;
flex-direction: column;
@ -143,20 +142,15 @@ export default {
}
}
.platforms {
// margin-top: $gp;
// display: grid;
// grid-template-columns: auto;
// grid-gap: $gp;
// grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
margin: 0;
@media($small) {
}
h4 {
position: sticky;
top: 0;
padding: $gp / 3 0;
background-color: $color-gray;
}
.open-source-message {
margin-top: $gp;
footer {
padding: $gp / 2 0;
justify-content: center;
display: flex;
align-items: center;

View file

@ -1,4 +1,18 @@
export default [
{
name: 'Nintendo Switch',
code: 'nintendo-switch',
hex: '#e60012',
id: 130,
generation: 8,
},
{
name: 'PlayStation 4',
code: 'ps4',
hex: '#2E6DB4',
id: 48,
generation: 8,
},
{
name: 'Xbox One',
code: 'xbox-one',
@ -12,13 +26,6 @@ export default [
generation: 8,
hex: '#171a21',
},
{
name: 'Nintendo Switch',
code: 'nintendo-switch',
hex: '#e60012',
id: 130,
generation: 8,
},
{
name: 'NES',
code: 'nes',
@ -60,18 +67,11 @@ export default [
id: 9,
generation: 7,
},
{
name: 'PlayStation 4',
code: 'ps4',
hex: '#2E6DB4',
id: 48,
generation: 8,
},
{
name: 'PC - Windows',
code: 'win',
id: 6,
generation: 0,
generation: 8,
},
{
name: 'Super Nintendo',