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';
|
2024-04-28 18:59:31 +02:00
|
|
|
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-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-04-28 18:59:31 +02:00
|
|
|
|
2024-05-24 20:23:49 +02:00
|
|
|
let popupElement: HTMLElement;
|
|
|
|
let popup: mapboxgl.Popup;
|
2024-04-28 18:59:31 +02:00
|
|
|
|
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 ?? ''}"
|
|
|
|
>
|
2024-04-28 18:59:31 +02:00
|
|
|
<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}
|
|
|
|
<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-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}
|
2024-04-28 18:59:31 +02:00
|
|
|
</Card.Content>
|
|
|
|
</Card.Root>
|
|
|
|
</div>
|
2024-04-22 19:36:31 +02:00
|
|
|
</div>
|
2024-04-28 18:59:31 +02:00
|
|
|
{/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} />
|