gamebrary/src/components/Board/PlatformPicker.vue

71 lines
1.5 KiB
Vue
Raw Normal View History

2020-11-21 06:23:40 +00:00
<!-- TODO: return filteredPlatforms getter and return sort/filters -->
2020-08-22 18:59:58 +00:00
<template lang="html">
2020-11-23 23:15:43 +00:00
<b-list-group class="platforms mb-3">
<b-list-group-item
v-for="platform in filteredPlatforms"
:key="platform.id"
button
:active="value.includes(platform.id)"
@click="handleClick(platform.id)"
2020-10-14 23:57:10 +00:00
>
2020-11-23 23:15:43 +00:00
<b-img
:src="`/static/platform-logos/${platform.slug}.${platform.logoFormat}`"
:alt="platform.name"
width="40"
class="pr-2"
/>
2020-11-21 06:23:40 +00:00
2020-11-23 23:15:43 +00:00
{{ platform.name }}
</b-list-group-item>
</b-list-group>
2020-08-22 18:59:58 +00:00
</template>
<script>
2020-11-23 23:15:43 +00:00
import { mapState, mapGetters } from 'vuex';
2020-08-22 18:59:58 +00:00
export default {
props: {
value: Array,
},
computed: {
2020-11-21 06:23:40 +00:00
...mapState(['platforms']),
2020-11-23 23:15:43 +00:00
...mapGetters(['filteredPlatforms']),
2020-10-14 23:20:25 +00:00
2020-11-21 06:23:40 +00:00
buttonLabel() {
2020-10-14 23:20:25 +00:00
return this.value.length
? this.$t('board.settings.platformLabel', { platformCount: this.value.length })
: this.$t('board.settings.platformPlaceholder');
},
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>
2020-10-14 23:57:10 +00:00
2020-10-21 19:02:32 +00:00
<style lang="scss" rel="stylesheet/scss" scoped>
2020-11-23 23:15:43 +00:00
.platforms {
2020-10-21 19:02:32 +00:00
max-height: 50vh;
2020-11-23 23:15:43 +00:00
overflow: scroll;
overflow-x: hidden;
2020-10-14 23:57:10 +00:00
}
</style>