-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply the Svelte trick to express shortcut mode as one component!
- Loading branch information
1 parent
08c662a
commit 2a9e6bb
Showing
5 changed files
with
130 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script lang="ts"> | ||
import { mapContents, sidebarContents } from "./stores"; | ||
// The kinda weird hack is that this must itself be nested underneath the | ||
// MapLibre bit, so it has context. The sidebar is the "remote" part. | ||
// TODO Maybe simplify accordingly | ||
</script> | ||
|
||
<div bind:this={$sidebarContents}> | ||
<slot name="sidebar" /> | ||
</div> | ||
<div bind:this={$mapContents}> | ||
<slot name="map" /> | ||
</div> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,4 @@ | ||
import { LTN } from "backend"; | ||
import { writable, type Writable } from "svelte/store"; | ||
import { writable } from "svelte/store"; | ||
|
||
export type State = | ||
| { | ||
state: "neutral"; | ||
} | ||
| { | ||
state: "chose-road"; | ||
road: number; | ||
gj: FeatureCollection; | ||
shortcutIndex: number | null; | ||
}; | ||
|
||
export let state: Writable<State> = writable({ state: "neutral" }); | ||
|
||
export function choseRoad(app: LTN, road: number) { | ||
let gj = JSON.parse(app.getShortcutsCrossingRoad(road)); | ||
if (gj.features.length == 0) { | ||
window.alert("No shortcuts here"); | ||
return; | ||
} | ||
|
||
state.set({ | ||
state: "chose-road", | ||
road, | ||
gj, | ||
shortcutIndex: null, | ||
}); | ||
} | ||
export let sidebarContents = writable(null); | ||
export let mapContents = writable(null); |