2022-08-29 03:48:29 +00:00
|
|
|
<script lang="ts">
|
2022-10-27 03:49:58 +00:00
|
|
|
import Game from '$lib/components/game/index.svelte';
|
|
|
|
|
import { collectionStore } from '$lib/stores/collectionStore';
|
|
|
|
|
import type { GameType, SavedGameType } from '$root/lib/types';
|
|
|
|
|
import { boredState } from '$root/lib/stores/boredState';
|
|
|
|
|
import RemoveCollectionDialog from '$root/lib/components/dialog/RemoveCollectionDialog.svelte';
|
2022-08-30 22:36:37 +00:00
|
|
|
|
2022-10-27 03:49:58 +00:00
|
|
|
let isOpen: boolean = false;
|
|
|
|
|
let gameToRemove: GameType | SavedGameType;
|
|
|
|
|
console.log('isOpen', isOpen);
|
2022-08-30 22:36:37 +00:00
|
|
|
|
2022-10-27 03:49:58 +00:00
|
|
|
interface RemoveGameEvent extends Event {
|
|
|
|
|
detail: GameType | SavedGameType;
|
|
|
|
|
}
|
2022-08-31 03:57:16 +00:00
|
|
|
|
2022-10-27 03:49:58 +00:00
|
|
|
function handleRemoveGame(event: RemoveGameEvent) {
|
|
|
|
|
console.log('event', event);
|
|
|
|
|
gameToRemove = event?.detail;
|
|
|
|
|
boredState.update((n) => ({
|
|
|
|
|
...n,
|
|
|
|
|
dialog: { isOpen: true, content: RemoveCollectionDialog, additionalData: gameToRemove }
|
|
|
|
|
}));
|
|
|
|
|
}
|
2022-08-29 03:48:29 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<svelte:head>
|
2022-10-27 03:49:58 +00:00
|
|
|
<title>Your Collection | Bored Game</title>
|
2022-08-29 03:48:29 +00:00
|
|
|
</svelte:head>
|
|
|
|
|
|
|
|
|
|
<h1>Your Collection</h1>
|
|
|
|
|
|
|
|
|
|
<div class="games">
|
2022-10-27 03:49:58 +00:00
|
|
|
<div class="games-list">
|
|
|
|
|
{#if $collectionStore.length === 0}
|
|
|
|
|
<h2>No games in your collection</h2>
|
|
|
|
|
{:else}
|
|
|
|
|
{#each $collectionStore as game}
|
|
|
|
|
<Game on:removeGameEvent={handleRemoveGame} minimal {game} />
|
|
|
|
|
{/each}
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2022-08-29 03:48:29 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
2022-10-27 03:49:58 +00:00
|
|
|
h1 {
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
2022-08-29 03:48:29 +00:00
|
|
|
|
2022-10-27 03:49:58 +00:00
|
|
|
.games {
|
|
|
|
|
margin: 2rem 0rem;
|
|
|
|
|
}
|
2022-08-29 03:48:29 +00:00
|
|
|
|
2022-10-27 03:49:58 +00:00
|
|
|
.games-list {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(3, minmax(200px, 1fr));
|
|
|
|
|
gap: 2rem;
|
2022-08-29 03:48:29 +00:00
|
|
|
|
2022-10-27 03:49:58 +00:00
|
|
|
@media (max-width: 800px) {
|
|
|
|
|
grid-template-columns: 1fr 1fr;
|
|
|
|
|
}
|
2022-08-29 03:48:29 +00:00
|
|
|
|
2022-10-27 03:49:58 +00:00
|
|
|
@media (max-width: 550px) {
|
|
|
|
|
grid-template-columns: 1fr;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-29 03:48:29 +00:00
|
|
|
</style>
|