From 2d2fd9f622c35b8b696299c0e10dd6bf2d8abe5d Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Fri, 27 Dec 2024 19:16:02 +0100 Subject: [PATCH] Lib: Remove non-lazy image We need the width/height anyways to determine the max size, so don't bother with non-lazy stuff --- src/lib/components/Image.svelte | 15 ------------ src/lib/components/LazyImage.svelte | 3 ++- src/lib/components/cards/Card.svelte | 23 +++++++++++++++---- src/lib/components/cards/DriverCard.svelte | 3 +++ src/lib/components/cards/RaceCard.svelte | 3 +++ .../components/cards/SubstitutionCard.svelte | 3 +++ src/lib/components/cards/TeamCard.svelte | 11 ++++++--- src/lib/components/form/Dropdown.svelte | 11 +++++++-- src/lib/components/form/Dropdown.ts | 6 +++++ src/lib/components/index.ts | 2 -- 10 files changed, 53 insertions(+), 27 deletions(-) delete mode 100644 src/lib/components/Image.svelte diff --git a/src/lib/components/Image.svelte b/src/lib/components/Image.svelte deleted file mode 100644 index b7a5cb2..0000000 --- a/src/lib/components/Image.svelte +++ /dev/null @@ -1,15 +0,0 @@ - - -{#await fetch_image_base64(src) then data} - -{/await} diff --git a/src/lib/components/LazyImage.svelte b/src/lib/components/LazyImage.svelte index 184deb9..423e3a3 100644 --- a/src/lib/components/LazyImage.svelte +++ b/src/lib/components/LazyImage.svelte @@ -47,7 +47,8 @@
{#if load} {#await fetch_image_base64(src) then data} diff --git a/src/lib/components/cards/Card.svelte b/src/lib/components/cards/Card.svelte index f889c65..39e19c8 100644 --- a/src/lib/components/cards/Card.svelte +++ b/src/lib/components/cards/Card.svelte @@ -1,15 +1,22 @@
{#if imgsrc !== undefined} - {/if} diff --git a/src/lib/components/cards/DriverCard.svelte b/src/lib/components/cards/DriverCard.svelte index 2a9ded0..9665fc0 100644 --- a/src/lib/components/cards/DriverCard.svelte +++ b/src/lib/components/cards/DriverCard.svelte @@ -8,6 +8,7 @@ } from "@skeletonlabs/skeleton"; import { Button, Input, Card, Dropdown, type DropdownOption } from "$lib/components"; import type { Driver } from "$lib/schema"; + import { DRIVER_HEADSHOT_HEIGHT, DRIVER_HEADSHOT_WIDTH } from "$lib/config"; interface DriverCardProps { /** The [Driver] object used to prefill values. */ @@ -58,6 +59,8 @@ imgsrc={driver?.headshot_url ?? headshot_template} imgid="update_driver_headshot_preview_{driver?.id ?? 'create'}" width="w-full sm:w-auto" + imgwidth={DRIVER_HEADSHOT_WIDTH} + imgheight={DRIVER_HEADSHOT_HEIGHT} >
diff --git a/src/lib/components/cards/RaceCard.svelte b/src/lib/components/cards/RaceCard.svelte index 5ed7a2a..cfa27a9 100644 --- a/src/lib/components/cards/RaceCard.svelte +++ b/src/lib/components/cards/RaceCard.svelte @@ -4,6 +4,7 @@ import { Button, Card, Input } from "$lib/components"; import type { Race } from "$lib/schema"; import { format } from "date-fns"; + import { RACE_PICTOGRAM_HEIGHT, RACE_PICTOGRAM_WIDTH } from "$lib/config"; interface RaceCardProps { /** The [Race] object used to prefill values. */ @@ -66,6 +67,8 @@ imgsrc={race?.pictogram_url ?? pictogram_template} imgid="update_race_pictogram_preview_{race?.id ?? 'create'}" width="w-full sm:w-auto" + imgwidth={RACE_PICTOGRAM_WIDTH} + imgheight={RACE_PICTOGRAM_HEIGHT} > diff --git a/src/lib/components/cards/SubstitutionCard.svelte b/src/lib/components/cards/SubstitutionCard.svelte index 1b09738..5804587 100644 --- a/src/lib/components/cards/SubstitutionCard.svelte +++ b/src/lib/components/cards/SubstitutionCard.svelte @@ -4,6 +4,7 @@ import { get_by_value } from "$lib/database"; import type { Action } from "svelte/action"; import { getModalStore, type ModalStore } from "@skeletonlabs/skeleton"; + import { DRIVER_HEADSHOT_HEIGHT, DRIVER_HEADSHOT_WIDTH } from "$lib/config"; interface SubstitutionCardProps { /** The [Substitution] object used to prefill values. */ @@ -93,6 +94,8 @@ headshot_template} imgid="update_substitution_headshot_preview_{substitution?.id ?? 'create'}" width="w-full sm:w-auto" + imgwidth={DRIVER_HEADSHOT_WIDTH} + imgheight={DRIVER_HEADSHOT_HEIGHT} > diff --git a/src/lib/components/cards/TeamCard.svelte b/src/lib/components/cards/TeamCard.svelte index 184dd7e..30ebcc9 100644 --- a/src/lib/components/cards/TeamCard.svelte +++ b/src/lib/components/cards/TeamCard.svelte @@ -1,8 +1,9 @@