2020-08-22 18:59:58 +00:00
|
|
|
<template lang="html">
|
|
|
|
<div class="platform-picker">
|
|
|
|
<b-form-group label="Select platform(s)" class="mb-1" />
|
|
|
|
|
|
|
|
<div class="platforms">
|
|
|
|
<b-card
|
2020-08-23 07:34:16 +00:00
|
|
|
v-for="platform in sortedPlatforms" :key="platform.id"
|
|
|
|
:header="platform.name"
|
|
|
|
:header-class="['py-0 px-2', value.includes(platform.id) ? 'text-white' : '']"
|
2020-08-22 18:59:58 +00:00
|
|
|
:border-variant="value.includes(platform.id) ? 'success' : ''"
|
2020-08-23 07:34:16 +00:00
|
|
|
:header-bg-variant="value.includes(platform.id) ? 'success' : ''"
|
|
|
|
body-class="d-flex p-2 text-center justify-content-center align-items-center"
|
|
|
|
header-tag="small"
|
2020-08-22 18:59:58 +00:00
|
|
|
@click="handleClick(platform.id)"
|
|
|
|
>
|
|
|
|
<b-img
|
2020-08-23 07:34:16 +00:00
|
|
|
:src="`/static/platform-logos/${platform.slug}.${platform.logoFormat
|
|
|
|
? platform.logoFormat : 'svg'}`"
|
2020-08-22 18:59:58 +00:00
|
|
|
:alt="platform.name"
|
|
|
|
fluid
|
2020-08-23 07:34:16 +00:00
|
|
|
class="platform-logo py-2"
|
2020-08-22 18:59:58 +00:00
|
|
|
/>
|
2020-08-23 07:34:16 +00:00
|
|
|
<!-- {{ platform.id }} -->
|
2020-08-22 18:59:58 +00:00
|
|
|
</b-card>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-08-23 07:34:16 +00:00
|
|
|
import orderBy from 'lodash.orderBy';
|
2020-08-22 18:59:58 +00:00
|
|
|
import { mapState } from 'vuex';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: Array,
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
...mapState(['platforms']),
|
|
|
|
|
2020-08-23 07:34:16 +00:00
|
|
|
sortedPlatforms() {
|
|
|
|
return orderBy(this.platforms, 'generation')
|
|
|
|
.filter(({ generation }) => Boolean(generation))
|
|
|
|
.reverse();
|
|
|
|
},
|
2020-08-22 18:59:58 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
handleClick(platformId) {
|
|
|
|
if (this.value.includes(platformId)) {
|
|
|
|
this.removePlatform(platformId);
|
|
|
|
} else {
|
|
|
|
this.selectPlatform(platformId);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
selectPlatform(platformId) {
|
|
|
|
this.value.push(platformId);
|
|
|
|
},
|
|
|
|
|
|
|
|
removePlatform(platformId) {
|
|
|
|
const index = this.value.indexOf(platformId);
|
|
|
|
|
|
|
|
this.value.splice(index, 1);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" rel="stylesheet/scss" scoped>
|
|
|
|
.platforms {
|
|
|
|
display: grid;
|
2020-08-23 07:34:16 +00:00
|
|
|
grid-template-columns: 1fr 1fr 1fr 1fr;
|
|
|
|
grid-gap: .5rem;
|
2020-08-22 18:59:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.platform-logo {
|
2020-08-23 07:34:16 +00:00
|
|
|
max-height: 80px;
|
2020-08-22 18:59:58 +00:00
|
|
|
}
|
|
|
|
</style>
|