gamebrary/src/components/Board/PlatformPicker.vue

81 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-22 18:59:58 +00:00
<div class="platforms">
<b-card
2020-08-25 04:21:24 +00:00
v-for="platform in filteredPlatforms" :key="platform.id"
2020-08-23 07:34:16 +00:00
: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-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>
.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>