2024-04-22 19:36:31 +02:00
|
|
|
<script lang="ts">
|
2025-06-21 21:07:36 +02:00
|
|
|
import { Tool, tool } from '$lib/components/toolbar/utils.svelte';
|
2025-02-02 11:17:22 +01:00
|
|
|
import { settings } from '$lib/db';
|
|
|
|
import * as Card from '$lib/components/ui/card';
|
|
|
|
import Routing from '$lib/components/toolbar/tools/routing/Routing.svelte';
|
|
|
|
import Scissors from '$lib/components/toolbar/tools/scissors/Scissors.svelte';
|
|
|
|
import Waypoint from '$lib/components/toolbar/tools/Waypoint.svelte';
|
|
|
|
import Time from '$lib/components/toolbar/tools/Time.svelte';
|
|
|
|
import Merge from '$lib/components/toolbar/tools/Merge.svelte';
|
|
|
|
import Extract from '$lib/components/toolbar/tools/Extract.svelte';
|
|
|
|
import Elevation from '$lib/components/toolbar/tools/Elevation.svelte';
|
|
|
|
import Clean from '$lib/components/toolbar/tools/Clean.svelte';
|
|
|
|
import Reduce from '$lib/components/toolbar/tools/Reduce.svelte';
|
|
|
|
import RoutingControlPopup from '$lib/components/toolbar/tools/routing/RoutingControlPopup.svelte';
|
|
|
|
import { onMount } from 'svelte';
|
|
|
|
import mapboxgl from 'mapbox-gl';
|
2024-04-28 18:59:31 +02:00
|
|
|
|
2025-02-02 11:17:22 +01:00
|
|
|
const { minimizeRoutingMenu } = settings;
|
2024-07-05 16:08:16 +02:00
|
|
|
|
2025-02-02 11:17:22 +01:00
|
|
|
let popupElement: HTMLElement;
|
|
|
|
let popup: mapboxgl.Popup;
|
2024-04-28 18:59:31 +02:00
|
|
|
|
2025-02-02 11:17:22 +01: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>
|
|
|
|
|
2025-06-21 21:07:36 +02:00
|
|
|
{#if tool.current !== null}
|
|
|
|
<div class="translate-x-1 h-full animate-in animate-out {$$props.class ?? ''}">
|
2025-02-02 11:17:22 +01:00
|
|
|
<div class="rounded-md shadow-md pointer-events-auto">
|
|
|
|
<Card.Root class="rounded-md border-none">
|
|
|
|
<Card.Content class="p-2.5">
|
2025-06-21 21:07:36 +02:00
|
|
|
{#if tool.current === Tool.ROUTING}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Routing {popup} {popupElement} bind:minimized={$minimizeRoutingMenu} />
|
2025-06-21 21:07:36 +02:00
|
|
|
{:else if tool.current === Tool.SCISSORS}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Scissors />
|
2025-06-21 21:07:36 +02:00
|
|
|
{:else if tool.current === Tool.WAYPOINT}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Waypoint />
|
2025-06-21 21:07:36 +02:00
|
|
|
{:else if tool.current === Tool.TIME}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Time />
|
2025-06-21 21:07:36 +02:00
|
|
|
{:else if tool.current === Tool.MERGE}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Merge />
|
2025-06-21 21:07:36 +02:00
|
|
|
{:else if tool.current === Tool.ELEVATION}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Elevation />
|
2025-06-21 21:07:36 +02:00
|
|
|
{:else if tool.current === Tool.EXTRACT}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Extract />
|
2025-06-21 21:07:36 +02:00
|
|
|
{:else if tool.current === Tool.CLEAN}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Clean />
|
2025-06-21 21:07:36 +02:00
|
|
|
{:else if tool.current === Tool.REDUCE}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Reduce />
|
|
|
|
{/if}
|
|
|
|
</Card.Content>
|
|
|
|
</Card.Root>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-28 18:59:31 +02:00
|
|
|
{/if}
|
2024-05-07 17:19:53 +02:00
|
|
|
|
|
|
|
<svelte:window
|
2025-02-02 11:17:22 +01:00
|
|
|
on:keydown={(e) => {
|
2025-06-21 21:07:36 +02:00
|
|
|
if (tool.current !== null && e.key === 'Escape') {
|
|
|
|
tool.current = null;
|
2025-02-02 11:17:22 +01:00
|
|
|
}
|
|
|
|
}}
|
2024-05-07 17:19:53 +02:00
|
|
|
/>
|
2024-05-24 20:23:49 +02:00
|
|
|
|
|
|
|
<RoutingControlPopup bind:element={popupElement} />
|