mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Adding dialog overlay to layout css, removing commented css, and updating dialog store on game page remove button click.
This commit is contained in:
parent
26d5b28323
commit
207c93da28
4 changed files with 30 additions and 140 deletions
|
|
@ -148,4 +148,12 @@
|
|||
padding: 40px 0;
|
||||
}
|
||||
}
|
||||
|
||||
:global(.dialog-overlay) {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 100;
|
||||
background-color: rgb(0 0 0);
|
||||
opacity: 0.8;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,12 @@
|
|||
<script lang="ts">
|
||||
import { fade } from 'svelte/transition';
|
||||
import {
|
||||
Dialog,
|
||||
DialogDescription,
|
||||
DialogOverlay,
|
||||
DialogTitle
|
||||
} from '@rgossiaux/svelte-headlessui';
|
||||
import type { GameType, SavedGameType } from '$root/lib/types';
|
||||
import { gameStore } from '$lib/stores/gameSearchStore';
|
||||
import { boredState } from '$root/lib/stores/boredState';
|
||||
import RemoveCollectionDialog from '$root/lib/components/dialog/RemoveCollectionDialog.svelte';
|
||||
import Game from '$lib/components/game/index.svelte';
|
||||
import TextSearch from '$lib/components/search/textSearch/index.svelte';
|
||||
import RandomSearch from '$lib/components/search/random/index.svelte';
|
||||
import Random from '$lib/components/random/index.svelte';
|
||||
import { gameStore } from '$lib/stores/gameSearchStore';
|
||||
import { boredState } from '$root/lib/stores/boredState';
|
||||
import { removeFromCollection } from '$root/lib/util/manipulateCollection';
|
||||
import type { GameType, SavedGameType } from '$root/lib/types';
|
||||
|
||||
async function handleSearch(event: SubmitEvent) {
|
||||
boredState.update((n) => ({ ...n, loading: true }));
|
||||
|
|
@ -41,17 +34,15 @@
|
|||
function handleRemoveGame(event: RemoveGameEvent) {
|
||||
console.log('event', event);
|
||||
gameToRemove = event?.detail;
|
||||
isOpen = true;
|
||||
}
|
||||
|
||||
function removeGame() {
|
||||
removeFromCollection(gameToRemove);
|
||||
isOpen = false;
|
||||
boredState.update((n) => ({
|
||||
...n,
|
||||
dialog: { isOpen: true, content: RemoveCollectionDialog, additionalData: gameToRemove }
|
||||
}));
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Bored Game</title>
|
||||
<title>Bored Game | Home</title>
|
||||
</svelte:head>
|
||||
|
||||
<h1>Search Boardgames!</h1>
|
||||
|
|
@ -76,28 +67,6 @@
|
|||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if isOpen}
|
||||
<div class="container">
|
||||
<div transition:fade>
|
||||
<Dialog open={isOpen} on:close={() => (isOpen = false)} static>
|
||||
<div transition:fade>
|
||||
<DialogOverlay class="dialog-overlay" />
|
||||
<div class="dialog">
|
||||
<DialogTitle>Remove from collection</DialogTitle>
|
||||
<DialogDescription
|
||||
>Are you sure you want to remove from your collection?</DialogDescription
|
||||
>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<button on:click={() => removeGame()}>Remove</button>
|
||||
<button on:click={() => (isOpen = false)}>Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
.games {
|
||||
|
|
@ -132,47 +101,4 @@
|
|||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog {
|
||||
display: grid;
|
||||
gap: 1.5rem;
|
||||
position: absolute;
|
||||
top: 35%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 101;
|
||||
border-radius: 10px;
|
||||
background-color: var(--clr-input-bg);
|
||||
padding: 2rem;
|
||||
min-width: 400px;
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 2rem;
|
||||
margin: 1rem 0;
|
||||
|
||||
button {
|
||||
display: flex;
|
||||
place-content: center;
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
border-radius: 10px;
|
||||
padding: 1rem;
|
||||
background-color: var(--color-btn-primary-active);
|
||||
|
||||
&:hover {
|
||||
background-color: var(--color-btn-primary-active-hover);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:global(.dialog-overlay) {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 100;
|
||||
background-color: rgb(0 0 0);
|
||||
opacity: 0.8;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -64,54 +64,4 @@
|
|||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
/* .dialog {
|
||||
display: grid;
|
||||
gap: 1.5rem;
|
||||
position: absolute;
|
||||
top: 35%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 101;
|
||||
border-radius: 10px;
|
||||
background-color: var(--clr-input-bg);
|
||||
padding: 2rem;
|
||||
min-width: 400px;
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 2rem;
|
||||
margin: 1rem 0;
|
||||
|
||||
button {
|
||||
display: flex;
|
||||
place-content: center;
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
border-radius: 10px;
|
||||
padding: 1rem;
|
||||
background-color: var(--color-btn-primary-active);
|
||||
|
||||
&:hover {
|
||||
background-color: var(--color-btn-primary-active-hover);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:global(.dialog-overlay) {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 100;
|
||||
background-color: rgb(0 0 0);
|
||||
opacity: 0.8;
|
||||
} */
|
||||
|
||||
/*
|
||||
.container > .button {
|
||||
display: grid;
|
||||
justify-content: center;
|
||||
background-color: var(--primary);
|
||||
} */
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
<script lang="ts">
|
||||
// throw new Error(
|
||||
// '@migration task: Add data prop (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292707)'
|
||||
// );
|
||||
|
||||
import { fade } from 'svelte/transition';
|
||||
import {
|
||||
ExternalLinkIcon,
|
||||
|
|
@ -11,12 +7,15 @@
|
|||
PlusCircleIcon,
|
||||
PlusIcon
|
||||
} from '@rgossiaux/svelte-heroicons/outline';
|
||||
import { collectionStore } from '$lib/stores/collectionStore';
|
||||
import type { GameType, SavedGameType } from '$lib/types';
|
||||
import { addToCollection, removeFromCollection } from '$lib/util/manipulateCollection';
|
||||
import { collectionStore } from '$lib/stores/collectionStore';
|
||||
import RemoveCollectionDialog from '$root/lib/components/dialog/RemoveCollectionDialog.svelte';
|
||||
import { addToCollection } from '$lib/util/manipulateCollection';
|
||||
import type { PageData } from './$types';
|
||||
import { boredState } from '$root/lib/stores/boredState';
|
||||
|
||||
$: existsInCollection = $collectionStore.find((item: SavedGameType) => item.id === game.id);
|
||||
|
||||
export let data: PageData;
|
||||
export let game: GameType = data?.game;
|
||||
console.log('page game', game);
|
||||
|
|
@ -29,6 +28,13 @@
|
|||
firstParagraphEnd = game?.description?.indexOf('</ p>') + 5;
|
||||
}
|
||||
console.log('firstParagraphEnd', firstParagraphEnd);
|
||||
|
||||
function removeGame() {
|
||||
boredState.update((n) => ({
|
||||
...n,
|
||||
dialog: { isOpen: true, content: RemoveCollectionDialog, additionalData: game }
|
||||
}));
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
|
@ -59,7 +65,7 @@
|
|||
>Board Game Atlas Link <ExternalLinkIcon width="24" height="24" /></a
|
||||
>
|
||||
{#if existsInCollection}
|
||||
<button class="btn" type="button" on:click={() => removeFromCollection(game)}
|
||||
<button class="btn" type="button" on:click={() => removeGame()}
|
||||
>Remove from collection <MinusCircleIcon width="24" height="24" /></button
|
||||
>
|
||||
{:else}
|
||||
|
|
|
|||
Loading…
Reference in a new issue