diff --git a/src/lib/components/DriverCard.svelte b/src/lib/components/DriverCard.svelte
index e7d80b1..89b22f3 100644
--- a/src/lib/components/DriverCard.svelte
+++ b/src/lib/components/DriverCard.svelte
@@ -1,11 +1,11 @@
-First Name
+ required={require_inputs}
+ >First Name
+
Last Name
+ required={require_inputs}
+ >Last Name
+
Driver Code
+ required={require_inputs}
+ >Driver Code
+
- Team
+ required={require_inputs}
+ >Team
+
-
+
diff --git a/src/lib/components/Card.svelte b/src/lib/components/LazyCard.svelte
similarity index 55%
rename from src/lib/components/Card.svelte
rename to src/lib/components/LazyCard.svelte
index 1062415..1b4b71e 100644
--- a/src/lib/components/Card.svelte
+++ b/src/lib/components/LazyCard.svelte
@@ -1,6 +1,7 @@
-
-
- {#if imgsrc !== undefined}
-
-
+
+ {#if load}
+
+
+ {#if imgsrc !== undefined}
+
+ {/if}
+
+ {@render children()}
+
{/if}
-
- {@render children()}
-
diff --git a/src/lib/components/Dropdown.svelte b/src/lib/components/LazyDropdown.svelte
similarity index 70%
rename from src/lib/components/Dropdown.svelte
rename to src/lib/components/LazyDropdown.svelte
index 23a0b75..649099e 100644
--- a/src/lib/components/Dropdown.svelte
+++ b/src/lib/components/LazyDropdown.svelte
@@ -4,13 +4,26 @@
import type { Action } from "svelte/action";
import type { HTMLInputAttributes } from "svelte/elements";
import { v4 as uuid } from "uuid";
+ import LazyImage from "./LazyImage.svelte";
- export interface DropdownOption {
+ export interface LazyDropdownOption {
+ /** The label displayed in the list of options. */
label: string;
+
+ /** The value assigned to the dropdown value variable */
value: string;
+
+ /** An optional icon displayed left to the label */
+ icon_url?: string;
+
+ /** The aspect ratio width of the optional icon */
+ icon_width?: number;
+
+ /** The aspect ratio height of the optional icon */
+ icon_height?: number;
}
- interface SearchProps extends HTMLInputAttributes {
+ interface LazyDropdownProps extends HTMLInputAttributes {
children: Snippet;
/** Placeholder for the empty input element */
@@ -37,7 +50,7 @@
/** The options this autocomplete component allows to choose from.
* Example: [[{ label: "Aston", value: "0" }, { label: "VCARB", value: "1" }]].
*/
- options: DropdownOption[];
+ options: LazyDropdownOption[];
}
let {
@@ -56,7 +69,7 @@
},
options,
...restProps
- }: SearchProps = $props();
+ }: LazyDropdownProps = $props();
/** Find the "label" of an option by its "value" */
const get_label = (value: string): string | undefined => {
@@ -78,6 +91,12 @@
if (input) input.dispatchEvent(new CustomEvent("DropdownChange"));
});
+
+ let load: boolean = $state(false);
+
+ const lazy_click_handler = () => {
+ load = true;
+ };
@@ -87,6 +106,7 @@
>
{@render children()}
+
{#if action}
event.preventDefault()}
value={get_label(input_variable) ?? placeholder}
{...restProps}
@@ -106,6 +127,7 @@
autocomplete="off"
style="height: 42px; text-align: start; text-indent: 12px; border-top-left-radius: 0; border-bottom-left-radius: 0;"
use:obtain_input
+ onmousedown={lazy_click_handler}
onkeypress={(event: Event) => event.preventDefault()}
value={get_label(input_variable) ?? placeholder}
{...restProps}
@@ -118,21 +140,25 @@
class="card z-10 w-auto overflow-y-scroll p-2 shadow"
style="max-height: 350px;"
>
-
- {#each options as option}
-
-
- {#if option.icon_url}
-
- {/if}
- {option.label}
-
-
- {/each}
-
+ {#if load}
+
+ {#each options as option}
+
+
+ {#if option.icon_url}
+
+ {/if}
+ {option.label}
+
+
+ {/each}
+
+ {/if}
diff --git a/src/lib/components/LazyImage.svelte b/src/lib/components/LazyImage.svelte
index dd96467..b3d46d4 100644
--- a/src/lib/components/LazyImage.svelte
+++ b/src/lib/components/LazyImage.svelte
@@ -6,19 +6,30 @@
interface LazyImageProps extends HTMLImgAttributes {
/** The URL to the image resource to lazyload */
src: string;
+
+ /** The aspect ratio width used to reserve image space (while its loading) */
+ imgwidth: number;
+
+ /** The aspect ratio height used to reserve image space (while its loading) */
+ imgheight: number;
}
- let { src, ...restProps }: LazyImageProps = $props();
+ let { src, imgwidth, imgheight, ...restProps }: LazyImageProps = $props();
+
+ // Once the image is visible, this will be set to true, triggering the loading
+ let load: boolean = $state(false);
const lazy_visible_handler = () => {
load = true;
};
-
- // Once the image is visible, this will be set to true, triggering the loading
- let load: boolean = $state(false);
-
+
+
{#if load}
{#await fetch_image_base64(src) then data}
diff --git a/src/lib/components/RaceCard.svelte b/src/lib/components/RaceCard.svelte
index fe55c7c..7dee71e 100644
--- a/src/lib/components/RaceCard.svelte
+++ b/src/lib/components/RaceCard.svelte
@@ -1,7 +1,7 @@
-
-
+
diff --git a/src/lib/components/SubstitutionCard.svelte b/src/lib/components/SubstitutionCard.svelte
index d516c36..f587229 100644
--- a/src/lib/components/SubstitutionCard.svelte
+++ b/src/lib/components/SubstitutionCard.svelte
@@ -1,9 +1,9 @@
-
- Substitute
+ Substitute
+
- For
+ required={require_inputs}
+ >For
+
- Race
+ required={require_inputs}
+ >Race
+
@@ -145,4 +149,4 @@
-
+
diff --git a/src/lib/components/TeamCard.svelte b/src/lib/components/TeamCard.svelte
index 4d67d35..b70cbbb 100644
--- a/src/lib/components/TeamCard.svelte
+++ b/src/lib/components/TeamCard.svelte
@@ -1,11 +1,11 @@
-
-
+
diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts
index fe12bc4..602da24 100644
--- a/src/lib/components/index.ts
+++ b/src/lib/components/index.ts
@@ -1,8 +1,8 @@
import Button from "./Button.svelte";
-import Card from "./Card.svelte";
import DriverCard from "./DriverCard.svelte";
-import Dropdown from "./Dropdown.svelte";
import Input from "./Input.svelte";
+import LazyCard from "./LazyCard.svelte";
+import LazyDropdown from "./LazyDropdown.svelte";
import LazyImage from "./LazyImage.svelte";
import LoadingIndicator from "./LoadingIndicator.svelte";
import RaceCard from "./RaceCard.svelte";
@@ -17,10 +17,10 @@ import UserIcon from "./svg/UserIcon.svelte";
export {
// Components
Button,
- Card,
DriverCard,
- Dropdown,
Input,
+ LazyCard,
+ LazyDropdown,
LazyImage,
LoadingIndicator,
RaceCard,