Lib: Add imgwidth/imgheight to Card component so layout doesn't jump when lazyloading images

This commit is contained in:
2024-12-16 02:28:31 +01:00
parent 0d25f23818
commit 72154656fb
5 changed files with 33 additions and 10 deletions

View File

@ -5,6 +5,7 @@
import { get_by_value } from "$lib/database";
import Dropdown, { type DropdownOption } from "./Dropdown.svelte";
import type { Action } from "svelte/action";
import { DRIVER_HEADSHOT_HEIGHT, DRIVER_HEADSHOT_WIDTH } from "$lib/config";
interface SubstitutionCardProps {
/** The [Substitution] object used to prefill values. */
@ -70,7 +71,7 @@
`update_substitution_headshot_preview_${substitution?.id ?? "create"}`,
) as HTMLImageElement;
preview.src = src;
if (preview) preview.src = src;
}
};
</script>
@ -78,6 +79,8 @@
<Card
imgsrc={get_by_value(drivers, "id", substitution?.substitute ?? "")?.headshot_url ??
headshot_template}
imgwidth={DRIVER_HEADSHOT_WIDTH}
imgheight={DRIVER_HEADSHOT_HEIGHT}
imgid="update_substitution_headshot_preview_{substitution?.id ?? 'create'}"
>
<form method="POST" enctype="multipart/form-data">