2023-03-24 19:21:15 +01:00
|
|
|
<script lang="ts">
|
2023-03-28 05:13:48 +02:00
|
|
|
import { Store, UIEventSource } from "../Logic/UIEventSource";
|
2023-03-24 19:21:15 +01:00
|
|
|
import { Map as MlMap } from "maplibre-gl";
|
|
|
|
import MaplibreMap from "./Map/MaplibreMap.svelte";
|
|
|
|
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
|
|
|
|
import FeatureSwitchState from "../Logic/State/FeatureSwitchState";
|
|
|
|
import MapControlButton from "./Base/MapControlButton.svelte";
|
|
|
|
import ToSvelte from "./Base/ToSvelte.svelte";
|
|
|
|
import Svg from "../Svg";
|
|
|
|
import If from "./Base/If.svelte";
|
|
|
|
import { GeolocationControl } from "./BigComponents/GeolocationControl.js";
|
2023-03-25 02:48:24 +01:00
|
|
|
import type { Feature } from "geojson";
|
2023-03-28 05:13:48 +02:00
|
|
|
import SelectedElementView from "./BigComponents/SelectedElementView.svelte";
|
|
|
|
import LayerConfig from "../Models/ThemeConfig/LayerConfig";
|
|
|
|
import Filterview from "./BigComponents/Filterview.svelte";
|
|
|
|
import RasterLayerPicker from "./Map/RasterLayerPicker.svelte";
|
|
|
|
import ThemeViewState from "../Models/ThemeViewState";
|
|
|
|
import type { MapProperties } from "../Models/MapProperties";
|
|
|
|
import Geosearch from "./BigComponents/Geosearch.svelte";
|
|
|
|
import { Tab, TabGroup, TabList, TabPanel, TabPanels } from "@rgossiaux/svelte-headlessui";
|
|
|
|
import Translations from "./i18n/Translations";
|
|
|
|
import { MenuIcon } from "@rgossiaux/svelte-heroicons/solid";
|
2023-03-29 17:21:20 +02:00
|
|
|
import Tr from "./Base/Tr.svelte";
|
2023-03-26 05:58:28 +02:00
|
|
|
|
2023-03-24 19:21:15 +01:00
|
|
|
export let layout: LayoutConfig;
|
2023-03-28 05:13:48 +02:00
|
|
|
const state = new ThemeViewState(layout);
|
2023-03-24 19:21:15 +01:00
|
|
|
|
2023-03-28 05:13:48 +02:00
|
|
|
let selectedElementTags: Store<UIEventSource<Record<string, string>>> =
|
|
|
|
state.selectedElement.mapD((f) => {
|
|
|
|
return state.featureProperties.getStore(f.properties.id);
|
2023-03-25 02:48:24 +01:00
|
|
|
}
|
2023-03-28 05:13:48 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
let maplibremap: UIEventSource<MlMap> = state.map;
|
|
|
|
let selectedElement: UIEventSource<Feature> = state.selectedElement;
|
|
|
|
let selectedLayer: UIEventSource<LayerConfig> = state.selectedLayer;
|
|
|
|
let mapproperties: MapProperties = state.mapProperties;
|
|
|
|
let featureSwitches: FeatureSwitchState = state.featureSwitches;
|
|
|
|
let availableLayers = state.availableLayers;
|
2023-03-24 19:21:15 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
2023-03-26 05:58:28 +02:00
|
|
|
<div class="h-screen w-screen absolute top-0 left-0 flex">
|
2023-03-24 19:21:15 +01:00
|
|
|
<MaplibreMap class="w-full h-full border border-black" map={maplibremap}></MaplibreMap>
|
|
|
|
</div>
|
|
|
|
|
2023-03-28 05:13:48 +02:00
|
|
|
<div class="absolute top-0 left-0 mt-2 ml-2">
|
|
|
|
<MapControlButton on:click={() => state.guistate.welcomeMessageIsOpened.setData(true)}>
|
|
|
|
<div class="flex mr-2 items-center">
|
|
|
|
<img class="w-8 h-8 block mr-2" src={layout.icon}>
|
|
|
|
<b>
|
2023-03-29 17:21:20 +02:00
|
|
|
<Tr t={layout.title}></Tr>
|
2023-03-28 05:13:48 +02:00
|
|
|
</b>
|
|
|
|
</div>
|
|
|
|
</MapControlButton>
|
|
|
|
<MapControlButton on:click={() =>state.guistate.menuIsOpened.setData(true)}>
|
|
|
|
<MenuIcon class="w-8 h-8"></MenuIcon>
|
|
|
|
</MapControlButton>
|
2023-03-24 19:21:15 +01:00
|
|
|
</div>
|
|
|
|
|
2023-03-28 05:13:48 +02:00
|
|
|
<div class="absolute bottom-0 left-0 mb-4 ml-4">
|
2023-03-29 17:21:20 +02:00
|
|
|
|
2023-03-24 19:21:15 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="absolute bottom-0 right-0 mb-4 mr-4">
|
2023-03-25 02:48:24 +01:00
|
|
|
<MapControlButton on:click={() => mapproperties.zoom.update(z => z+1)}>
|
|
|
|
<ToSvelte class="w-7 h-7 block" construct={Svg.plus_ui}></ToSvelte>
|
|
|
|
</MapControlButton>
|
|
|
|
<MapControlButton on:click={() => mapproperties.zoom.update(z => z-1)}>
|
|
|
|
<ToSvelte class="w-7 h-7 block" construct={Svg.min_ui}></ToSvelte>
|
|
|
|
</MapControlButton>
|
2023-03-24 19:21:15 +01:00
|
|
|
<If condition={featureSwitches.featureSwitchGeolocation}>
|
|
|
|
<MapControlButton>
|
2023-03-28 05:13:48 +02:00
|
|
|
<ToSvelte
|
|
|
|
construct={new GeolocationControl(state.geolocation, mapproperties).SetClass("block w-8 h-8")}></ToSvelte>
|
2023-03-24 19:21:15 +01:00
|
|
|
</MapControlButton>
|
|
|
|
</If>
|
|
|
|
</div>
|
|
|
|
|
2023-03-28 05:13:48 +02:00
|
|
|
<div class="absolute top-0 right-0 mt-4 mr-4">
|
|
|
|
<If condition={state.featureSwitches.featureSwitchSearch}>
|
|
|
|
<Geosearch bounds={state.mapProperties.bounds} layout={state.layout} location={state.mapProperties.location}
|
|
|
|
{selectedElement} {selectedLayer}
|
|
|
|
zoom={state.mapProperties.zoom}></Geosearch>
|
|
|
|
</If>
|
2023-03-24 19:21:15 +01:00
|
|
|
</div>
|
|
|
|
|
2023-03-28 05:13:48 +02:00
|
|
|
|
|
|
|
<If condition={state.guistate.welcomeMessageIsOpened}>
|
|
|
|
<!-- Theme page -->
|
|
|
|
<div class="absolute top-0 left-0 w-screen h-screen" style="background-color: #00000088">
|
|
|
|
<div class="flex flex-col m-4 sm:m-6 md:m-8 p-4 sm:p-6 md:m-8 normal-background rounded">
|
|
|
|
<div on:click={() => state.guistate.welcomeMessageIsOpened.setData(false)}>Close</div>
|
|
|
|
<TabGroup>
|
|
|
|
<TabList>
|
2023-03-29 17:21:20 +02:00
|
|
|
<Tab class={({selected}) => selected ? "tab-selected" : "tab-unselected"}>
|
|
|
|
<Tr t={layout.title}/>
|
|
|
|
</Tab>
|
|
|
|
<Tab class={({selected}) => selected ? "tab-selected" : "tab-unselected"}>
|
|
|
|
<Tr t={Translations.t.general.menu.filter}/>
|
|
|
|
</Tab>
|
2023-03-28 05:13:48 +02:00
|
|
|
<Tab class={({selected}) => selected ? "tab-selected" : "tab-unselected"}>Tab 3</Tab>
|
|
|
|
</TabList>
|
|
|
|
<TabPanels>
|
|
|
|
<TabPanel class="flex flex-col">
|
2023-03-29 17:21:20 +02:00
|
|
|
<Tr t={layout.description}></Tr>
|
|
|
|
<Tr t={Translations.t.general.welcomeExplanation.general}/>
|
2023-03-28 05:13:48 +02:00
|
|
|
{#if layout.layers.some((l) => l.presets?.length > 0)}
|
|
|
|
<If condition={state.featureSwitches.featureSwitchAddNew}>
|
2023-03-29 17:21:20 +02:00
|
|
|
<Tr t={Translations.t.general.welcomeExplanation.addNew}/>
|
2023-03-28 05:13:48 +02:00
|
|
|
</If>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<!--toTheMap,
|
|
|
|
loginStatus.SetClass("block mt-6 pt-2 md:border-t-2 border-dotted border-gray-400"),
|
|
|
|
-->
|
2023-03-29 17:21:20 +02:00
|
|
|
<Tr t={layout.descriptionTail}></Tr>
|
2023-03-28 05:13:48 +02:00
|
|
|
<div class="m-x-8">
|
2023-03-29 17:21:20 +02:00
|
|
|
<button class="subtle-background rounded w-full p-4"
|
|
|
|
on:click={() => state.guistate.welcomeMessageIsOpened.setData(false)}>
|
|
|
|
<Tr t={Translations.t.general.openTheMap} />
|
|
|
|
</button>
|
2023-03-28 05:13:48 +02:00
|
|
|
</div>
|
|
|
|
|
2023-03-29 17:21:20 +02:00
|
|
|
|
|
|
|
</TabPanel>
|
|
|
|
<TabPanel>
|
|
|
|
<div class="flex flex-col">
|
|
|
|
<!-- Filter panel -- TODO move to actual location-->
|
|
|
|
{#each layout.layers as layer}
|
|
|
|
<Filterview filteredLayer={state.layerState.filteredLayers.get(layer.id)}></Filterview>
|
|
|
|
{/each}
|
|
|
|
|
|
|
|
<RasterLayerPicker {availableLayers} value={mapproperties.rasterLayer}></RasterLayerPicker>
|
|
|
|
</div>
|
2023-03-28 05:13:48 +02:00
|
|
|
</TabPanel>
|
|
|
|
<TabPanel>Content 3</TabPanel>
|
|
|
|
</TabPanels>
|
|
|
|
</TabGroup>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</If>
|
|
|
|
|
|
|
|
|
|
|
|
<If condition={state.guistate.menuIsOpened}>
|
|
|
|
<!-- Menu page -->
|
|
|
|
<div class="absolute top-0 left-0 w-screen h-screen" style="background-color: #00000088">
|
|
|
|
<div class="flex flex-col m-4 sm:m-6 md:m-8 p-4 sm:p-6 md:m-8 normal-background rounded">
|
|
|
|
<div on:click={() => state.guistate.menuIsOpened.setData(false)}>Close</div>
|
|
|
|
<TabGroup>
|
|
|
|
<TabList>
|
|
|
|
<Tab class={({selected}) => selected ? "tab-selected" : "tab-unselected"}>About MapComplete</Tab>
|
|
|
|
<Tab class={({selected}) => selected ? "tab-selected" : "tab-unselected"}>Settings</Tab>
|
|
|
|
<Tab class={({selected}) => selected ? "tab-selected" : "tab-unselected"}>Privacy</Tab>
|
|
|
|
</TabList>
|
|
|
|
<TabPanels>
|
|
|
|
<TabPanel class="flex flex-col">
|
|
|
|
About MC
|
|
|
|
|
|
|
|
|
|
|
|
</TabPanel>
|
|
|
|
<TabPanel>User settings</TabPanel>
|
|
|
|
<TabPanel>Privacy</TabPanel>
|
|
|
|
</TabPanels>
|
|
|
|
</TabGroup>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</If>
|
|
|
|
|
2023-03-29 17:21:20 +02:00
|
|
|
{#if $selectedElement !== undefined && $selectedLayer !== undefined}
|
2023-03-28 05:13:48 +02:00
|
|
|
<div class="absolute top-0 right-0 normal-background">
|
|
|
|
|
2023-03-29 17:21:20 +02:00
|
|
|
<SelectedElementView layer={$selectedLayer} selectedElement={$selectedElement}
|
|
|
|
tags={$selectedElementTags} state={state}></SelectedElementView>
|
2023-03-28 05:13:48 +02:00
|
|
|
|
|
|
|
</div>
|
2023-03-29 17:21:20 +02:00
|
|
|
{/if}
|
2023-03-28 05:13:48 +02:00
|
|
|
<style>
|
|
|
|
/* WARNING: This is just for demonstration.
|
|
|
|
Using :global() in this way can be risky. */
|
|
|
|
:global(.tab-selected) {
|
|
|
|
background-color: rgb(59 130 246);
|
|
|
|
color: rgb(255 255 255);
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(.tab-unselected) {
|
|
|
|
background-color: rgb(255 255 255);
|
|
|
|
color: rgb(0 0 0);
|
|
|
|
}
|
|
|
|
</style>
|