diff --git a/.gitignore b/.gitignore index 64007bd..d8e9851 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ node_modules !.env.example .vercel .output +.idea \ No newline at end of file diff --git a/src/lib/components/LinkWithIcon.svelte b/src/lib/components/LinkWithIcon.svelte new file mode 100644 index 0000000..1241b92 --- /dev/null +++ b/src/lib/components/LinkWithIcon.svelte @@ -0,0 +1,25 @@ + + + + + + + diff --git a/src/lib/components/button/index.svelte b/src/lib/components/button/index.svelte new file mode 100644 index 0000000..482acd5 --- /dev/null +++ b/src/lib/components/button/index.svelte @@ -0,0 +1,37 @@ + + + + + diff --git a/src/lib/components/game/index.svelte b/src/lib/components/game/index.svelte index dd00a37..f269c3b 100644 --- a/src/lib/components/game/index.svelte +++ b/src/lib/components/game/index.svelte @@ -28,27 +28,22 @@
-

{game.name}

{`Image - - {#if !minimal && game?.players && game?.playtime} -
- {#if game.year_published} -

{game.year_published}

- {/if} -

{game.players} {game.max_players === 1 ? 'player' : 'players'}

-

{game.playtime} minutes

-

Minimum Age: {game.min_age}

- - {#if detailed} -
{@html game.description}
- {/if} -
- {/if} +
+

Players: {game.min_players} - {game.max_players}

+

Time: {game.playtime} minutes

+ {#if game?.min_age} +

Min Age: {game.min_age}

+ {/if} + {#if detailed} +
{@html game.description}
+ {/if} +
+
{#if existsInCollection}
@@ -65,6 +67,11 @@ bind:checked={exactMaxPlayers} /> + {#if form?.error?.id === 'maxPlayers'} +

+ Error: {form.error.message} +

+ {/if}
diff --git a/src/lib/types.ts b/src/lib/types.ts index 690db17..458a3b2 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -39,6 +39,9 @@ export type SavedGameType = { id: string; name: string; thumb_url: string; + min_players: number; + max_players: number; + playtime: string } export type GameType = { diff --git a/src/lib/util/gameMapper.ts b/src/lib/util/gameMapper.ts index 7164c6c..d0100f7 100644 --- a/src/lib/util/gameMapper.ts +++ b/src/lib/util/gameMapper.ts @@ -1,12 +1,15 @@ import type { GameType, SavedGameType } from '$lib/types'; export function mapSavedGameToGame(game: SavedGameType): GameType { - const { id, name, thumb_url } = game; + const { id, name, thumb_url, min_players, max_players, playtime } = game; return { id, name, - thumb_url + thumb_url, + min_players, + max_players, + playtime }; } diff --git a/src/routes/game/[id]/+page.svelte b/src/routes/game/[id]/+page.svelte index e9e5bfa..33ab6e0 100644 --- a/src/routes/game/[id]/+page.svelte +++ b/src/routes/game/[id]/+page.svelte @@ -9,11 +9,13 @@ } from '@rgossiaux/svelte-heroicons/outline'; import type { GameType, SavedGameType } from '$lib/types'; import { collectionStore } from '$lib/stores/collectionStore'; + import Button from '$lib/components/button/index.svelte'; 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'; import { browser } from '$app/environment'; + import LinkWithIcon from '$root/lib/components/LinkWithIcon.svelte'; $: existsInCollection = $collectionStore.find((item: SavedGameType) => item.id === game.id); @@ -55,38 +57,36 @@
-

Year Published: {game?.year_published}

-

Players: {game.players} {game.max_players === 1 ? 'player' : 'players'}

+

Year: {game?.year_published}

+

Players: {game.players}

Playtime: {game.playtime} minutes

Minimum Age: {game.min_age}

- {#if +game?.price !== 0.0} + {#if game?.price !== 0.0}

Price: ${game?.price}

{/if} - Board Game Atlas + + Board Game Atlas +
{#if existsInCollection} - + {:else} - + Add to collection + {/if}
diff --git a/src/styles/global.scss b/src/styles/global.scss index 47e79a3..8d84d12 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -348,4 +348,12 @@ ol { .icon { width: 24px; height: 24px; +} + +.center { + text-align: center; +} + +.error { + color: var(--tomatoOrange); } \ No newline at end of file