From 8aa2fd3c2d08a2b2dcd3664272e056261fca82b2 Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Wed, 31 Aug 2022 16:50:45 -0500 Subject: [PATCH 1/4] Testing base dialog at layout level using svelte component. --- .../components/dialog/DefaultDialog.svelte | 67 +++++++++++++++ .../dialog/RemoveCollectionDialog.svelte | 82 +++++++++++++++++++ src/lib/stores/boredState.ts | 25 ++---- src/lib/types.ts | 9 ++ src/routes/+layout.svelte | 53 ++++++++++++ src/routes/collection/+page.svelte | 45 ++-------- 6 files changed, 228 insertions(+), 53 deletions(-) create mode 100644 src/lib/components/dialog/DefaultDialog.svelte create mode 100644 src/lib/components/dialog/RemoveCollectionDialog.svelte diff --git a/src/lib/components/dialog/DefaultDialog.svelte b/src/lib/components/dialog/DefaultDialog.svelte new file mode 100644 index 0000000..262cc03 --- /dev/null +++ b/src/lib/components/dialog/DefaultDialog.svelte @@ -0,0 +1,67 @@ + + + { + boredState.update((n) => ({ ...n, dialog: { ...n.dialog, isOpen: false } })); + }} + static +> +
+ +
+ Default Dialog + Dialog Description + + +
+
+ + diff --git a/src/lib/components/dialog/RemoveCollectionDialog.svelte b/src/lib/components/dialog/RemoveCollectionDialog.svelte new file mode 100644 index 0000000..234d62b --- /dev/null +++ b/src/lib/components/dialog/RemoveCollectionDialog.svelte @@ -0,0 +1,82 @@ + + + { + boredState.update((n) => ({ ...n, dialog: { isOpen: false } })); + }} + static +> +
+ +
+ Remove from collection + Are you sure you want to remove from your collection? + + +
+
+
+ + diff --git a/src/lib/stores/boredState.ts b/src/lib/stores/boredState.ts index 78f10d3..5824923 100644 --- a/src/lib/stores/boredState.ts +++ b/src/lib/stores/boredState.ts @@ -1,26 +1,19 @@ -import type { BoredStore } from '$lib/types'; +import type { BoredStore, Dialog } from '$lib/types'; import { writable } from 'svelte/store'; +import DefaultDialog from '../components/dialog/DefaultDialog.svelte'; // import { BoredStore } from '$lib/types'; // Custom store const state = () => { - const { subscribe, set, update } = writable({ loading: false }); - - // function remove(id: string) { - // update((store) => { - // const newStore = store.filter((item: GameType) => item.id !== id); - // return [...newStore]; - // }); - // } - - // function removeAll() { - // update(() => { - // return []; - // }); - // } + const initialDialog: Dialog = { + isOpen: false, + content: DefaultDialog + } + const initial = { loading: false, dialog: initialDialog } + const { subscribe, set, update } = writable(initial); function clear() { - set({ loading: false }); + set(initial); } return { subscribe, set, update, clear }; diff --git a/src/lib/types.ts b/src/lib/types.ts index 6944ee8..a4d83dc 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -1,5 +1,14 @@ +import type { SvelteComponent } from "svelte"; + +export type Dialog = { + isOpen: boolean; + content?: typeof SvelteComponent; + additionalData?: SavedGameType | GameType; +} + export type BoredStore = { loading: boolean; + dialog: Dialog; }; export enum ToastType { diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index d894f0b..d020db2 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,6 +1,7 @@ @@ -48,28 +41,6 @@ {/if} -{#if isOpen} -
-
- (isOpen = false)} static> -
- -
- Remove from collection - Are you sure you want to remove from your collection? - - -
-
-
-
-
-{/if} From 207c93da2835492e5c8cb300270cac47302f2c0c Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Wed, 31 Aug 2022 21:32:30 -0500 Subject: [PATCH 3/4] Adding dialog overlay to layout css, removing commented css, and updating dialog store on game page remove button click. --- src/routes/+layout.svelte | 8 +++ src/routes/+page.svelte | 92 +++--------------------------- src/routes/collection/+page.svelte | 50 ---------------- src/routes/game/[id]/+page.svelte | 20 ++++--- 4 files changed, 30 insertions(+), 140 deletions(-) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 15b3b46..2c5e64f 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -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; + } diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index d1c55cb..3aae9e4 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,19 +1,12 @@ - Bored Game + Bored Game | Home

Search Boardgames!

@@ -76,28 +67,6 @@ {/if} -{#if isOpen} -
-
- (isOpen = false)} static> -
- -
- Remove from collection - Are you sure you want to remove from your collection? - - -
-
-
-
-
-{/if} diff --git a/src/routes/collection/+page.svelte b/src/routes/collection/+page.svelte index 2958913..a21a0ed 100644 --- a/src/routes/collection/+page.svelte +++ b/src/routes/collection/+page.svelte @@ -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); - } */ diff --git a/src/routes/game/[id]/+page.svelte b/src/routes/game/[id]/+page.svelte index 4b6f338..489d9b3 100644 --- a/src/routes/game/[id]/+page.svelte +++ b/src/routes/game/[id]/+page.svelte @@ -1,8 +1,4 @@ @@ -59,7 +65,7 @@ >Board Game Atlas Link {#if existsInCollection} - {:else} From bc59d64f7cb9f2051795d9d789049ac116808259 Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Thu, 1 Sep 2022 00:17:11 -0500 Subject: [PATCH 4/4] Max height to button, modal gets 50%. --- .../components/dialog/RemoveCollectionDialog.svelte | 2 +- src/lib/components/game/index.svelte | 11 ++++++----- src/routes/collection/+page.svelte | 2 +- src/routes/game/[id]/+page.svelte | 5 +++++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/lib/components/dialog/RemoveCollectionDialog.svelte b/src/lib/components/dialog/RemoveCollectionDialog.svelte index 234d62b..4045308 100644 --- a/src/lib/components/dialog/RemoveCollectionDialog.svelte +++ b/src/lib/components/dialog/RemoveCollectionDialog.svelte @@ -49,7 +49,7 @@ display: grid; gap: 1.5rem; position: absolute; - top: 35%; + top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 101; diff --git a/src/lib/components/game/index.svelte b/src/lib/components/game/index.svelte index 3bd90b1..4ee00f8 100644 --- a/src/lib/components/game/index.svelte +++ b/src/lib/components/game/index.svelte @@ -73,12 +73,9 @@ background-color: var(--color-btn-primary-active); } - /* :global(.icon) { - width: 24px; - height: 24px; - } */ - .game-container { + /* display: grid; */ + /* grid-template-rows: minmax(25px, 50px) 1fr minmax(50px, 75px); */ display: flex; flex-wrap: wrap; @@ -107,5 +104,9 @@ padding: 0.25rem; } } + + .btn { + max-height: 50px; + } } diff --git a/src/routes/collection/+page.svelte b/src/routes/collection/+page.svelte index a21a0ed..d6d410e 100644 --- a/src/routes/collection/+page.svelte +++ b/src/routes/collection/+page.svelte @@ -60,7 +60,7 @@ grid-template-columns: 1fr 1fr; } - @media (max-width: 650px) { + @media (max-width: 550px) { grid-template-columns: 1fr; } } diff --git a/src/routes/game/[id]/+page.svelte b/src/routes/game/[id]/+page.svelte index 489d9b3..eb41f3b 100644 --- a/src/routes/game/[id]/+page.svelte +++ b/src/routes/game/[id]/+page.svelte @@ -147,4 +147,9 @@ gap: 1.5rem; margin: 1rem; } + + .with-icon { + display: flex; + place-items: center; + }