Skip to content

Commit

Permalink
Move the layer controls to the sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Mar 15, 2024
1 parent 69bb5fc commit a6b6889
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
12 changes: 0 additions & 12 deletions web/src/common/TopLeftPanel.svelte

This file was deleted.

1 change: 0 additions & 1 deletion web/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ export { default as Geocoder } from "./Geocoder.svelte";
export { default as Layout } from "./Layout.svelte";
export { default as Map } from "./Map.svelte";
export { default as ThemePicker } from "./ThemePicker.svelte";
export { default as TopLeftPanel } from "./TopLeftPanel.svelte";
export * from "./store";
36 changes: 26 additions & 10 deletions web/src/street-explorer/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
import init from "osm2streets-js";
import { onMount } from "svelte";
import AppSwitcher from "../AppSwitcher.svelte";
import {
ThemePicker,
BasemapPicker,
Geocoder,
Layout,
Map,
TopLeftPanel,
} from "../common";
import { ThemePicker, BasemapPicker, Geocoder, Layout, Map } from "../common";
import ImportControls from "../common/import/ImportControls.svelte";
import RenderBoundary from "../common/layers/RenderBoundary.svelte";
import RenderIntersectionMarkings from "../common/layers/RenderIntersectionMarkings.svelte";
Expand All @@ -27,6 +20,16 @@
onMount(async () => {
await init();
});
// Some of the layer contents need to be under the Map component for Svelte
// context to work, but the controls themselves should be in the
// sidebar. This trick moves the DOM node around.
let controlsContents: HTMLDivElement | null = null;
let controlsContainer: HTMLSpanElement;
$: if (controlsContents && controlsContainer) {
controlsContainer.innerHTML = "";
controlsContainer.appendChild(controlsContents);
}
</script>

<Layout>
Expand All @@ -40,13 +43,21 @@
>
and <a href="https://gitlab.com/LeLuxNet/Muv" target="_blank">Muv</a>.
</p>

<hr />

<ImportControls />

<br />

<details open>
<summary>Layers</summary>
<div bind:this={controlsContainer} />
</details>
</div>
<div slot="main">
<Map>
<TopLeftPanel>
<div bind:this={controlsContents}>
<RenderBoundary />
<RenderIntersectionPolygons>
<Popup openOn="click" popupClass="popup" let:data let:close>
Expand Down Expand Up @@ -75,7 +86,7 @@

<BasemapPicker />
<ThemePicker />
</TopLeftPanel>
</div>
<Geocoder />
</Map>
</div>
Expand All @@ -88,4 +99,9 @@
max-height: 50vh;
max-width: 30vw;
}
details {
border: 1px solid black;
padding: 4px;
}
</style>

0 comments on commit a6b6889

Please sign in to comment.