6 changed files with 113 additions and 12 deletions
@ -0,0 +1,25 @@ |
|||||||
|
import {createStore} from 'vuex' |
||||||
|
import iziToast from "izitoast"; |
||||||
|
|
||||||
|
export default createStore({ |
||||||
|
state: { |
||||||
|
collection: [], |
||||||
|
wishlist: [], |
||||||
|
}, |
||||||
|
mutations: { |
||||||
|
addOwned(state, minifig) { |
||||||
|
state.collection.push(minifig); |
||||||
|
iziToast.success({ |
||||||
|
title: minifig.name+' has been added to your collection' |
||||||
|
}); |
||||||
|
}, |
||||||
|
addWished(state, minifig) { |
||||||
|
state.wishlist.push(minifig); |
||||||
|
iziToast.success({ |
||||||
|
title: minifig.name+' has been added to your collection' |
||||||
|
}); |
||||||
|
} |
||||||
|
}, |
||||||
|
actions: {}, |
||||||
|
modules: {} |
||||||
|
}) |
@ -1,5 +0,0 @@ |
|||||||
<template> |
|
||||||
<div class="about"> |
|
||||||
<h1>This is an about page</h1> |
|
||||||
</div> |
|
||||||
</template> |
|
@ -0,0 +1,26 @@ |
|||||||
|
<template> |
||||||
|
<div class="row"> |
||||||
|
<div class="col col-md-3" v-for="(minifig, minifigIndex) in $store.state.collection" :key="minifigIndex"> |
||||||
|
<div class="card"> |
||||||
|
<img :src="minifig.set_img_url ?? placeholder" alt="" class="minifig-image"/> |
||||||
|
<a href="javascript:" alt="" class="toggle-button collection-button" @click="$store.commit('addOwned', minifig)"> |
||||||
|
+ |
||||||
|
</a> |
||||||
|
<a href="javascript:" alt="" class="toggle-button wishlist-button" @click="$store.commit('addWished', minifig)"> |
||||||
|
❤ |
||||||
|
</a> |
||||||
|
<div class="card-footer">{{ minifig.name }}</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
export default { |
||||||
|
name: "Collection" |
||||||
|
} |
||||||
|
</script> |
||||||
|
|
||||||
|
<style scoped> |
||||||
|
|
||||||
|
</style> |
Loading…
Reference in new issue