toogle cards

This commit is contained in:
valere
2025-12-21 20:20:20 +01:00
parent c0d79591c3
commit 55cae0b9c6

View File

@@ -7,13 +7,8 @@
</button> </button>
</div> </div>
<div class="controls flex justify-center z-50 relative"> <div class="controls flex justify-center z-50 relative">
<button class="px-4 py-2 text-black hover:text-black bg-esyellow transition-colors" <button class="px-4 py-2 text-black hover:text-black bg-esyellow transition-colors" @click="toggleAllCards">
@click="cardStore.revealAllCards(tracks)"> {{ allCardsRevealed ? 'Hide All' : 'Reveal All' }}
reveal
</button>
<button class="px-4 py-2 text-black hover:text-black bg-esyellow transition-colors"
@click="cardStore.hideAllCards(tracks)">
hide
</button> </button>
<SearchInput @search="onSearch" /> <SearchInput @search="onSearch" />
<SelectCardRank @change="onRankChange" /> <SelectCardRank @change="onRankChange" />
@@ -27,7 +22,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref } from 'vue' import { computed, ref, watch } from 'vue'
import { useDataStore } from '~/store/data' import { useDataStore } from '~/store/data'
import { useCardStore } from '~/store/card' import { useCardStore } from '~/store/card'
import { usePlayerStore } from '~/store/player' import { usePlayerStore } from '~/store/player'
@@ -57,6 +52,20 @@ const searchQuery = ref('')
const isCardRevealed = (trackId: number) => cardStore.isCardRevealed(trackId) const isCardRevealed = (trackId: number) => cardStore.isCardRevealed(trackId)
// Vérifie si toutes les cartes sont révélées
const allCardsRevealed = computed(() => {
return tracks.value.every(track => cardStore.isCardRevealed(track.id))
})
// Fonction pour basculer l'état de toutes les cartes
const toggleAllCards = () => {
if (allCardsRevealed.value) {
cardStore.hideAllCards(tracks.value)
} else {
cardStore.revealAllCards(tracks.value)
}
}
const closeDatBox = () => { const closeDatBox = () => {
uiStore.closeBox() uiStore.closeBox()
} }