Files
gpx.studio/website/src/lib/components/gpx-layer/WaypointPopup.svelte

60 lines
2.0 KiB
Svelte
Raw Normal View History

<script lang="ts">
import * as Card from '$lib/components/ui/card';
2024-06-13 09:44:27 +02:00
import { Button } from '$lib/components/ui/button';
import Shortcut from '$lib/components/Shortcut.svelte';
import { waypointPopup, currentPopupWaypoint, deleteWaypoint } from './WaypointPopup';
2024-05-13 19:43:10 +02:00
import WithUnits from '$lib/components/WithUnits.svelte';
2024-06-13 09:44:27 +02:00
import { Dot, Trash2 } from 'lucide-svelte';
2024-05-13 19:43:10 +02:00
import { onMount } from 'svelte';
2024-06-13 09:44:27 +02:00
import { Tool, currentTool } from '$lib/stores';
import { _ } from 'svelte-i18n';
2024-05-13 19:43:10 +02:00
let popupElement: HTMLDivElement;
onMount(() => {
waypointPopup.setDOMContent(popupElement);
popupElement.classList.remove('hidden');
});
</script>
2024-05-13 19:43:10 +02:00
<div bind:this={popupElement} class="hidden">
2024-06-12 18:48:03 +02:00
{#if $currentPopupWaypoint}
2024-06-13 09:44:27 +02:00
<Card.Root class="border-none shadow-md text-base max-w-80 p-2">
2024-05-13 19:43:10 +02:00
<Card.Header class="p-0">
2024-06-13 09:44:27 +02:00
<Card.Title class="text-md">{$currentPopupWaypoint[0].name}</Card.Title>
2024-05-13 19:43:10 +02:00
</Card.Header>
<Card.Content class="flex flex-col p-0 text-sm">
<div class="flex flex-row items-center text-muted-foreground">
2024-06-13 09:44:27 +02:00
{$currentPopupWaypoint[0].getLatitude().toFixed(6)}&deg; {$currentPopupWaypoint[0]
2024-05-13 19:43:10 +02:00
.getLongitude()
.toFixed(6)}&deg;
2024-06-13 09:44:27 +02:00
{#if $currentPopupWaypoint[0].ele !== undefined}
2024-05-13 19:43:10 +02:00
<Dot size="16" />
2024-06-13 09:44:27 +02:00
<WithUnits value={$currentPopupWaypoint[0].ele} type="elevation" />
2024-05-13 19:43:10 +02:00
{/if}
</div>
2024-06-13 09:44:27 +02:00
{#if $currentPopupWaypoint[0].desc}
<span>{$currentPopupWaypoint[0].desc}</span>
{/if}
{#if $currentPopupWaypoint[0].cmt}
<span>{$currentPopupWaypoint[0].cmt}</span>
2024-05-13 19:43:10 +02:00
{/if}
2024-06-13 09:44:27 +02:00
{#if $currentTool === Tool.WAYPOINT}
<div class="mt-2">
<Button
class="w-full px-2 py-1 h-6 justify-start"
variant="ghost"
on:click={() =>
deleteWaypoint($currentPopupWaypoint[1], $currentPopupWaypoint[0]._data.index)}
>
<Trash2 size="16" class="mr-1" />
{$_('menu.delete')}
<Shortcut key="" shift={true} click={true} />
</Button>
</div>
2024-05-13 19:43:10 +02:00
{/if}
</Card.Content>
</Card.Root>
{/if}
</div>