Last active
April 21, 2021 20:31
-
-
Save lpj145/c07ff94d110cae2faf4c80dfb350276c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export default { | |
name: 'CardContainer', | |
} | |
</script> | |
<template> | |
<div class="container is-fluid is-flex is-flex-direction-column"> | |
<ul id="matchesList" class="is-flex is-flex-direction-column is-align-item"> | |
<slot name="favoritos" /> | |
<slot /> | |
</ul> | |
</div> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import CardContainer from '@/modules/Warehouse/components/CardContainer' | |
export default { | |
name: 'CardList', | |
components: { CardContainer }, | |
data: () => ({ | |
items: [], | |
itemsFavoritos: [] | |
}), | |
methods: { | |
toggleFavorite(id) { | |
if (this.itemsFavoritos.includes(id)) { | |
this.itemsFavoritos = this.itemsFavoritos.filter((i) => i !== id) | |
return | |
} | |
this.itemsFavoritos.push(id) | |
}, | |
hasFavorited(arg) { | |
return this.itemsFavoritos.includes(arg) | |
} | |
} | |
} | |
</script> | |
<template> | |
<CardContainer> | |
<CardItem | |
v-for="match in items" | |
@favorite-toggle="toggleFavorite" | |
:match="match" | |
:key="match.bt365_id" | |
:slot="hasFavorited(match.bt365_id) ? 'favorites' : 'default'" | |
/> | |
</CardContainer> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment