allow to select wallpaper from preview modal

This commit is contained in:
Gamebrary 2021-02-21 12:10:24 -07:00
parent e01e84aa57
commit b711693162
2 changed files with 39 additions and 8 deletions

View file

@ -1,14 +1,26 @@
<template lang="html">
<b-modal
id="previewWallpaper"
:header-bg-variant="darkTheme ? 'dark' : null"
:header-text-variant="darkTheme ? 'white' : null"
:body-bg-variant="darkTheme ? 'dark' : null"
:body-text-variant="darkTheme ? 'white' : null"
hide-footer
size="xl"
>
<template v-slot:modal-header="{ close }">
<modal-header
:title="wallpaper.name"
title="Wallpaper preview"
:subtitle="wallpaper.name"
@close="close"
/>
>
<b-button
v-if="selectable"
@click="select"
>
Select
</b-button>
</modal-header>
</template>
<b-img
@ -20,9 +32,27 @@
</template>
<script>
import { mapGetters } from 'vuex';
export default {
props: {
wallpaper: Object,
selectable: Boolean,
wallpaper: {
type: [Object, Boolean],
default: () => {},
},
},
computed: {
...mapGetters(['darkTheme']),
},
methods: {
select() {
this.$emit('selected', this.wallpaper);
this.$bvModal.hide('previewWallpaper');
},
},
};
</script>

View file

@ -1,13 +1,13 @@
<template lang="html">
<div class="wallpapers">
<preview-wallpaper-modal
v-if="activeWallpaper"
:wallpaper="activeWallpaper"
:selectable="selectable"
@selected="selected"
/>
<b-card
v-for="wallpaper in wallpapers"
@click="openModal(wallpaper)"
:key="wallpaper.name"
:img-src="wallpaper.url"
:img-alt="wallpaper.name"
@ -15,6 +15,7 @@
bg-variant="transparent"
img-width="180"
class="mb-3 overflow-hidden word-wrap clickable"
@click="openModal(wallpaper)"
>
<h6>
{{ wallpaper.name }}
@ -26,7 +27,7 @@
<b-button
variant="danger"
@click="confirmDeleteWallpaper(wallpaper)"
@click.stop="confirmDeleteWallpaper(wallpaper)"
>
<i class="fas fa-trash-alt fa-fw" aria-hidden />
</b-button>
@ -34,7 +35,7 @@
<b-button
v-if="selectable"
variant="primary"
@click="handleClick(wallpaper)"
@click.stop="selected(wallpaper)"
>
<i
v-if="saving"
@ -78,7 +79,7 @@ export default {
this.$bvModal.show('previewWallpaper');
},
handleClick(wallpaper) {
selected(wallpaper) {
if (this.selectable) {
this.$emit('selected', wallpaper);
}