Migrates to svelte 5
This commit is contained in:
@@ -1,73 +1,87 @@
|
||||
<script lang="ts">
|
||||
import Modal from "$lib/components/base/modal.svelte";
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { _ } from "svelte-i18n";
|
||||
import Select from "../base/select.svelte";
|
||||
|
||||
export let openModal: (() => void) | undefined = undefined;
|
||||
export let closeModal: (() => void) | undefined = undefined;
|
||||
export let title: string = $_("export");
|
||||
interface Props {
|
||||
title?: string;
|
||||
onexport?: (settings: typeof exportSettings) => void;
|
||||
}
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
let { title = $_("export"), onexport }: Props = $props();
|
||||
|
||||
let modal: Modal;
|
||||
|
||||
export function openModal() {
|
||||
modal.openModal();
|
||||
}
|
||||
|
||||
const fileFormats = [
|
||||
{ text: "GPX", value: "gpx" },
|
||||
{ text: "GeoJSON", value: "json" },
|
||||
];
|
||||
|
||||
const exportSettings = {
|
||||
const exportSettings: {
|
||||
fileFormat: "gpx" | "json";
|
||||
photos: boolean;
|
||||
summitLog: boolean;
|
||||
} = $state({
|
||||
fileFormat: "gpx",
|
||||
photos: false,
|
||||
summitLog: false,
|
||||
};
|
||||
});
|
||||
|
||||
function exportTrail() {
|
||||
dispatch("export", exportSettings);
|
||||
closeModal!();
|
||||
onexport?.(exportSettings);
|
||||
modal.closeModal();
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal id="export-modal" {title} size="max-w-sm" bind:openModal bind:closeModal>
|
||||
<div slot="content">
|
||||
<div class="mb-3">
|
||||
<Select
|
||||
bind:value={exportSettings.fileFormat}
|
||||
items={fileFormats}
|
||||
label={$_("file-format")}
|
||||
></Select>
|
||||
<Modal id="export-modal" {title} size="max-w-sm" bind:this={modal}>
|
||||
{#snippet content()}
|
||||
<div>
|
||||
<div class="mb-3">
|
||||
<Select
|
||||
bind:value={exportSettings.fileFormat}
|
||||
items={fileFormats}
|
||||
label={$_("file-format")}
|
||||
></Select>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<input
|
||||
id="include-photos-checkbox"
|
||||
type="checkbox"
|
||||
bind:checked={exportSettings.photos}
|
||||
class="w-4 h-4 bg-input-background accent-primary border-input-border focus:ring-input-ring focus:ring-2"
|
||||
/>
|
||||
<label for="include-photos-checkbox" class="ms-2 text-sm"
|
||||
>{$_("photos")}</label
|
||||
>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<input
|
||||
id="include-summit-log-checkbox"
|
||||
type="checkbox"
|
||||
bind:checked={exportSettings.summitLog}
|
||||
class="w-4 h-4 bg-input-background accent-primary border-input-border focus:ring-input-ring focus:ring-2"
|
||||
/>
|
||||
<label for="include-summit-log-checkbox" class="ms-2 text-sm"
|
||||
>{$_("summit-book")}</label
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<input
|
||||
id="include-photos-checkbox"
|
||||
type="checkbox"
|
||||
bind:checked={exportSettings.photos}
|
||||
class="w-4 h-4 bg-input-background accent-primary border-input-border focus:ring-input-ring focus:ring-2"
|
||||
/>
|
||||
<label for="include-photos-checkbox" class="ms-2 text-sm"
|
||||
>{$_("photos")}</label
|
||||
{/snippet}
|
||||
{#snippet footer()}
|
||||
<div class="flex items-center gap-4">
|
||||
<button class="btn-secondary" onclick={() => modal.closeModal()}
|
||||
>{$_("cancel")}</button
|
||||
>
|
||||
<button
|
||||
class="btn-primary"
|
||||
type="button"
|
||||
onclick={exportTrail}
|
||||
name="save">{$_("export")}</button
|
||||
>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<input
|
||||
id="include-summit-log-checkbox"
|
||||
type="checkbox"
|
||||
bind:checked={exportSettings.summitLog}
|
||||
class="w-4 h-4 bg-input-background accent-primary border-input-border focus:ring-input-ring focus:ring-2"
|
||||
/>
|
||||
<label for="include-summit-log-checkbox" class="ms-2 text-sm"
|
||||
>{$_("summit-book")}</label
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div slot="footer" class="flex items-center gap-4">
|
||||
<button class="btn-secondary" on:click={closeModal}
|
||||
>{$_("cancel")}</button
|
||||
>
|
||||
<button
|
||||
class="btn-primary"
|
||||
type="button"
|
||||
on:click={exportTrail}
|
||||
name="save">{$_("export")}</button
|
||||
>
|
||||
</div></Modal
|
||||
{/snippet}</Modal
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user