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

44 lines
1.3 KiB
Svelte
Raw Normal View History

<script lang="ts">
import * as Card from '$lib/components/ui/card';
2024-06-12 18:48:03 +02:00
import { waypointPopup, currentPopupWaypoint } from './WaypointPopup';
2024-05-13 19:43:10 +02:00
import WithUnits from '$lib/components/WithUnits.svelte';
import { Dot } from 'lucide-svelte';
import { onMount } from 'svelte';
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-05-13 19:43:10 +02:00
<Card.Root class="border-none shadow-md text-base max-w-72 p-2">
<Card.Header class="p-0">
2024-06-12 18:48:03 +02:00
<Card.Title class="text-md">{$currentPopupWaypoint.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-12 18:48:03 +02:00
{$currentPopupWaypoint.getLatitude().toFixed(6)}&deg; {$currentPopupWaypoint
2024-05-13 19:43:10 +02:00
.getLongitude()
.toFixed(6)}&deg;
2024-06-12 18:48:03 +02:00
{#if $currentPopupWaypoint.ele !== undefined}
2024-05-13 19:43:10 +02:00
<Dot size="16" />
2024-06-12 18:48:03 +02:00
<WithUnits value={$currentPopupWaypoint.ele} type="elevation" />
2024-05-13 19:43:10 +02:00
{/if}
</div>
2024-06-12 18:48:03 +02:00
{#if $currentPopupWaypoint.desc}
<span>{$currentPopupWaypoint.desc}</span>
2024-05-13 19:43:10 +02:00
{/if}
2024-06-12 18:48:03 +02:00
{#if $currentPopupWaypoint.cmt}
<span>{$currentPopupWaypoint.cmt}</span>
2024-05-13 19:43:10 +02:00
{/if}
</Card.Content>
</Card.Root>
{/if}
</div>