Add station data and parser for the script.
Need to do: - Write the StationIfno modal and enable toggling it's display.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { components } from '$lib/mapRegistry';
|
||||
import type { ElecType } from '$lib/railStyles';
|
||||
import { IconArrowNarrowRight } from '@tabler/icons-svelte';
|
||||
import { IconArrowNarrowRight, IconInfoCircle } from '@tabler/icons-svelte';
|
||||
|
||||
type featureType = "station" | "junction" | "crossovers" | "siteof" | "bridge" | "minorBridge" | "crossover" | "crossing" | "loop" | "loops" | "signallerChange" | "electrificationChange" | "default" | "tunnel";
|
||||
export let feature: {name: string; type: featureType; goto?: string; entryPoint?: string; miles: number; chains: number; description?: string}; // Raw Object
|
||||
@@ -13,9 +13,14 @@
|
||||
// Linking Logic
|
||||
$: isLinkable = !!(feature.goto && feature.entryPoint);
|
||||
$: href = `/map/${feature.goto}#${feature.entryPoint}`;
|
||||
$: stationInfo = (feature.type === "station" && feature.stationInfo && feature.crs);
|
||||
|
||||
const slugify = (str?: string) =>
|
||||
str?.toLocaleLowerCase().trim().replace(/\s+/g, '-') ?? 'unknown';
|
||||
|
||||
function stationInfo(crs) {
|
||||
console.log(`Date requested for CRS: ${crs}`)
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="row-container" id={slugify(feature.name)}>
|
||||
@@ -37,6 +42,12 @@
|
||||
<div class="feature-desc">{feature.description}</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if stationInfo}
|
||||
<div class="link-indicator" on:click={stationInfo(feature.crs)}>
|
||||
<IconInfoCircle />
|
||||
</div>
|
||||
{/if}
|
||||
{#if isLinkable}
|
||||
<div class="link-indicator">
|
||||
<IconArrowNarrowRight />
|
||||
|
||||
16
src/lib/components/StationInfo.svelte
Normal file
16
src/lib/components/StationInfo.svelte
Normal file
@@ -0,0 +1,16 @@
|
||||
<script lang="ts">
|
||||
|
||||
/*
|
||||
Loads and displayes a 'Station Info' Modal
|
||||
*/
|
||||
|
||||
let crs = $props();
|
||||
|
||||
const allStations = import.meta.glob('$lib/assets/station/*.json', { query: '?json' });
|
||||
|
||||
const stationData = $derived(allStations[`../data/stations/${crs}.json`]);
|
||||
</script>
|
||||
|
||||
{#if stationData}
|
||||
<!-- RENDER STATION DATA DISPLAY HERE -->
|
||||
{/if}
|
||||
Reference in New Issue
Block a user