Skip to content

Commit

Permalink
Use help modal instead of inline text
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Dec 8, 2024
1 parent b6821d1 commit d348c79
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 30 deletions.
1 change: 1 addition & 0 deletions web/assets/help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 18 additions & 16 deletions web/src/NetworkMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { downloadGeneratedFile, notNull } from "svelte-utils";
import type { Feature } from "geojson";
import { FillLayer, GeoJSON, hoverStateFilter } from "svelte-maplibre";
import { layerId, Popup, Link } from "./common";
import { layerId, Popup, Link, HelpButton } from "./common";
import ModalFilterLayer from "./ModalFilterLayer.svelte";
import { SplitComponent } from "svelte-utils/top_bar_layout";
import { app, autosave, mode, projectName } from "./stores";
Expand Down Expand Up @@ -72,7 +72,22 @@
Choose project
</Link>
</li>
<li>Pick neighbourhood</li>
<li>
Pick neighbourhood
<HelpButton>
<p>
Inside the neighbourhood you define, the goal is to eliminate (or
deliberately permit) through-traffic. An appropriate neighbourhood
boundary depends on many factors. The simplest approach is to find
the area bounded on all sides by "main" roads, which are designed
for higher traffic volumes. There are many other considerations,
though -- maybe severances like rivers or rail should be part of a
boundary. Bridges and tunnels near a boundary may be confusing as
well. And note that your boundary may not match the conventional
definition of "neighbourhood."
</p>
</HelpButton>
</li>
</ul>
</nav>
<nav>
Expand All @@ -87,21 +102,8 @@
</ul>
</nav>
</div>
<div slot="sidebar">
<details>
<summary>Help</summary>
<p>
Inside the neighbourhood you define, the goal is to eliminate (or
deliberately permit) through-traffic. An appropriate neighbourhood
boundary depends on many factors. The simplest approach is to find the
area bounded on all sides by "main" roads, which are designed for higher
traffic volumes. There are many other considerations, though -- maybe
severances like rivers or rail should be part of a boundary. Bridges and
tunnels near a boundary may be confusing as well. And note that your
boundary may not match the conventional definition of "neighbourhood."
</p>
</details>

<div slot="sidebar">
<div><Link on:click={newBoundary}>Draw a new boundary</Link></div>
<div>
<Link on:click={() => ($mode = { mode: "auto-boundaries" })}>
Expand Down
30 changes: 30 additions & 0 deletions web/src/common/HelpButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script lang="ts">
// This launches a modal when clicked. The user should put the modal contents
// as a slot beneath this component.
import icon from "../../assets/help.svg?url";
import { Modal } from "svelte-utils";
let show = false;
</script>

<button on:click={() => (show = true)}>
<img src={icon} title="Help" alt="Help" />
</button>

{#if show}
<Modal on:close={() => (show = false)}>
<h2>Help</h2>
<slot />
</Modal>
{/if}

<style>
button {
background: none;
border: 1px solid rgba(0, 0, 0, 0);
}
button:hover {
border: 1px solid black;
}
</style>
1 change: 1 addition & 0 deletions web/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { default as BasemapPicker } from "./BasemapPicker.svelte";
export { default as DisableInteractiveLayers } from "./DisableInteractiveLayers.svelte";
export { default as HelpButton } from "./HelpButton.svelte";
export { default as Link } from "./Link.svelte";
export { default as Popup } from "./Popup.svelte";
export { default as StreetView } from "./StreetView.svelte";
Expand Down
26 changes: 13 additions & 13 deletions web/src/edit/NeighbourhoodMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import type { LngLat } from "maplibre-gl";
import { onDestroy } from "svelte";
import { type LayerClickInfo } from "svelte-maplibre";
import { Popup, Link } from "../common";
import { Popup, Link, HelpButton } from "../common";
import RenderNeighbourhood from "../RenderNeighbourhood.svelte";
import { SplitComponent } from "svelte-utils/top_bar_layout";
import {
Expand Down Expand Up @@ -141,7 +141,18 @@
Pick neighbourhood
</Link>
</li>
<li>Editing</li>
<li>
Editing
<HelpButton>
<p>
Now that you've defined a neighbourhood boundary, you can see the
possible shortcuts that vehicles are currently able to take
through it. You can add a new modal filter to try and solve this.
The colored "cell" areas show what's reachable for drivers without
leaving the boundary you've drawn.
</p>
</HelpButton>
</li>
</ul>
</nav>
<nav>
Expand Down Expand Up @@ -183,17 +194,6 @@
, with an area of {gjInput.area_km2.toFixed(1)} km²
</p>

<details>
<summary>Help</summary>
<p>
Now that you've defined a neighbourhood boundary, you can see the
possible shortcuts that vehicles are currently able to take through it.
You can add a new modal filter to try and solve this. The colored "cell"
areas show what's reachable for drivers without leaving the boundary
you've drawn.
</p>
</details>

{#if numDisconnectedCells > 0}
<mark>
Some parts of the neighbourhood aren't reachable by drivers, shown in
Expand Down

0 comments on commit d348c79

Please sign in to comment.