Skip to content

Commit d348c79

Browse files
committed
Use help modal instead of inline text
1 parent b6821d1 commit d348c79

File tree

6 files changed

+64
-30
lines changed

6 files changed

+64
-30
lines changed

web/assets/help.svg

+1
Loading

web/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/src/NetworkMode.svelte

+18-16
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { downloadGeneratedFile, notNull } from "svelte-utils";
55
import type { Feature } from "geojson";
66
import { FillLayer, GeoJSON, hoverStateFilter } from "svelte-maplibre";
7-
import { layerId, Popup, Link } from "./common";
7+
import { layerId, Popup, Link, HelpButton } from "./common";
88
import ModalFilterLayer from "./ModalFilterLayer.svelte";
99
import { SplitComponent } from "svelte-utils/top_bar_layout";
1010
import { app, autosave, mode, projectName } from "./stores";
@@ -72,7 +72,22 @@
7272
Choose project
7373
</Link>
7474
</li>
75-
<li>Pick neighbourhood</li>
75+
<li>
76+
Pick neighbourhood
77+
<HelpButton>
78+
<p>
79+
Inside the neighbourhood you define, the goal is to eliminate (or
80+
deliberately permit) through-traffic. An appropriate neighbourhood
81+
boundary depends on many factors. The simplest approach is to find
82+
the area bounded on all sides by "main" roads, which are designed
83+
for higher traffic volumes. There are many other considerations,
84+
though -- maybe severances like rivers or rail should be part of a
85+
boundary. Bridges and tunnels near a boundary may be confusing as
86+
well. And note that your boundary may not match the conventional
87+
definition of "neighbourhood."
88+
</p>
89+
</HelpButton>
90+
</li>
7691
</ul>
7792
</nav>
7893
<nav>
@@ -87,21 +102,8 @@
87102
</ul>
88103
</nav>
89104
</div>
90-
<div slot="sidebar">
91-
<details>
92-
<summary>Help</summary>
93-
<p>
94-
Inside the neighbourhood you define, the goal is to eliminate (or
95-
deliberately permit) through-traffic. An appropriate neighbourhood
96-
boundary depends on many factors. The simplest approach is to find the
97-
area bounded on all sides by "main" roads, which are designed for higher
98-
traffic volumes. There are many other considerations, though -- maybe
99-
severances like rivers or rail should be part of a boundary. Bridges and
100-
tunnels near a boundary may be confusing as well. And note that your
101-
boundary may not match the conventional definition of "neighbourhood."
102-
</p>
103-
</details>
104105

106+
<div slot="sidebar">
105107
<div><Link on:click={newBoundary}>Draw a new boundary</Link></div>
106108
<div>
107109
<Link on:click={() => ($mode = { mode: "auto-boundaries" })}>

web/src/common/HelpButton.svelte

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<script lang="ts">
2+
// This launches a modal when clicked. The user should put the modal contents
3+
// as a slot beneath this component.
4+
import icon from "../../assets/help.svg?url";
5+
import { Modal } from "svelte-utils";
6+
7+
let show = false;
8+
</script>
9+
10+
<button on:click={() => (show = true)}>
11+
<img src={icon} title="Help" alt="Help" />
12+
</button>
13+
14+
{#if show}
15+
<Modal on:close={() => (show = false)}>
16+
<h2>Help</h2>
17+
<slot />
18+
</Modal>
19+
{/if}
20+
21+
<style>
22+
button {
23+
background: none;
24+
border: 1px solid rgba(0, 0, 0, 0);
25+
}
26+
27+
button:hover {
28+
border: 1px solid black;
29+
}
30+
</style>

web/src/common/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export { default as BasemapPicker } from "./BasemapPicker.svelte";
22
export { default as DisableInteractiveLayers } from "./DisableInteractiveLayers.svelte";
3+
export { default as HelpButton } from "./HelpButton.svelte";
34
export { default as Link } from "./Link.svelte";
45
export { default as Popup } from "./Popup.svelte";
56
export { default as StreetView } from "./StreetView.svelte";

web/src/edit/NeighbourhoodMode.svelte

+13-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import type { LngLat } from "maplibre-gl";
66
import { onDestroy } from "svelte";
77
import { type LayerClickInfo } from "svelte-maplibre";
8-
import { Popup, Link } from "../common";
8+
import { Popup, Link, HelpButton } from "../common";
99
import RenderNeighbourhood from "../RenderNeighbourhood.svelte";
1010
import { SplitComponent } from "svelte-utils/top_bar_layout";
1111
import {
@@ -141,7 +141,18 @@
141141
Pick neighbourhood
142142
</Link>
143143
</li>
144-
<li>Editing</li>
144+
<li>
145+
Editing
146+
<HelpButton>
147+
<p>
148+
Now that you've defined a neighbourhood boundary, you can see the
149+
possible shortcuts that vehicles are currently able to take
150+
through it. You can add a new modal filter to try and solve this.
151+
The colored "cell" areas show what's reachable for drivers without
152+
leaving the boundary you've drawn.
153+
</p>
154+
</HelpButton>
155+
</li>
145156
</ul>
146157
</nav>
147158
<nav>
@@ -183,17 +194,6 @@
183194
, with an area of {gjInput.area_km2.toFixed(1)} km²
184195
</p>
185196

186-
<details>
187-
<summary>Help</summary>
188-
<p>
189-
Now that you've defined a neighbourhood boundary, you can see the
190-
possible shortcuts that vehicles are currently able to take through it.
191-
You can add a new modal filter to try and solve this. The colored "cell"
192-
areas show what's reachable for drivers without leaving the boundary
193-
you've drawn.
194-
</p>
195-
</details>
196-
197197
{#if numDisconnectedCells > 0}
198198
<mark>
199199
Some parts of the neighbourhood aren't reachable by drivers, shown in

0 commit comments

Comments
 (0)