Skip to content

Commit 9557041

Browse files
committed
Refactor about modal
1 parent af51138 commit 9557041

File tree

4 files changed

+76
-42
lines changed

4 files changed

+76
-42
lines changed

web/src/common/OverpassSelector.svelte

+3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@
105105
>Import current view</button
106106
>
107107
</div>
108+
109+
<i>or...</i>
110+
108111
<div>
109112
<button type="button" on:click={startPolygonTool}
110113
>Draw an area to import on the map</button

web/src/title/About.svelte

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<script lang="ts">
2+
import { Modal, notNull } from "../common";
3+
4+
export let showModal: boolean;
5+
</script>
6+
7+
{#if showModal}
8+
<Modal on:close={() => (showModal = false)} let:dialog>
9+
<h1>The Low-traffic neighbourhood (LTN) tool, v2</h1>
10+
<p>
11+
This is an <b>experimental</b> version of the
12+
<a
13+
href="https://a-b-street.github.io/docs/software/ltn/index.html"
14+
target="_blank">A/B Street LTN tool</a
15+
>. Most parts of it do not work yet, and you should probably use the other
16+
version of the tool instead.
17+
</p>
18+
<p>To use this tool, you need to:</p>
19+
<ol>
20+
<li>Choose your study area to analyze</li>
21+
<li>Define one or more neighbourhood boundaries</li>
22+
<li>
23+
Optionally, to fix the basemap data on existing modal filters, turn
24+
restrictions, one-ways, etc
25+
</li>
26+
<li>
27+
To create one or more proposals with new modal filters, and explore
28+
their effects
29+
</li>
30+
</ol>
31+
<p>
32+
This tool is created by <a
33+
href="https://github.com/dabreegster/"
34+
target="_blank">Dustin Carlino</a
35+
>
36+
and relies heavily on
37+
<a href="https://www.openstreetmap.org/about" target="_blank"
38+
>OpenStreetMap</a
39+
> data.
40+
</p>
41+
<center
42+
><button on:click={() => notNull(dialog).close()}>Start!</button></center
43+
>
44+
</Modal>
45+
{/if}

web/src/title/MapLoader.svelte

+8-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
function loadMap(buffer: ArrayBuffer) {
3535
msg = "Building map model from OSM input";
3636
console.time("load");
37-
$app = new LTN(new Uint8Array(buffer), $example == "" ? undefined : $example);
37+
$app = new LTN(
38+
new Uint8Array(buffer),
39+
$example == "" ? undefined : $example
40+
);
3841
console.timeEnd("load");
3942
4043
// Autoload from local storage
@@ -115,13 +118,17 @@
115118
</label>
116119
</div>
117120

121+
<i>or...</i>
122+
118123
<div>
119124
<label>
120125
Load an osm.xml or a .pbf file:
121126
<input bind:this={fileInput} on:change={loadFile} type="file" />
122127
</label>
123128
</div>
124129

130+
<i>or...</i>
131+
125132
<OverpassSelector
126133
map={$map}
127134
on:gotXml={gotXml}

web/src/title/TitleMode.svelte

+20-41
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,40 @@
11
<script lang="ts">
2-
import { Modal, notNull } from "../common";
32
import PolygonToolLayer from "../common/draw_polygon/PolygonToolLayer.svelte";
43
import SplitComponent from "../SplitComponent.svelte";
54
import { map } from "../stores";
5+
import About from "./About.svelte";
66
import MapLoader from "./MapLoader.svelte";
77
88
export let wasmReady: boolean;
99
1010
// TODO Once per session
1111
let showModal = true;
12+
13+
let fileInput: HTMLInputElement;
14+
async function loadFile(e: Event) {
15+
try {
16+
let gj = JSON.parse(await fileInput.files![0].text());
17+
// TODO set area, then load savefile
18+
} catch (err) {
19+
window.alert(`Couldn't open this file: ${err}`);
20+
}
21+
}
1222
</script>
1323

1424
<SplitComponent>
1525
<div slot="sidebar">
16-
{#if showModal}
17-
<Modal on:close={() => (showModal = false)} let:dialog>
18-
<h1>The Low-traffic neighbourhood (LTN) tool, v2</h1>
19-
<p>
20-
This is an <b>experimental</b> version of the
21-
<a
22-
href="https://a-b-street.github.io/docs/software/ltn/index.html"
23-
target="_blank">A/B Street LTN tool</a
24-
>. Most parts of it do not work yet, and you should probably use the
25-
other version of the tool instead.
26-
</p>
27-
<p>To use this tool, you need to:</p>
28-
<ol>
29-
<li>Choose your study area to analyze</li>
30-
<li>Define one or more neighbourhood boundaries</li>
31-
<li>
32-
Optionally, to fix the basemap data on existing modal filters, turn
33-
restrictions, one-ways, etc
34-
</li>
35-
<li>
36-
To create one or more proposals with new modal filters, and explore
37-
their effects
38-
</li>
39-
</ol>
40-
<p>
41-
This tool is created by <a
42-
href="https://github.com/dabreegster/"
43-
target="_blank">Dustin Carlino</a
44-
>
45-
and relies heavily on
46-
<a href="https://www.openstreetmap.org/about" target="_blank"
47-
>OpenStreetMap</a
48-
> data.
49-
</p>
50-
<center
51-
><button on:click={() => notNull(dialog).close()}>Start!</button
52-
></center
53-
>
54-
</Modal>
55-
{/if}
26+
<About bind:showModal />
5627

5728
<h1>Choose your study area</h1>
5829
<button on:click={() => (showModal = true)}>About the LTN tool</button>
30+
31+
<div>
32+
<label>
33+
Load a project from a file
34+
<input bind:this={fileInput} on:change={loadFile} type="file" />
35+
</label>
36+
</div>
37+
5938
<hr />
6039

6140
{#if $map && wasmReady}

0 commit comments

Comments
 (0)