2024-04-22 19:36:31 +02:00
|
|
|
<script lang="ts">
|
2025-10-18 16:10:08 +02:00
|
|
|
import { Tool, currentTool } from '$lib/components/toolbar/tools';
|
2025-02-02 11:17:22 +01:00
|
|
|
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';
|
2025-10-05 19:34:05 +02:00
|
|
|
import Waypoint from '$lib/components/toolbar/tools/waypoint/Waypoint.svelte';
|
2025-10-18 19:21:10 +02:00
|
|
|
import Time from '$lib/components/toolbar/tools/Time.svelte';
|
2025-02-02 11:17:22 +01:00
|
|
|
import Merge from '$lib/components/toolbar/tools/Merge.svelte';
|
|
|
|
|
import Elevation from '$lib/components/toolbar/tools/Elevation.svelte';
|
2025-10-18 16:10:08 +02:00
|
|
|
import Extract from '$lib/components/toolbar/tools/Extract.svelte';
|
2025-02-02 11:17:22 +01:00
|
|
|
import Clean from '$lib/components/toolbar/tools/Clean.svelte';
|
2025-10-18 16:10:08 +02:00
|
|
|
import Reduce from '$lib/components/toolbar/tools/reduce/Reduce.svelte';
|
2025-02-02 11:17:22 +01:00
|
|
|
import RoutingControlPopup from '$lib/components/toolbar/tools/routing/RoutingControlPopup.svelte';
|
|
|
|
|
import mapboxgl from 'mapbox-gl';
|
2025-10-17 23:54:45 +02:00
|
|
|
import { settings } from '$lib/logic/settings';
|
2024-04-28 18:59:31 +02:00
|
|
|
|
2025-10-05 19:34:05 +02:00
|
|
|
let {
|
|
|
|
|
class: className = '',
|
|
|
|
|
}: {
|
|
|
|
|
class: string;
|
|
|
|
|
} = $props();
|
2024-07-05 16:08:16 +02:00
|
|
|
|
2025-10-05 19:34:05 +02:00
|
|
|
const { minimizeRoutingMenu } = settings;
|
2024-04-28 18:59:31 +02:00
|
|
|
|
2025-10-18 16:10:08 +02:00
|
|
|
let popupElement: HTMLDivElement | undefined = $state(undefined);
|
|
|
|
|
let popup: mapboxgl.Popup | undefined = $derived.by(() => {
|
|
|
|
|
if (!popupElement) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
let popup = new mapboxgl.Popup({
|
2025-02-02 11:17:22 +01:00
|
|
|
closeButton: false,
|
|
|
|
|
maxWidth: undefined,
|
|
|
|
|
});
|
|
|
|
|
popup.setDOMContent(popupElement);
|
|
|
|
|
popupElement.classList.remove('hidden');
|
2025-10-18 16:10:08 +02:00
|
|
|
return popup;
|
2025-02-02 11:17:22 +01:00
|
|
|
});
|
2024-04-22 19:36:31 +02:00
|
|
|
</script>
|
|
|
|
|
|
2025-10-18 16:10:08 +02:00
|
|
|
{#if $currentTool !== null}
|
2025-11-10 11:11:37 +01:00
|
|
|
<div
|
|
|
|
|
class="translate-x-1 h-full animate-in fade-in-0 zoom-in-95 slide-in-from-left-2 {className}"
|
|
|
|
|
>
|
2025-02-02 11:17:22 +01:00
|
|
|
<div class="rounded-md shadow-md pointer-events-auto">
|
2025-10-18 18:51:11 +02:00
|
|
|
<Card.Root class="rounded-md border-none py-2.5">
|
|
|
|
|
<Card.Content class="px-2.5">
|
2025-10-18 16:10:08 +02:00
|
|
|
{#if $currentTool === Tool.ROUTING}
|
|
|
|
|
<Routing {popup} {popupElement} bind:minimized={$minimizeRoutingMenu} />
|
|
|
|
|
{:else if $currentTool === Tool.SCISSORS}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Scissors />
|
2025-10-18 16:10:08 +02:00
|
|
|
{:else if $currentTool === Tool.WAYPOINT}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Waypoint />
|
2025-10-18 19:21:10 +02:00
|
|
|
{:else if $currentTool === Tool.TIME}
|
|
|
|
|
<Time />
|
2025-10-18 16:10:08 +02:00
|
|
|
{:else if $currentTool === Tool.MERGE}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Merge />
|
2025-10-18 16:10:08 +02:00
|
|
|
{:else if $currentTool === Tool.ELEVATION}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Elevation />
|
2025-10-18 16:10:08 +02:00
|
|
|
{:else if $currentTool === Tool.EXTRACT}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Extract />
|
2025-10-18 16:10:08 +02:00
|
|
|
{:else if $currentTool === Tool.CLEAN}
|
2025-02-02 11:17:22 +01:00
|
|
|
<Clean />
|
2025-10-18 16:10:08 +02:00
|
|
|
{:else if $currentTool === 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-10-18 16:10:08 +02:00
|
|
|
if ($currentTool !== null && e.key === 'Escape') {
|
|
|
|
|
$currentTool = 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} />
|