gamebrary/src/components/Board/PlatformPicker.vue

87 lines
1.9 KiB
Vue
Raw Normal View History

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" />
2020-08-25 04:21:24 +00:00
<platform-picker-sort-filter />
2020-08-26 16:29:44 +00:00
<b-row>
<b-col
cols="6"
md="4"
lg="3"
v-for="platform in filteredPlatforms"
:key="platform.id"
class="mb-3"
>
2020-08-26 16:29:44 +00:00
<b-card
:header="platform.name"
:header-class="['py-0 px-2', value.includes(platform.id) ? 'text-white' : '']"
:border-variant="value.includes(platform.id) ? 'success' : ''"
:header-bg-variant="value.includes(platform.id) ? 'success' : ''"
body-class="p-2 text-center platform"
header-tag="small"
@click="handleClick(platform.id)"
>
<b-img
:src="`/static/platform-logos/${platform.slug}.${platform.logoFormat
? platform.logoFormat : 'svg'}`"
:alt="platform.name"
class="platform-logo py-2"
/>
</b-card>
</b-col>
</b-row>
2020-08-22 18:59:58 +00:00
</div>
</template>
<script>
2020-08-25 04:21:24 +00:00
import PlatformPickerSortFilter from '@/components/Board/PlatformPickerSortFilter';
import { mapGetters } from 'vuex';
2020-08-22 18:59:58 +00:00
export default {
2020-08-25 04:21:24 +00:00
components: {
PlatformPickerSortFilter,
},
2020-08-22 18:59:58 +00:00
props: {
value: Array,
},
computed: {
2020-08-25 04:21:24 +00:00
...mapGetters(['filteredPlatforms']),
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>
2020-08-26 16:29:44 +00:00
.platform {
height: 80px;
2020-08-22 18:59:58 +00:00
}
.platform-logo {
2020-08-26 16:29:44 +00:00
max-height: 60px;
width: auto;
max-width: 100%;
2020-08-22 18:59:58 +00:00
}
</style>