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">
import type { SvelteComponentTyped } from 'svelte';
export let url: string;
export let ariaLabel = `Link to ${url}`;
export let external = false;

View file

@ -40,13 +40,21 @@ export type ToastData = {
message: string;
};
export type GameMechanic = {
id: string;
name: string;
boardGameAtlasLink: string;
};
export type SavedGameType = {
id: string;
name: string;
thumb_url: string;
players: string;
playtime: string;
mechanics: GameMechanic[];
searchTerms: string;
includeInRandom: boolean;
};
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 = {
ids: `${params?.id}`,
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);
@ -19,8 +19,13 @@ export const load: PageServerLoad = async ({ params, setHeaders }) => {
});
const game = gameResponse?.games[0];
game.players = `${game.min_players}-${game.max_players}`;
game.playtime = `${game.min_playtime}-${game.max_playtime}`;
if (game.min_players) {
game.players = `${game.min_players}-${game.max_players}`;
}
if (game.min_playtime) {
game.playtime = `${game.min_playtime}-${game.max_playtime}`;
}
return {
game

View file

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