Fixing url on link with icon and fixing nulls on playtime/players.

This commit is contained in:
Bradley Shellnut 2023-01-08 21:50:05 -08:00
parent 18dd5640de
commit 103690fbbc
5 changed files with 1133 additions and 10 deletions

View file

@ -1,6 +1,4 @@
<script lang="ts"> <script lang="ts">
import type { SvelteComponentTyped } from 'svelte';
export let url: string; export let url: string;
export let ariaLabel = `Link to ${url}`; export let ariaLabel = `Link to ${url}`;
export let external = false; export let external = false;

View file

@ -40,13 +40,21 @@ export type ToastData = {
message: string; message: string;
}; };
export type GameMechanic = {
id: string;
name: string;
boardGameAtlasLink: string;
};
export type SavedGameType = { export type SavedGameType = {
id: string; id: string;
name: string; name: string;
thumb_url: string; thumb_url: string;
players: string; players: string;
playtime: string; playtime: string;
mechanics: GameMechanic[];
searchTerms: string; searchTerms: string;
includeInRandom: boolean;
}; };
export type GameType = { export type GameType = {

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@ export const load: PageServerLoad = async ({ params, setHeaders }) => {
const queryParams = { const queryParams = {
ids: `${params?.id}`, ids: `${params?.id}`,
fields: fields:
'id,name,price,min_age,min_players,max_players,thumb_url,playtime,min_playtime,max_playtime,min_age,description,year_published,image_url' 'id,name,price,min_age,min_players,max_players,thumb_url,playtime,min_playtime,max_playtime,min_age,description,year_published,url,image_url'
}; };
const response = await boardGameApi('get', `search`, queryParams); const response = await boardGameApi('get', `search`, queryParams);
@ -19,8 +19,13 @@ export const load: PageServerLoad = async ({ params, setHeaders }) => {
}); });
const game = gameResponse?.games[0]; const game = gameResponse?.games[0];
game.players = `${game.min_players}-${game.max_players}`; if (game.min_players) {
game.playtime = `${game.min_playtime}-${game.max_playtime}`; game.players = `${game.min_players}-${game.max_players}`;
}
if (game.min_playtime) {
game.playtime = `${game.min_playtime}-${game.max_playtime}`;
}
return { return {
game game

View file

@ -82,11 +82,9 @@
{#if +game?.price !== 0.0} {#if +game?.price !== 0.0}
<p>Price: ${game?.price}</p> <p>Price: ${game?.price}</p>
{/if} {/if}
<p> <LinkWithIcon external ariaLabel={`Board Game Atlas Link for ${game.name}`} url={game.url}>
<LinkWithIcon external ariaLabel={`Board Game Atlas Link for ${game.name}`} url={game.url}> Board Game Atlas <ExternalLinkIcon width="24" height="24" />
Board Game Atlas <ExternalLinkIcon width="24" height="24" /> </LinkWithIcon>
</LinkWithIcon>
</p>
</div> </div>
<div style="display: grid; gap: 1.5rem; place-content: center;"> <div style="display: grid; gap: 1.5rem; place-content: center;">
{#if existsInCollection} {#if existsInCollection}