Files
gpx.studio/website/src/lib/components/toolbar/ToolbarItemMenu.svelte

58 lines
1.6 KiB
Svelte
Raw Normal View History

2024-04-22 19:36:31 +02:00
<script lang="ts">
2024-05-24 20:23:49 +02:00
import { Tool, currentTool } from '$lib/stores';
2024-04-22 19:36:31 +02:00
import { flyAndScale } from '$lib/utils';
import * as Card from '$lib/components/ui/card';
2024-05-24 20:23:49 +02:00
import Routing from '$lib/components/toolbar/tools/routing/Routing.svelte';
2024-06-06 11:44:53 +02:00
import Scissors from '$lib/components/toolbar/tools/Scissors.svelte';
import Waypoint from '$lib/components/toolbar/tools/Waypoint.svelte';
2024-06-08 17:19:22 +02:00
import Merge from '$lib/components/toolbar/tools/Merge.svelte';
2024-05-24 20:23:49 +02:00
import RoutingControlPopup from '$lib/components/toolbar/tools/routing/RoutingControlPopup.svelte';
import { onMount } from 'svelte';
import mapboxgl from 'mapbox-gl';
2024-05-24 20:23:49 +02:00
let popupElement: HTMLElement;
let popup: mapboxgl.Popup;
2024-05-24 20:23:49 +02:00
onMount(() => {
popup = new mapboxgl.Popup({
closeButton: false,
maxWidth: undefined
});
popup.setDOMContent(popupElement);
popupElement.classList.remove('hidden');
});
2024-04-22 19:36:31 +02:00
</script>
2024-05-24 20:23:49 +02:00
{#if $currentTool !== null}
<div
in:flyAndScale={{ x: -2, y: 0, duration: 100 }}
class="translate-x-1 h-full {$$props.class ?? ''}"
>
<div class="rounded-md shadow-md pointer-events-auto">
<Card.Root class="border-none">
2024-05-24 20:23:49 +02:00
<Card.Content class="p-3">
{#if $currentTool === Tool.ROUTING}
<Routing {popup} {popupElement} />
2024-06-06 11:44:53 +02:00
{:else if $currentTool === Tool.SCISSORS}
<Scissors />
2024-05-24 20:23:49 +02:00
{:else if $currentTool === Tool.WAYPOINT}
<Waypoint />
2024-06-08 17:19:22 +02:00
{:else if $currentTool === Tool.MERGE}
<Merge />
2024-05-24 20:23:49 +02:00
{/if}
</Card.Content>
</Card.Root>
</div>
2024-04-22 19:36:31 +02:00
</div>
{/if}
2024-05-07 17:19:53 +02:00
<svelte:window
on:keydown={(e) => {
2024-05-24 20:23:49 +02:00
if ($currentTool && e.key === 'Escape') {
2024-05-07 17:19:53 +02:00
currentTool.set(null);
}
}}
/>
2024-05-24 20:23:49 +02:00
<RoutingControlPopup bind:element={popupElement} />