Compare commits
4 Commits
0b3184ba56
...
6178312fde
| Author | SHA1 | Date | |
|---|---|---|---|
| 6178312fde | |||
| 7131aebf86 | |||
| 379c58d0c2 | |||
| 6b87d05de6 |
@ -1,11 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { get_image_preview_event_handler } from "$lib/image";
|
import { get_image_preview_event_handler } from "$lib/image";
|
||||||
import { FileDropzone, SlideToggle } from "@skeletonlabs/skeleton";
|
import { FileDropzone, SlideToggle } from "@skeletonlabs/skeleton";
|
||||||
import Card from "./Card.svelte";
|
import LazyCard from "./LazyCard.svelte";
|
||||||
import Button from "./Button.svelte";
|
import Button from "./Button.svelte";
|
||||||
import type { Driver } from "$lib/schema";
|
import type { Driver } from "$lib/schema";
|
||||||
import Input from "./Input.svelte";
|
import Input from "./Input.svelte";
|
||||||
import Dropdown, { type DropdownOption } from "./Dropdown.svelte";
|
import LazyDropdown, { type DropdownOption } from "./LazyDropdown.svelte";
|
||||||
import { DRIVER_HEADSHOT_HEIGHT, DRIVER_HEADSHOT_WIDTH } from "$lib/config";
|
import { DRIVER_HEADSHOT_HEIGHT, DRIVER_HEADSHOT_WIDTH } from "$lib/config";
|
||||||
|
|
||||||
interface DriverCardProps {
|
interface DriverCardProps {
|
||||||
@ -42,7 +42,7 @@
|
|||||||
}: DriverCardProps = $props();
|
}: DriverCardProps = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card
|
<LazyCard
|
||||||
imgsrc={driver?.headshot_url ?? headshot_template}
|
imgsrc={driver?.headshot_url ?? headshot_template}
|
||||||
imgwidth={DRIVER_HEADSHOT_WIDTH}
|
imgwidth={DRIVER_HEADSHOT_WIDTH}
|
||||||
imgheight={DRIVER_HEADSHOT_HEIGHT}
|
imgheight={DRIVER_HEADSHOT_HEIGHT}
|
||||||
@ -64,8 +64,9 @@
|
|||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
labelwidth="120px"
|
labelwidth="120px"
|
||||||
disabled={disable_inputs}
|
disabled={disable_inputs}
|
||||||
required={require_inputs}>First Name</Input
|
required={require_inputs}
|
||||||
>
|
>First Name
|
||||||
|
</Input>
|
||||||
<Input
|
<Input
|
||||||
id="driver_last_name_{driver?.id ?? 'create'}"
|
id="driver_last_name_{driver?.id ?? 'create'}"
|
||||||
name="lastname"
|
name="lastname"
|
||||||
@ -73,8 +74,9 @@
|
|||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
labelwidth="120px"
|
labelwidth="120px"
|
||||||
disabled={disable_inputs}
|
disabled={disable_inputs}
|
||||||
required={require_inputs}>Last Name</Input
|
required={require_inputs}
|
||||||
>
|
>Last Name
|
||||||
|
</Input>
|
||||||
<Input
|
<Input
|
||||||
id="driver_code_{driver?.id ?? 'create'}"
|
id="driver_code_{driver?.id ?? 'create'}"
|
||||||
name="code"
|
name="code"
|
||||||
@ -84,18 +86,20 @@
|
|||||||
maxlength={3}
|
maxlength={3}
|
||||||
labelwidth="120px"
|
labelwidth="120px"
|
||||||
disabled={disable_inputs}
|
disabled={disable_inputs}
|
||||||
required={require_inputs}>Driver Code</Input
|
required={require_inputs}
|
||||||
>
|
>Driver Code
|
||||||
|
</Input>
|
||||||
|
|
||||||
<!-- Driver team input -->
|
<!-- Driver team input -->
|
||||||
<Dropdown
|
<LazyDropdown
|
||||||
name="team"
|
name="team"
|
||||||
input_variable={team_select_value}
|
input_variable={team_select_value}
|
||||||
options={team_select_options}
|
options={team_select_options}
|
||||||
labelwidth="120px"
|
labelwidth="120px"
|
||||||
disabled={disable_inputs}
|
disabled={disable_inputs}
|
||||||
required={require_inputs}>Team</Dropdown
|
required={require_inputs}
|
||||||
>
|
>Team
|
||||||
|
</LazyDropdown>
|
||||||
|
|
||||||
<!-- Headshot upload -->
|
<!-- Headshot upload -->
|
||||||
<FileDropzone
|
<FileDropzone
|
||||||
@ -133,4 +137,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</Card>
|
</LazyCard>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Snippet } from "svelte";
|
import type { Snippet } from "svelte";
|
||||||
import LazyImage from "./LazyImage.svelte";
|
import LazyImage from "./LazyImage.svelte";
|
||||||
|
import { lazyload } from "$lib/lazyload";
|
||||||
|
|
||||||
interface CardProps {
|
interface CardProps {
|
||||||
children: Snippet;
|
children: Snippet;
|
||||||
@ -12,10 +13,10 @@
|
|||||||
imgid?: string | undefined;
|
imgid?: string | undefined;
|
||||||
|
|
||||||
/** The aspect ratio width used to reserve image space (while its loading) */
|
/** The aspect ratio width used to reserve image space (while its loading) */
|
||||||
imgwidth?: number;
|
imgwidth: number;
|
||||||
|
|
||||||
/** The aspect ratio height used to reserve image space (while its loading) */
|
/** The aspect ratio height used to reserve image space (while its loading) */
|
||||||
imgheight?: number;
|
imgheight: number;
|
||||||
|
|
||||||
/** Hide the header image element. It can be shown by removing the "hidden" property using JS and the imgid. */
|
/** Hide the header image element. It can be shown by removing the "hidden" property using JS and the imgid. */
|
||||||
imghidden?: boolean;
|
imghidden?: boolean;
|
||||||
@ -28,29 +29,39 @@
|
|||||||
children,
|
children,
|
||||||
imgsrc = undefined,
|
imgsrc = undefined,
|
||||||
imgid = undefined,
|
imgid = undefined,
|
||||||
imgwidth = undefined,
|
imgwidth,
|
||||||
imgheight = undefined,
|
imgheight,
|
||||||
imghidden = false,
|
imghidden = false,
|
||||||
fullwidth = false,
|
fullwidth = false,
|
||||||
...restProps
|
...restProps
|
||||||
}: CardProps = $props();
|
}: CardProps = $props();
|
||||||
|
|
||||||
|
let load: boolean = $state(false);
|
||||||
|
|
||||||
|
const lazy_visible_handler = () => {
|
||||||
|
load = true;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="card overflow-hidden bg-white shadow {fullwidth ? 'w-full' : 'w-auto'}">
|
<div use:lazyload onLazyVisible={lazy_visible_handler}>
|
||||||
<!-- Allow empty strings for images that only appear after user action -->
|
{#if load}
|
||||||
{#if imgsrc !== undefined}
|
<div class="card overflow-hidden bg-white shadow {fullwidth ? 'w-full' : 'w-auto'}">
|
||||||
<div style="width: auto; aspect-ratio: {imgwidth} / {imgheight};">
|
<!-- Allow empty strings for images that only appear after user action -->
|
||||||
<LazyImage
|
{#if imgsrc !== undefined}
|
||||||
id={imgid}
|
<LazyImage
|
||||||
src={imgsrc}
|
id={imgid}
|
||||||
alt="Card header"
|
src={imgsrc}
|
||||||
draggable="false"
|
{imgwidth}
|
||||||
class="select-none shadow"
|
{imgheight}
|
||||||
hidden={imghidden}
|
alt="Card header"
|
||||||
/>
|
draggable="false"
|
||||||
|
class="select-none shadow"
|
||||||
|
hidden={imghidden}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
<div class="p-2" {...restProps}>
|
||||||
|
{@render children()}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="p-2" {...restProps}>
|
|
||||||
{@render children()}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
@ -4,13 +4,26 @@
|
|||||||
import type { Action } from "svelte/action";
|
import type { Action } from "svelte/action";
|
||||||
import type { HTMLInputAttributes } from "svelte/elements";
|
import type { HTMLInputAttributes } from "svelte/elements";
|
||||||
import { v4 as uuid } from "uuid";
|
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;
|
label: string;
|
||||||
|
|
||||||
|
/** The value assigned to the dropdown value variable */
|
||||||
value: string;
|
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;
|
children: Snippet;
|
||||||
|
|
||||||
/** Placeholder for the empty input element */
|
/** Placeholder for the empty input element */
|
||||||
@ -37,7 +50,7 @@
|
|||||||
/** The options this autocomplete component allows to choose from.
|
/** The options this autocomplete component allows to choose from.
|
||||||
* Example: [[{ label: "Aston", value: "0" }, { label: "VCARB", value: "1" }]].
|
* Example: [[{ label: "Aston", value: "0" }, { label: "VCARB", value: "1" }]].
|
||||||
*/
|
*/
|
||||||
options: DropdownOption[];
|
options: LazyDropdownOption[];
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@ -56,7 +69,7 @@
|
|||||||
},
|
},
|
||||||
options,
|
options,
|
||||||
...restProps
|
...restProps
|
||||||
}: SearchProps = $props();
|
}: LazyDropdownProps = $props();
|
||||||
|
|
||||||
/** Find the "label" of an option by its "value" */
|
/** Find the "label" of an option by its "value" */
|
||||||
const get_label = (value: string): string | undefined => {
|
const get_label = (value: string): string | undefined => {
|
||||||
@ -78,6 +91,12 @@
|
|||||||
|
|
||||||
if (input) input.dispatchEvent(new CustomEvent("DropdownChange"));
|
if (input) input.dispatchEvent(new CustomEvent("DropdownChange"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let load: boolean = $state(false);
|
||||||
|
|
||||||
|
const lazy_click_handler = () => {
|
||||||
|
load = true;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="input-group input-group-divider grid-cols-[auto_1fr_auto]">
|
<div class="input-group input-group-divider grid-cols-[auto_1fr_auto]">
|
||||||
@ -87,6 +106,7 @@
|
|||||||
>
|
>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</div>
|
</div>
|
||||||
|
<!-- TODO: How to assign use: conditionally? I don't wan't to repeat the entire input... -->
|
||||||
{#if action}
|
{#if action}
|
||||||
<input
|
<input
|
||||||
use:popup={popup_settings}
|
use:popup={popup_settings}
|
||||||
@ -95,6 +115,7 @@
|
|||||||
style="height: 42px; text-align: start; text-indent: 12px; border-top-left-radius: 0; border-bottom-left-radius: 0;"
|
style="height: 42px; text-align: start; text-indent: 12px; border-top-left-radius: 0; border-bottom-left-radius: 0;"
|
||||||
use:obtain_input
|
use:obtain_input
|
||||||
use:action
|
use:action
|
||||||
|
onmousedown={lazy_click_handler}
|
||||||
onkeypress={(event: Event) => event.preventDefault()}
|
onkeypress={(event: Event) => event.preventDefault()}
|
||||||
value={get_label(input_variable) ?? placeholder}
|
value={get_label(input_variable) ?? placeholder}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
@ -106,6 +127,7 @@
|
|||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
style="height: 42px; text-align: start; text-indent: 12px; border-top-left-radius: 0; border-bottom-left-radius: 0;"
|
style="height: 42px; text-align: start; text-indent: 12px; border-top-left-radius: 0; border-bottom-left-radius: 0;"
|
||||||
use:obtain_input
|
use:obtain_input
|
||||||
|
onmousedown={lazy_click_handler}
|
||||||
onkeypress={(event: Event) => event.preventDefault()}
|
onkeypress={(event: Event) => event.preventDefault()}
|
||||||
value={get_label(input_variable) ?? placeholder}
|
value={get_label(input_variable) ?? placeholder}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
@ -118,21 +140,25 @@
|
|||||||
class="card z-10 w-auto overflow-y-scroll p-2 shadow"
|
class="card z-10 w-auto overflow-y-scroll p-2 shadow"
|
||||||
style="max-height: 350px;"
|
style="max-height: 350px;"
|
||||||
>
|
>
|
||||||
<ListBox>
|
{#if load}
|
||||||
{#each options as option}
|
<ListBox>
|
||||||
<ListBoxItem bind:group={input_variable} {name} value={option.value}>
|
{#each options as option}
|
||||||
<div class="flex flex-nowrap">
|
<ListBoxItem bind:group={input_variable} {name} value={option.value}>
|
||||||
{#if option.icon_url}
|
<div class="flex flex-nowrap">
|
||||||
<img
|
{#if option.icon_url}
|
||||||
src={option.icon_url}
|
<LazyImage
|
||||||
alt=""
|
src={option.icon_url}
|
||||||
class="mr-2 rounded"
|
alt=""
|
||||||
style="height: 24px; max-width: 64px;"
|
imgwidth={option.icon_width ?? 1}
|
||||||
/>
|
imgheight={option.icon_height ?? 1}
|
||||||
{/if}
|
class="mr-2 rounded"
|
||||||
{option.label}
|
style="height: 24px; max-width: 64px;"
|
||||||
</div>
|
/>
|
||||||
</ListBoxItem>
|
{/if}
|
||||||
{/each}
|
{option.label}
|
||||||
</ListBox>
|
</div>
|
||||||
|
</ListBoxItem>
|
||||||
|
{/each}
|
||||||
|
</ListBox>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@ -6,19 +6,30 @@
|
|||||||
interface LazyImageProps extends HTMLImgAttributes {
|
interface LazyImageProps extends HTMLImgAttributes {
|
||||||
/** The URL to the image resource to lazyload */
|
/** The URL to the image resource to lazyload */
|
||||||
src: string;
|
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 = () => {
|
const lazy_visible_handler = () => {
|
||||||
load = true;
|
load = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Once the image is visible, this will be set to true, triggering the loading
|
|
||||||
let load: boolean = $state(false);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div use:lazyload onLazyVisible={lazy_visible_handler}>
|
<!-- Show a correctly sized div so the layout doesn't jump. -->
|
||||||
|
<div
|
||||||
|
use:lazyload
|
||||||
|
onLazyVisible={lazy_visible_handler}
|
||||||
|
style="width: 100%; aspect-ratio: {imgwidth} / {imgheight};"
|
||||||
|
>
|
||||||
{#if load}
|
{#if load}
|
||||||
{#await fetch_image_base64(src) then data}
|
{#await fetch_image_base64(src) then data}
|
||||||
<img src={data} style="width: 100%" {...restProps} />
|
<img src={data} style="width: 100%" {...restProps} />
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { get_image_preview_event_handler } from "$lib/image";
|
import { get_image_preview_event_handler } from "$lib/image";
|
||||||
import { FileDropzone } from "@skeletonlabs/skeleton";
|
import { FileDropzone } from "@skeletonlabs/skeleton";
|
||||||
import Card from "./Card.svelte";
|
import LazyCard from "./LazyCard.svelte";
|
||||||
import Button from "./Button.svelte";
|
import Button from "./Button.svelte";
|
||||||
import type { Race } from "$lib/schema";
|
import type { Race } from "$lib/schema";
|
||||||
import Input from "./Input.svelte";
|
import Input from "./Input.svelte";
|
||||||
@ -55,7 +55,7 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card
|
<LazyCard
|
||||||
imgsrc={race?.pictogram_url ?? pictogram_template}
|
imgsrc={race?.pictogram_url ?? pictogram_template}
|
||||||
imgwidth={RACE_PICTOGRAM_WIDTH}
|
imgwidth={RACE_PICTOGRAM_WIDTH}
|
||||||
imgheight={RACE_PICTOGRAM_HEIGHT}
|
imgheight={RACE_PICTOGRAM_HEIGHT}
|
||||||
@ -175,4 +175,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</Card>
|
</LazyCard>
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Card from "./Card.svelte";
|
import LazyCard from "./LazyCard.svelte";
|
||||||
import Button from "./Button.svelte";
|
import Button from "./Button.svelte";
|
||||||
import type { Driver, Substitution } from "$lib/schema";
|
import type { Driver, Substitution } from "$lib/schema";
|
||||||
import { get_by_value } from "$lib/database";
|
import { get_by_value } from "$lib/database";
|
||||||
import Dropdown, { type DropdownOption } from "./Dropdown.svelte";
|
import LazyDropdown, { type DropdownOption } from "./LazyDropdown.svelte";
|
||||||
import type { Action } from "svelte/action";
|
import type { Action } from "svelte/action";
|
||||||
import { DRIVER_HEADSHOT_HEIGHT, DRIVER_HEADSHOT_WIDTH } from "$lib/config";
|
import { DRIVER_HEADSHOT_HEIGHT, DRIVER_HEADSHOT_WIDTH } from "$lib/config";
|
||||||
|
|
||||||
@ -76,7 +76,7 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card
|
<LazyCard
|
||||||
imgsrc={get_by_value(drivers, "id", substitution?.substitute ?? "")?.headshot_url ??
|
imgsrc={get_by_value(drivers, "id", substitution?.substitute ?? "")?.headshot_url ??
|
||||||
headshot_template}
|
headshot_template}
|
||||||
imgwidth={DRIVER_HEADSHOT_WIDTH}
|
imgwidth={DRIVER_HEADSHOT_WIDTH}
|
||||||
@ -92,35 +92,39 @@
|
|||||||
|
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<!-- Substitute select -->
|
<!-- Substitute select -->
|
||||||
<Dropdown
|
<LazyDropdown
|
||||||
name="substitute"
|
name="substitute"
|
||||||
input_variable={substitute_select_value}
|
input_variable={substitute_select_value}
|
||||||
action={register_substitute_preview_handler}
|
action={register_substitute_preview_handler}
|
||||||
options={driver_select_options}
|
options={driver_select_options}
|
||||||
labelwidth="120px"
|
labelwidth="120px"
|
||||||
disabled={disable_inputs}
|
disabled={disable_inputs}
|
||||||
required={require_inputs}>Substitute</Dropdown
|
required={require_inputs}
|
||||||
>
|
>
|
||||||
|
Substitute
|
||||||
|
</LazyDropdown>
|
||||||
|
|
||||||
<!-- Driver select -->
|
<!-- Driver select -->
|
||||||
<Dropdown
|
<LazyDropdown
|
||||||
name="for"
|
name="for"
|
||||||
input_variable={driver_select_value}
|
input_variable={driver_select_value}
|
||||||
options={driver_select_options}
|
options={driver_select_options}
|
||||||
labelwidth="120px"
|
labelwidth="120px"
|
||||||
disabled={disable_inputs}
|
disabled={disable_inputs}
|
||||||
required={require_inputs}>For</Dropdown
|
required={require_inputs}
|
||||||
>
|
>For
|
||||||
|
</LazyDropdown>
|
||||||
|
|
||||||
<!-- Race select -->
|
<!-- Race select -->
|
||||||
<Dropdown
|
<LazyDropdown
|
||||||
name="race"
|
name="race"
|
||||||
input_variable={race_select_value}
|
input_variable={race_select_value}
|
||||||
options={race_select_options}
|
options={race_select_options}
|
||||||
labelwidth="120px"
|
labelwidth="120px"
|
||||||
disabled={disable_inputs}
|
disabled={disable_inputs}
|
||||||
required={require_inputs}>Race</Dropdown
|
required={require_inputs}
|
||||||
>
|
>Race
|
||||||
|
</LazyDropdown>
|
||||||
|
|
||||||
<!-- Save/Delete buttons -->
|
<!-- Save/Delete buttons -->
|
||||||
<div class="flex justify-end gap-2">
|
<div class="flex justify-end gap-2">
|
||||||
@ -145,4 +149,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</Card>
|
</LazyCard>
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { get_image_preview_event_handler } from "$lib/image";
|
import { get_image_preview_event_handler } from "$lib/image";
|
||||||
import { FileDropzone } from "@skeletonlabs/skeleton";
|
import { FileDropzone } from "@skeletonlabs/skeleton";
|
||||||
import Card from "./Card.svelte";
|
|
||||||
import Button from "./Button.svelte";
|
import Button from "./Button.svelte";
|
||||||
import type { Team } from "$lib/schema";
|
import type { Team } from "$lib/schema";
|
||||||
import Input from "./Input.svelte";
|
import Input from "./Input.svelte";
|
||||||
import { TEAM_LOGO_HEIGHT, TEAM_LOGO_WIDTH } from "$lib/config";
|
import { TEAM_LOGO_HEIGHT, TEAM_LOGO_WIDTH } from "$lib/config";
|
||||||
|
import LazyCard from "./LazyCard.svelte";
|
||||||
|
|
||||||
interface TeamCardProps {
|
interface TeamCardProps {
|
||||||
/** The [Team] object used to prefill values. */
|
/** The [Team] object used to prefill values. */
|
||||||
@ -29,7 +29,7 @@
|
|||||||
}: TeamCardProps = $props();
|
}: TeamCardProps = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card
|
<LazyCard
|
||||||
imgsrc={team?.logo_url ?? logo_template}
|
imgsrc={team?.logo_url ?? logo_template}
|
||||||
imgwidth={TEAM_LOGO_WIDTH}
|
imgwidth={TEAM_LOGO_WIDTH}
|
||||||
imgheight={TEAM_LOGO_HEIGHT}
|
imgheight={TEAM_LOGO_HEIGHT}
|
||||||
@ -83,4 +83,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</Card>
|
</LazyCard>
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import Button from "./Button.svelte";
|
import Button from "./Button.svelte";
|
||||||
import Card from "./Card.svelte";
|
|
||||||
import DriverCard from "./DriverCard.svelte";
|
import DriverCard from "./DriverCard.svelte";
|
||||||
import Dropdown from "./Dropdown.svelte";
|
|
||||||
import Input from "./Input.svelte";
|
import Input from "./Input.svelte";
|
||||||
|
import LazyCard from "./LazyCard.svelte";
|
||||||
|
import LazyDropdown from "./LazyDropdown.svelte";
|
||||||
import LazyImage from "./LazyImage.svelte";
|
import LazyImage from "./LazyImage.svelte";
|
||||||
import LoadingIndicator from "./LoadingIndicator.svelte";
|
import LoadingIndicator from "./LoadingIndicator.svelte";
|
||||||
import RaceCard from "./RaceCard.svelte";
|
import RaceCard from "./RaceCard.svelte";
|
||||||
@ -17,10 +17,10 @@ import UserIcon from "./svg/UserIcon.svelte";
|
|||||||
export {
|
export {
|
||||||
// Components
|
// Components
|
||||||
Button,
|
Button,
|
||||||
Card,
|
|
||||||
DriverCard,
|
DriverCard,
|
||||||
Dropdown,
|
|
||||||
Input,
|
Input,
|
||||||
|
LazyCard,
|
||||||
|
LazyDropdown,
|
||||||
LazyImage,
|
LazyImage,
|
||||||
LoadingIndicator,
|
LoadingIndicator,
|
||||||
RaceCard,
|
RaceCard,
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { browser } from "$app/environment";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain an onchange event handler that updates an <Avatar> component
|
* Obtain an onchange event handler that updates an <Avatar> component
|
||||||
* with a new image uploaded via a file input element.
|
* with a new image uploaded via a file input element.
|
||||||
@ -46,8 +48,15 @@ export const get_image_preview_event_handler = (id: string): ((event: Event) =>
|
|||||||
return handler;
|
return handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Convert a binary [Blob] to base64 string */
|
/**
|
||||||
|
* Convert a binary [Blob] to base64 string.
|
||||||
|
* Can only be called clientside from a browser as it depends on FileReader!
|
||||||
|
*/
|
||||||
export const blob_to_base64 = (blob: Blob): Promise<string> => {
|
export const blob_to_base64 = (blob: Blob): Promise<string> => {
|
||||||
|
if (!browser) {
|
||||||
|
console.error("Can't call blob_to_base64 on server (FileReader is not available)!");
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, _) => {
|
return new Promise((resolve, _) => {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
|
|
||||||
@ -58,9 +67,19 @@ export const blob_to_base64 = (blob: Blob): Promise<string> => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Fetch an image from an URL using a fetch function [f] and return as base64 string */
|
/**
|
||||||
|
* Fetch an image from an URL using a fetch function [f] and return as base64 string .
|
||||||
|
* Can be called client- and server-side.
|
||||||
|
*/
|
||||||
export const fetch_image_base64 = async (url: string, f: Function = fetch): Promise<string> => {
|
export const fetch_image_base64 = async (url: string, f: Function = fetch): Promise<string> => {
|
||||||
return f(url)
|
if (browser) {
|
||||||
.then((response: Response) => response.blob())
|
return await f(url)
|
||||||
.then((blob: Blob) => blob_to_base64(blob));
|
.then((response: Response) => response.blob())
|
||||||
|
.then((blob: Blob) => blob_to_base64(blob));
|
||||||
|
}
|
||||||
|
|
||||||
|
// On the server
|
||||||
|
const response: Response = await f(url);
|
||||||
|
const buffer: Buffer = Buffer.from(await response.arrayBuffer());
|
||||||
|
return buffer.toString("base64");
|
||||||
};
|
};
|
||||||
|
|||||||
@ -33,12 +33,36 @@
|
|||||||
// Drawer config
|
// Drawer config
|
||||||
initializeStores();
|
initializeStores();
|
||||||
const drawerStore: DrawerStore = getDrawerStore();
|
const drawerStore: DrawerStore = getDrawerStore();
|
||||||
|
let drawerOpen: boolean = false;
|
||||||
|
let drawerId: string = "";
|
||||||
|
drawerStore.subscribe((settings: DrawerSettings) => {
|
||||||
|
drawerOpen = settings.open ?? false;
|
||||||
|
drawerId = settings.id ?? "";
|
||||||
|
});
|
||||||
|
|
||||||
|
const toggle_drawer = (settings: DrawerSettings) => {
|
||||||
|
if (drawerOpen) {
|
||||||
|
if (drawerId === settings.id) {
|
||||||
|
// We clicked the same button to close the drawer
|
||||||
|
drawerStore.close();
|
||||||
|
} else {
|
||||||
|
// We clicked another button to open another drawer
|
||||||
|
drawerStore.close();
|
||||||
|
setTimeout(() => drawerStore.open(settings), 200);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
drawerStore.open(settings);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const close_drawer = () => drawerStore.close();
|
||||||
|
|
||||||
const drawer_settings_base: DrawerSettings = {
|
const drawer_settings_base: DrawerSettings = {
|
||||||
position: "top",
|
position: "top",
|
||||||
height: "auto",
|
height: "auto",
|
||||||
padding: "lg:px-96",
|
padding: "lg:px-96 pt-14", // pt-14 is 56px, so its missing 4px for the 60px navbar...
|
||||||
bgDrawer: "bg-surface-100",
|
bgDrawer: "bg-surface-100",
|
||||||
|
duration: 150,
|
||||||
};
|
};
|
||||||
|
|
||||||
const menu_drawer = () => {
|
const menu_drawer = () => {
|
||||||
@ -46,7 +70,7 @@
|
|||||||
id: "menu_drawer",
|
id: "menu_drawer",
|
||||||
...drawer_settings_base,
|
...drawer_settings_base,
|
||||||
};
|
};
|
||||||
drawerStore.open(drawerSettings);
|
toggle_drawer(drawerSettings);
|
||||||
};
|
};
|
||||||
|
|
||||||
const data_drawer = () => {
|
const data_drawer = () => {
|
||||||
@ -54,7 +78,7 @@
|
|||||||
id: "data_drawer",
|
id: "data_drawer",
|
||||||
...drawer_settings_base,
|
...drawer_settings_base,
|
||||||
};
|
};
|
||||||
drawerStore.open(drawerSettings);
|
toggle_drawer(drawerSettings);
|
||||||
};
|
};
|
||||||
|
|
||||||
const login_drawer = () => {
|
const login_drawer = () => {
|
||||||
@ -62,7 +86,7 @@
|
|||||||
id: "login_drawer",
|
id: "login_drawer",
|
||||||
...drawer_settings_base,
|
...drawer_settings_base,
|
||||||
};
|
};
|
||||||
drawerStore.open(drawerSettings);
|
toggle_drawer(drawerSettings);
|
||||||
};
|
};
|
||||||
|
|
||||||
const profile_drawer = () => {
|
const profile_drawer = () => {
|
||||||
@ -70,11 +94,9 @@
|
|||||||
id: "profile_drawer",
|
id: "profile_drawer",
|
||||||
...drawer_settings_base,
|
...drawer_settings_base,
|
||||||
};
|
};
|
||||||
drawerStore.open(drawerSettings);
|
toggle_drawer(drawerSettings);
|
||||||
};
|
};
|
||||||
|
|
||||||
const close_drawer = () => drawerStore.close();
|
|
||||||
|
|
||||||
// Popups config
|
// Popups config
|
||||||
storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
|
storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
|
||||||
|
|
||||||
@ -93,11 +115,12 @@
|
|||||||
<LoadingIndicator />
|
<LoadingIndicator />
|
||||||
|
|
||||||
<Drawer>
|
<Drawer>
|
||||||
{#if $drawerStore.id === "menu_drawer"}
|
<!-- Use p-3 because the drawer has a 5px overlap with the navbar -->
|
||||||
<!-- Menu Drawer -->
|
<div class="flex flex-col gap-2 p-3">
|
||||||
<!-- Menu Drawer -->
|
{#if $drawerStore.id === "menu_drawer"}
|
||||||
<!-- Menu Drawer -->
|
<!-- Menu Drawer -->
|
||||||
<div class="flex flex-col gap-2 p-2">
|
<!-- Menu Drawer -->
|
||||||
|
<!-- Menu Drawer -->
|
||||||
<Button href="/racepicks" onclick={close_drawer} color="surface" fullwidth>Race Picks</Button>
|
<Button href="/racepicks" onclick={close_drawer} color="surface" fullwidth>Race Picks</Button>
|
||||||
<Button href="/seasonpicks" onclick={close_drawer} color="surface" fullwidth
|
<Button href="/seasonpicks" onclick={close_drawer} color="surface" fullwidth
|
||||||
>Season Picks
|
>Season Picks
|
||||||
@ -109,51 +132,46 @@
|
|||||||
>Statistics
|
>Statistics
|
||||||
</Button>
|
</Button>
|
||||||
<Button href="/rules" onclick={close_drawer} color="surface" fullwidth>Rules</Button>
|
<Button href="/rules" onclick={close_drawer} color="surface" fullwidth>Rules</Button>
|
||||||
</div>
|
{:else if $drawerStore.id === "data_drawer"}
|
||||||
{:else if $drawerStore.id === "data_drawer"}
|
<!-- Data Drawer -->
|
||||||
<!-- Data Drawer -->
|
<!-- Data Drawer -->
|
||||||
<!-- Data Drawer -->
|
<!-- Data Drawer -->
|
||||||
<!-- Data Drawer -->
|
<Button href="/data/raceresult" onclick={close_drawer} color="surface" fullwidth
|
||||||
<div class="flex flex-col gap-2 p-2">
|
>Race Results
|
||||||
<Button href="/data/raceresult" onclick={close_drawer} color="surface" fullwidth>
|
|
||||||
Race Results
|
|
||||||
</Button>
|
</Button>
|
||||||
<Button href="/data/season" onclick={close_drawer} color="surface" fullwidth>Season</Button>
|
<Button href="/data/season" onclick={close_drawer} color="surface" fullwidth>Season</Button>
|
||||||
<Button href="/data/user" onclick={close_drawer} color="surface" fullwidth>Users</Button>
|
<Button href="/data/user" onclick={close_drawer} color="surface" fullwidth>Users</Button>
|
||||||
</div>
|
{:else if $drawerStore.id === "login_drawer"}
|
||||||
{:else if $drawerStore.id === "login_drawer"}
|
<!-- Login Drawer -->
|
||||||
<!-- Login Drawer -->
|
<!-- Login Drawer -->
|
||||||
<!-- Login Drawer -->
|
<!-- Login Drawer -->
|
||||||
<!-- Login Drawer -->
|
|
||||||
<div class="flex flex-col gap-2 p-2">
|
|
||||||
<h4 class="h4 select-none">Enter Username and Password</h4>
|
<h4 class="h4 select-none">Enter Username and Password</h4>
|
||||||
<form method="POST" class="contents">
|
<form method="POST" class="contents">
|
||||||
<!-- Supply the pathname so the form can redirect to the current page. -->
|
<!-- Supply the pathname so the form can redirect to the current page. -->
|
||||||
<input type="hidden" name="redirect_url" value={$page.url.pathname} />
|
<input type="hidden" name="redirect_url" value={$page.url.pathname} />
|
||||||
<Input name="username" placeholder="Username" autocomplete="username" required>
|
<Input name="username" placeholder="Username" autocomplete="username" required
|
||||||
<UserIcon />
|
><UserIcon />
|
||||||
</Input>
|
</Input>
|
||||||
<Input name="password" type="password" placeholder="Password" autocomplete="off" required>
|
<Input name="password" type="password" placeholder="Password" autocomplete="off" required
|
||||||
<PasswordIcon />
|
><PasswordIcon />
|
||||||
</Input>
|
</Input>
|
||||||
<div class="flex justify-end gap-2">
|
<div class="flex justify-end gap-2">
|
||||||
<Button formaction="/profile?/login" onclick={close_drawer} color="tertiary" submit>
|
<Button formaction="/profile?/login" onclick={close_drawer} color="tertiary" submit
|
||||||
Login
|
>Login
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
formaction="/profile?/create_profile"
|
formaction="/profile?/create_profile"
|
||||||
onclick={close_drawer}
|
onclick={close_drawer}
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
submit>Register</Button
|
submit
|
||||||
>
|
>Register
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
{:else if $drawerStore.id === "profile_drawer" && data.user}
|
||||||
{:else if $drawerStore.id === "profile_drawer" && data.user}
|
<!-- Profile Drawer -->
|
||||||
<!-- Profile Drawer -->
|
<!-- Profile Drawer -->
|
||||||
<!-- Profile Drawer -->
|
<!-- Profile Drawer -->
|
||||||
<!-- Profile Drawer -->
|
|
||||||
<div class="flex flex-col gap-2 p-2">
|
|
||||||
<h4 class="h4 select-none">Edit Profile</h4>
|
<h4 class="h4 select-none">Edit Profile</h4>
|
||||||
<form method="POST" enctype="multipart/form-data" class="contents">
|
<form method="POST" enctype="multipart/form-data" class="contents">
|
||||||
<!-- Supply the pathname so the form can redirect to the current page. -->
|
<!-- Supply the pathname so the form can redirect to the current page. -->
|
||||||
@ -187,72 +205,74 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
{/if}
|
||||||
{/if}
|
</div>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<!-- TODO: Make this stick to the top somehow (fixed/sticky). -->
|
<div class="fixed left-0 right-0 top-0 z-50">
|
||||||
<AppBar
|
<AppBar
|
||||||
slotDefault="place-self-center"
|
slotDefault="place-self-center"
|
||||||
slotTrail="place-content-end"
|
slotTrail="place-content-end"
|
||||||
background="bg-primary-500"
|
background="bg-primary-500"
|
||||||
shadow="shadow"
|
shadow="shadow"
|
||||||
padding="p-2"
|
padding="p-2"
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="lead">
|
<svelte:fragment slot="lead">
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<!-- Navigation drawer -->
|
<!-- Navigation drawer -->
|
||||||
<div class="lg:hidden">
|
<div class="lg:hidden">
|
||||||
<Button color="primary" onclick={menu_drawer}>
|
<Button color="primary" onclick={menu_drawer}>
|
||||||
<MenuDrawerIcon />
|
<MenuDrawerIcon />
|
||||||
</Button>
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Site logo -->
|
||||||
|
<Button href="/" color="primary"><span class="text-xl font-bold">Formula 11</span></Button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
|
</svelte:fragment>
|
||||||
|
|
||||||
<!-- Site logo -->
|
<!-- Large navigation -->
|
||||||
<Button href="/" color="primary"><span class="text-xl font-bold">Formula 11</span></Button>
|
<div class="hidden gap-2 lg:flex">
|
||||||
|
<Button href="/racepicks" color="primary" activate_href>Race Picks</Button>
|
||||||
|
<Button href="/seasonpicks" color="primary" activate_href>Season Picks</Button>
|
||||||
|
<Button href="/leaderboard" color="primary" activate_href>Leaderboard</Button>
|
||||||
|
<Button href="/statistics" color="primary" activate_href>Statistics</Button>
|
||||||
|
<Button href="/rules" color="primary" activate_href>Rules</Button>
|
||||||
</div>
|
</div>
|
||||||
</svelte:fragment>
|
|
||||||
|
|
||||||
<!-- Large navigation -->
|
<svelte:fragment slot="trail">
|
||||||
<div class="hidden gap-2 lg:flex">
|
<div class="flex gap-2">
|
||||||
<Button href="/racepicks" color="primary" activate_href>Race Picks</Button>
|
<!-- Data drawer -->
|
||||||
<Button href="/seasonpicks" color="primary" activate_href>Season Picks</Button>
|
<Button
|
||||||
<Button href="/leaderboard" color="primary" activate_href>Leaderboard</Button>
|
color="primary"
|
||||||
<Button href="/statistics" color="primary" activate_href>Statistics</Button>
|
onclick={data_drawer}
|
||||||
<Button href="/rules" color="primary" activate_href>Rules</Button>
|
activate={$page.url.pathname.startsWith("/data")}>Data</Button
|
||||||
</div>
|
>
|
||||||
|
|
||||||
<svelte:fragment slot="trail">
|
{#if !data.user}
|
||||||
<div class="flex gap-2">
|
<!-- Login drawer -->
|
||||||
<!-- Data drawer -->
|
<Button color="primary" onclick={login_drawer}>Login</Button>
|
||||||
<Button
|
{:else}
|
||||||
color="primary"
|
<!-- Profile drawer -->
|
||||||
onclick={data_drawer}
|
<Avatar
|
||||||
activate={$page.url.pathname.startsWith("/data")}>Data</Button
|
id="user_avatar_preview"
|
||||||
>
|
src={data.user.avatar_url}
|
||||||
|
rounded="rounded-full"
|
||||||
{#if !data.user}
|
width="w-10"
|
||||||
<!-- Login drawer -->
|
background="bg-primary-50"
|
||||||
<Button color="primary" onclick={login_drawer}>Login</Button>
|
onclick={profile_drawer}
|
||||||
{:else}
|
cursor="cursor-pointer"
|
||||||
<!-- Profile drawer -->
|
/>
|
||||||
<Avatar
|
{/if}
|
||||||
id="user_avatar_preview"
|
</div>
|
||||||
src={data.user.avatar_url}
|
</svelte:fragment>
|
||||||
rounded="rounded-full"
|
</AppBar>
|
||||||
width="w-10"
|
</div>
|
||||||
background="bg-primary-50"
|
|
||||||
onclick={profile_drawer}
|
|
||||||
cursor="cursor-pointer"
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</svelte:fragment>
|
|
||||||
</AppBar>
|
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<!-- Each child's contents will be inserted here -->
|
<!-- Each child's contents will be inserted here -->
|
||||||
<div class="p-2">
|
<div class="p-2" style="margin-top: 60px;">
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -4,9 +4,17 @@
|
|||||||
import { Tab, TabGroup } from "@skeletonlabs/skeleton";
|
import { Tab, TabGroup } from "@skeletonlabs/skeleton";
|
||||||
|
|
||||||
// TODO: Why does this work but import { type DropdownOption } from "$lib/components" does not?
|
// TODO: Why does this work but import { type DropdownOption } from "$lib/components" does not?
|
||||||
import type { DropdownOption } from "$lib/components/Dropdown.svelte";
|
import type { LazyDropdownOption } from "$lib/components/LazyDropdown.svelte";
|
||||||
import { TeamCard, DriverCard, RaceCard, SubstitutionCard } from "$lib/components";
|
import { TeamCard, DriverCard, RaceCard, SubstitutionCard } from "$lib/components";
|
||||||
import { get_by_value } from "$lib/database";
|
import { get_by_value } from "$lib/database";
|
||||||
|
import {
|
||||||
|
DRIVER_HEADSHOT_HEIGHT,
|
||||||
|
DRIVER_HEADSHOT_WIDTH,
|
||||||
|
RACE_PICTOGRAM_HEIGHT,
|
||||||
|
RACE_PICTOGRAM_WIDTH,
|
||||||
|
TEAM_LOGO_HEIGHT,
|
||||||
|
TEAM_LOGO_WIDTH,
|
||||||
|
} from "$lib/config";
|
||||||
|
|
||||||
let { data, form }: { data: PageData; form: ActionData } = $props();
|
let { data, form }: { data: PageData; form: ActionData } = $props();
|
||||||
|
|
||||||
@ -44,28 +52,42 @@
|
|||||||
update_substitution_race_select_values["create"] = "";
|
update_substitution_race_select_values["create"] = "";
|
||||||
|
|
||||||
// All options to create a <Dropdown> component for the teams
|
// All options to create a <Dropdown> component for the teams
|
||||||
const team_dropdown_options: DropdownOption[] = [];
|
const team_dropdown_options: LazyDropdownOption[] = [];
|
||||||
data.teams.forEach((team: Team) => {
|
data.teams.forEach((team: Team) => {
|
||||||
team_dropdown_options.push({ label: team.name, value: team.id, icon_url: team.logo_url });
|
team_dropdown_options.push({
|
||||||
|
label: team.name,
|
||||||
|
value: team.id,
|
||||||
|
icon_url: team.logo_url,
|
||||||
|
icon_width: TEAM_LOGO_WIDTH,
|
||||||
|
icon_height: TEAM_LOGO_HEIGHT,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// All options to create a <Dropdown> component for the drivers
|
// All options to create a <Dropdown> component for the drivers
|
||||||
const driver_dropdown_options: DropdownOption[] = [];
|
const driver_dropdown_options: LazyDropdownOption[] = [];
|
||||||
data.drivers.then((drivers: Driver[]) =>
|
data.drivers.then((drivers: Driver[]) =>
|
||||||
drivers.forEach((driver: Driver) => {
|
drivers.forEach((driver: Driver) => {
|
||||||
driver_dropdown_options.push({
|
driver_dropdown_options.push({
|
||||||
label: driver.code,
|
label: driver.code,
|
||||||
value: driver.id,
|
value: driver.id,
|
||||||
icon_url: driver.headshot_url,
|
icon_url: driver.headshot_url,
|
||||||
|
icon_width: DRIVER_HEADSHOT_WIDTH,
|
||||||
|
icon_height: DRIVER_HEADSHOT_HEIGHT,
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
// All options to create a <Dropdown> component for the races
|
// All options to create a <Dropdown> component for the races
|
||||||
const race_dropdown_options: DropdownOption[] = [];
|
const race_dropdown_options: LazyDropdownOption[] = [];
|
||||||
data.races.then((races: Race[]) =>
|
data.races.then((races: Race[]) =>
|
||||||
races.forEach((race: Race) => {
|
races.forEach((race: Race) => {
|
||||||
race_dropdown_options.push({ label: race.name, value: race.id });
|
race_dropdown_options.push({
|
||||||
|
label: race.name,
|
||||||
|
value: race.id,
|
||||||
|
icon_url: race.pictogram_url,
|
||||||
|
icon_width: RACE_PICTOGRAM_WIDTH,
|
||||||
|
icon_height: RACE_PICTOGRAM_HEIGHT,
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user