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

76 lines
2.4 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-07-05 16:08:16 +02:00
import { settings } from '$lib/db';
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-07-25 16:15:44 +02:00
import Scissors from '$lib/components/toolbar/tools/scissors/Scissors.svelte';
2024-06-06 11:44:53 +02:00
import Waypoint from '$lib/components/toolbar/tools/Waypoint.svelte';
2024-06-13 17:36:43 +02:00
import Time from '$lib/components/toolbar/tools/Time.svelte';
2024-06-08 17:19:22 +02:00
import Merge from '$lib/components/toolbar/tools/Merge.svelte';
2024-06-15 18:44:17 +02:00
import Extract from '$lib/components/toolbar/tools/Extract.svelte';
2024-07-19 13:18:38 +02:00
import Elevation from '$lib/components/toolbar/tools/Elevation.svelte';
2024-06-11 16:33:06 +02:00
import Clean from '$lib/components/toolbar/tools/Clean.svelte';
2024-06-11 19:08:46 +02:00
import Reduce from '$lib/components/toolbar/tools/Reduce.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-07-05 16:08:16 +02:00
const { minimizeRoutingMenu } = settings;
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">
2024-06-10 12:06:32 +02:00
<Card.Root class="rounded-md border-none">
<Card.Content class="p-2.5">
2024-05-24 20:23:49 +02:00
{#if $currentTool === Tool.ROUTING}
2024-07-05 16:08:16 +02:00
<Routing {popup} {popupElement} bind:minimized={$minimizeRoutingMenu} />
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-13 17:36:43 +02:00
{:else if $currentTool === Tool.TIME}
<Time />
2024-06-08 17:19:22 +02:00
{:else if $currentTool === Tool.MERGE}
<Merge />
2024-07-19 13:18:38 +02:00
{:else if $currentTool === Tool.ELEVATION}
<Elevation />
2024-06-15 18:44:17 +02:00
{:else if $currentTool === Tool.EXTRACT}
<Extract />
2024-06-11 16:33:06 +02:00
{:else if $currentTool === Tool.CLEAN}
<Clean />
2024-06-11 19:08:46 +02:00
{:else if $currentTool === Tool.REDUCE}
<Reduce />
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-06-11 22:04:49 +02:00
if ($currentTool !== null && 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} />