Run npm format

This commit is contained in:
2026-02-05 20:01:54 +00:00
parent 221159433c
commit 4220cdfa5e
18 changed files with 751 additions and 723 deletions

View File

@@ -5,12 +5,12 @@ import path from 'path';
const inputDir = '../static/mapFiles/yaml';
const outputDir = '../static/mapFiles/json';
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, {recursive: true});
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });
fs.readdirSync(inputDir).forEach(file => {
if (file.endsWith('.yaml')) {
const content = yaml.load(fs.readFileSync(path.join(inputDir, file), 'utf8'));
const fileName = file.replace('.yaml', '.json');
fs.writeFileSync(path.join(outputDir, fileName), JSON.stringify(content));
}
})
fs.readdirSync(inputDir).forEach((file) => {
if (file.endsWith('.yaml')) {
const content = yaml.load(fs.readFileSync(path.join(inputDir, file), 'utf8'));
const fileName = file.replace('.yaml', '.json');
fs.writeFileSync(path.join(outputDir, fileName), JSON.stringify(content));
}
});

View File

@@ -2,7 +2,10 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"
/>
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">

View File

@@ -1,133 +1,128 @@
<script lang="ts">
import { components } from '$lib/mapRegistry';
import { components } from '$lib/mapRegistry';
export let feature: any; // Raw Object
export let activeElec: string; // Active Electrification Type
export let reversed: boolean = false;
export let feature: any; // Raw Object
export let activeElec: string; // Active Electrification Type
export let reversed: boolean = false;
$: Icon = components[feature.type] || components.default;
$: Icon = components[feature.type] || components.default;
</script>
<div class="row-container">
<div class="mileage-col">
<span class="miles">{feature.miles + "m" || "" }</span>
<span class="chains">{feature.chains + "ch" || "" }</span>
</div>
<div class="mileage-col">
<span class="miles">{feature.miles + 'm' || ''}</span>
<span class="chains">{feature.chains + 'ch' || ''}</span>
</div>
<div class="icon-col">
<svelte:component
this={Icon}
{feature}
{activeElec}
{reversed}
/>
</div>
<div class="icon-col">
<svelte:component this={Icon} {feature} {activeElec} {reversed} />
</div>
<div class="label-col">
{#if feature.name}
<div class="feature-name">{feature.name}</div>
{/if}
{#if feature.description}
<div class="feature-desc">{feature.description}</div>
{/if}
</div>
<div class="label-col">
{#if feature.name}
<div class="feature-name">{feature.name}</div>
{/if}
{#if feature.description}
<div class="feature-desc">{feature.description}</div>
{/if}
</div>
</div>
<style>
.row-container {
display: grid;
/* Balanced columns: 1fr on both sides keeps the 64px icon in the dead center */
grid-template-columns: 3.5rem 64px 1fr;
width: 100%;
height: 64px;
align-items: center;
margin: 0;
padding: 0;
}
.row-container {
display: grid;
/* Balanced columns: 1fr on both sides keeps the 64px icon in the dead center */
grid-template-columns: 3.5rem 64px 1fr;
width: 100%;
height: 64px;
align-items: center;
margin: 0;
padding: 0;
}
.mileage-col {
display: flex;
flex-direction: column;
align-items: flex-end;
padding-right: 12px;
font-family: 'Courier New', Courier, monospace;
font-size: 0.85rem;
color: #64748b; /* Adjusted slightly for contrast */
}
.mileage-col {
display: flex;
flex-direction: column;
align-items: flex-end;
padding-right: 12px;
font-family: 'Courier New', Courier, monospace;
font-size: 0.85rem;
color: #64748b; /* Adjusted slightly for contrast */
}
.miles {
font-weight: bold;
line-height: 1;
}
.miles {
font-weight: bold;
line-height: 1;
}
.chains {
font-size: 0.7rem;
}
.chains {
font-size: 0.7rem;
}
.icon-col {
width: 64px;
height: 64px;
/* Ensure the icon itself is centered if the SVG is smaller than 64px */
display: flex;
justify-content: center;
align-items: center;
}
.icon-col {
width: 64px;
height: 64px;
/* Ensure the icon itself is centered if the SVG is smaller than 64px */
display: flex;
justify-content: center;
align-items: center;
}
.label-col {
padding-left: 16px;
display: flex;
flex-direction: column;
justify-content: center;
.label-col {
padding-left: 16px;
display: flex;
flex-direction: column;
justify-content: center;
/* FIX: Allow children to manage their own wrapping */
overflow: hidden;
/* min-width: 0 is critical for flex children to allow truncation */
min-width: 0;
}
/* FIX: Allow children to manage their own wrapping */
overflow: hidden;
/* min-width: 0 is critical for flex children to allow truncation */
min-width: 0;
}
.feature-name {
font-weight: 700;
color: #1e293b;
font-size: 0.8rem;
text-transform: capitalize;
.feature-name {
font-weight: 700;
color: #1e293b;
font-size: 0.8rem;
text-transform: capitalize;
/* Allow the title to wrap naturally onto multiple lines */
white-space: normal;
line-height: 1.2;
margin-bottom: 2px;
}
/* Allow the title to wrap naturally onto multiple lines */
white-space: normal;
line-height: 1.2;
margin-bottom: 2px;
}
.feature-desc {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
.feature-desc {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
/* Firefox Fix: Ensure white-space is normal here too */
white-space: normal;
/* Firefox Fix: Ensure white-space is normal here too */
white-space: normal;
line-height: 1.2rem;
max-height: 2.4rem;
font-size: 0.75rem;
color: #64748b;
word-break: break-word;
}
line-height: 1.2rem;
max-height: 2.4rem;
font-size: 0.75rem;
color: #64748b;
word-break: break-word;
}
/* Tablet and Desktop scaling */
@media (min-width: 480px) {
.feature-name {
font-size: 1rem; /* The larger title you requested */
margin-bottom: 4px;
}
/* Tablet and Desktop scaling */
@media (min-width: 480px) {
.feature-name {
font-size: 1rem; /* The larger title you requested */
margin-bottom: 4px;
}
.feature-desc {
font-size: 0.85rem; /* Slightly larger desc to match */
line-height: 1.3rem;
max-height: 2.6rem;
}
.feature-desc {
font-size: 0.85rem; /* Slightly larger desc to match */
line-height: 1.3rem;
max-height: 2.6rem;
}
.label-col {
padding-left: 24px; /* More "breathing room" on big screens */
}
}
.label-col {
padding-left: 24px; /* More "breathing room" on big screens */
}
}
</style>

View File

@@ -1,22 +1,27 @@
<script lang="ts">
import { getElecColour, type ElecType } from '$lib/railStyles';
import { getElecColour, type ElecType } from '$lib/railStyles';
export let activeElec: ElecType = 'none';
export let height: number = 64;
const width = 6;
export let activeElec: ElecType = 'none';
export let height: number = 64;
const width = 6;
$: colour = getElecColour(activeElec);
$: colour = getElecColour(activeElec);
</script>
<line x1="32" y1="0" x2="32" y2={height}
stroke={colour}
stroke-width={width}
stroke-linecap="butt" />
<line
x1="32"
y1="0"
x2="32"
y2={height}
stroke={colour}
stroke-width={width}
stroke-linecap="butt"
/>
<style>
svg{
display: block;
width: 100%;
height: 100%;
}
svg {
display: block;
width: 100%;
height: 100%;
}
</style>

View File

@@ -1,74 +1,80 @@
<script lang="ts">
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
export let feature: {
position: 'over' | 'under';
category: 'rail' | 'footbridge' | 'aroad' | 'minorRoad' | 'motorway' | 'waterway';
roadName?: string;
}
export let feature: {
position: 'over' | 'under';
category: 'rail' | 'footbridge' | 'aroad' | 'minorRoad' | 'motorway' | 'waterway';
roadName?: string;
};
export let activeElec: string;
export let activeElec: string;
const bridgeStyles = {
rail: { color: '#ffffff', stroke: '#000000', width: 20, text: '#000000'},
footbridge: { color: '#ffffff', stroke: '#475569', width: 10, text: '#475569' },
aroad: { color: '#00703c', stroke: '#004d29', width: 24, text: '#FFEB3B' },
minorRoad: { color: '#ffffff', stroke: '#64748b', width: 20, text: '#334155' },
motorway: { color: '#005da1', stroke: '#003e6b', width: 32, text: '#ffffff' },
waterway: { color: '#bae6fd', stroke: '#0369a1', width: 24, text: '#075985' },
pipeline: { color: '#334155', stroke: '#1e293b', width: 4, text: '#334155'},
}
const bridgeStyles = {
rail: { color: '#ffffff', stroke: '#000000', width: 20, text: '#000000' },
footbridge: { color: '#ffffff', stroke: '#475569', width: 10, text: '#475569' },
aroad: { color: '#00703c', stroke: '#004d29', width: 24, text: '#FFEB3B' },
minorRoad: { color: '#ffffff', stroke: '#64748b', width: 20, text: '#334155' },
motorway: { color: '#005da1', stroke: '#003e6b', width: 32, text: '#ffffff' },
waterway: { color: '#bae6fd', stroke: '#0369a1', width: 24, text: '#075985' },
pipeline: { color: '#334155', stroke: '#1e293b', width: 4, text: '#334155' }
};
$: s = bridgeStyles[feature.category] || bridgeStyles.minorRoad;
$: isOver = feature.position === 'over';
$: s = bridgeStyles[feature.category] || bridgeStyles.minorRoad;
$: isOver = feature.position === 'over';
$: topY = 32 - (s.width / 2);
$: bottomY = 32 + (s.width /2);
$: topY = 32 - s.width / 2;
$: bottomY = 32 + s.width / 2;
$: topPath = `M 0 ${topY} Q 8 ${topY} 8 ${topY - 4} M 56 ${topY - 4} Q 56 ${topY} 64 ${topY}`;
$: bottomPath = `M 0 ${bottomY} Q 8 ${bottomY} 8 ${bottomY + 4} M 56 ${bottomY + 4} Q 56 ${bottomY} 64 ${bottomY}`;
$: topPath = `M 0 ${topY} Q 8 ${topY} 8 ${topY - 4} M 56 ${topY - 4} Q 56 ${topY} 64 ${topY}`;
$: bottomPath = `M 0 ${bottomY} Q 8 ${bottomY} 8 ${bottomY + 4} M 56 ${bottomY + 4} Q 56 ${bottomY} 64 ${bottomY}`;
$: bodyPath = `M 0 ${topY} L 64 ${topY} L 64 ${bottomY} L 0 ${bottomY} Z`;
$: bodyPath = `M 0 ${topY} L 64 ${topY} L 64 ${bottomY} L 0 ${bottomY} Z`;
</script>
<svg viewBox="0 0 64 64" width="64" height="64" class="bridge">
{#if !isOver}
<path d={bodyPath} fill={s.color} />
<path d={`M 0 ${topY} L 64 ${topY}`} stroke={s.stroke} stroke-width="2" />
<path d={`M 0 ${bottomY} L 64 ${bottomY}`} stroke={s.stroke} stroke-width="2" />
<BaseTrack {activeElec} height={64} />
{:else}
<BaseTrack {activeElec} height={64} />
{#if !isOver}
<path d={bodyPath} fill={s.color} />
<path d={`M 0 ${topY} L 64 ${topY}`} stroke={s.stroke} stroke-width="2" />
<path d={`M 0 ${bottomY} L 64 ${bottomY}`} stroke={s.stroke} stroke-width="2" />
<BaseTrack {activeElec} height={64} />
{:else}
<BaseTrack {activeElec} height={64} />
<path d={bodyPath} fill="white" /> <path d={bodyPath} fill={s.color} />
<path d={bodyPath} fill="white" /> <path d={bodyPath} fill={s.color} />
<g fill="none" stroke={s.stroke} stroke-width="2.5" stroke-linecap="round">
<path d={`M 0 ${topY} L 64 ${topY}`} />
<path d={`M 0 ${bottomY} L 64 ${bottomY}`} />
<path d={`M 0 ${topY} Q 4 ${topY} 4 ${topY-6}`} />
<path d={`M 64 ${topY} Q 60 ${topY} 60 ${topY-6}`} />
<path d={`M 0 ${bottomY} Q 4 ${bottomY} 4 ${bottomY+6}`} />
<path d={`M 64 ${bottomY} Q 60 ${bottomY} 60 ${bottomY+6}`} />
</g>
<g fill="none" stroke={s.stroke} stroke-width="2.5" stroke-linecap="round">
<path d={`M 0 ${topY} L 64 ${topY}`} />
<path d={`M 0 ${bottomY} L 64 ${bottomY}`} />
<path d={`M 0 ${topY} Q 4 ${topY} 4 ${topY - 6}`} />
<path d={`M 64 ${topY} Q 60 ${topY} 60 ${topY - 6}`} />
<path d={`M 0 ${bottomY} Q 4 ${bottomY} 4 ${bottomY + 6}`} />
<path d={`M 64 ${bottomY} Q 60 ${bottomY} 60 ${bottomY + 6}`} />
</g>
{#if feature.roadName}
<text
x="32" y="32"
text-anchor="middle"
dominant-baseline="central"
fill={s.text}
font-family="sans-serif"
font-weight="bold"
font-size={s.width > 20 ? "10" : "8"}
style="pointer-events: none; text-transform: uppercase; letter-spacing: 0.5px;"
>
{feature.roadName}
</text>
{/if}
{/if}
{#if feature.roadName}
<text
x="32"
y="32"
text-anchor="middle"
dominant-baseline="central"
fill={s.text}
font-family="sans-serif"
font-weight="bold"
font-size={s.width > 20 ? '10' : '8'}
style="pointer-events: none; text-transform: uppercase; letter-spacing: 0.5px;"
>
{feature.roadName}
</text>
{/if}
{/if}
</svg>
<style>
svg { display: block; overflow: visible; }
text { user-select: none; }
svg {
display: block;
overflow: visible;
}
text {
user-select: none;
}
</style>

View File

@@ -1,45 +1,57 @@
<script lang="ts">
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
export let feature: {
kind: 'uwc' | 'ahb' | 'mcb' | 'cctv' | 'tmo' | 'foot';
};
export let feature: {
kind: 'uwc' | 'ahb' | 'mcb' | 'cctv' | 'tmo' | 'foot';
};
export let activeElec: any;
export let activeElec: any;
$: type = feature.kind.toLowerCase();
$: isFoot = type === 'foot';
$: filterCategory = isFoot ? 'foot' : (type === 'uwc' ? 'uwc' : 'level-crossing');
$: type = feature.kind.toLowerCase();
$: isFoot = type === 'foot';
$: filterCategory = isFoot ? 'foot' : type === 'uwc' ? 'uwc' : 'level-crossing';
</script>
<svg viewBox="0 0 64 64" width="64" height="64" class={filterCategory}>
<BaseTrack {activeElec} height={64} />
<BaseTrack {activeElec} height={64} />
{#if type === 'foot'}
<line x1="12" y1="32" x2="52" y2="32" stroke="#475569" stroke-width="2" stroke-dasharray="4 2" />
{#if type === 'foot'}
<line
x1="12"
y1="32"
x2="52"
y2="32"
stroke="#475569"
stroke-width="2"
stroke-dasharray="4 2"
/>
{:else if type === 'uwc'}
<g stroke="#1e293b" stroke-width="3">
<line x1="12" y1="26" x2="26" y2="26" />
<line x1="38" y1="38" x2="52" y2="38" />
</g>
<text x="50" y="32" class="label-right">UWC</text>
{:else}
<rect x="18" y="22" width="28" height="20" rx="1" fill="#1e293b" />
{:else if type === 'uwc'}
<g stroke="#1e293b" stroke-width="3">
<line x1="12" y1="26" x2="26" y2="26" />
<line x1="38" y1="38" x2="52" y2="38" />
</g>
<text x="50" y="32" class="label-right">UWC</text>
{:else}
<rect x="18" y="22" width="28" height="20" rx="1" fill="#1e293b" />
<circle cx="25" cy="29" r="3.5" fill="#ef4444" /> <circle cx="39" cy="29" r="3.5" fill="#ef4444" /> <circle cx="32" cy="37" r="3.5" fill="#ffcc00" /> <text x="50" y="32" class="label-right">{type.toUpperCase()}</text>
{/if}
<circle cx="25" cy="29" r="3.5" fill="#ef4444" />
<circle cx="39" cy="29" r="3.5" fill="#ef4444" />
<circle cx="32" cy="37" r="3.5" fill="#ffcc00" />
<text x="50" y="32" class="label-right">{type.toUpperCase()}</text>
{/if}
</svg>
<style>
svg { display: block; overflow: visible; }
.label-right {
text-anchor: start; /* Align to the left of the start point */
dominant-baseline: central;
font-family: sans-serif;
font-weight: bold;
font-size: 9px;
fill: #1e293b;
}
svg {
display: block;
overflow: visible;
}
.label-right {
text-anchor: start; /* Align to the left of the start point */
dominant-baseline: central;
font-family: sans-serif;
font-weight: bold;
font-size: 9px;
fill: #1e293b;
}
</style>

View File

@@ -1,18 +1,18 @@
<script lang="ts">
import { getElecColour } from '$lib/railStyles';
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
import { getElecColour } from '$lib/railStyles';
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
export let activeElec: any;
export let features: any;
export let activeElec: any;
export let features: any;
$: branchColour = getElecColour(features?.elecBranch || activeElec);
$: branchColour = getElecColour(features?.elecBranch || activeElec);
</script>
<svg viewBox="0 0 64 64" width="64" height="64" class="crossover">
<g stroke={branchColour} stroke-width="3" stroke-linecap="round">
<line x1="16" y1="44" x2="48" y2="12" />
<line x1="16" y1="52" x2="48" y2="20" />
</g>
<g stroke={branchColour} stroke-width="3" stroke-linecap="round">
<line x1="16" y1="44" x2="48" y2="12" />
<line x1="16" y1="52" x2="48" y2="20" />
</g>
<BaseTrack {activeElec} height={64} />
<BaseTrack {activeElec} height={64} />
</svg>

View File

@@ -1,49 +1,59 @@
<script lang="ts">
import { getElecColour } from '$lib/railStyles';
import { getElecColour } from '$lib/railStyles';
export let feature: {
from: {
elec: string;
eco?: string;
},
to: {
elec: string;
eco?: string;
}
}
export let feature: {
from: {
elec: string;
eco?: string;
};
to: {
elec: string;
eco?: string;
};
};
$: fromColour = getElecColour(feature.from.elec);
$: toColour = getElecColour(feature.to.elec);
$: showFromEco = !!feature.from.eco;
$: showToEco = !!feature.to.eco;
$: fromColour = getElecColour(feature.from.elec);
$: toColour = getElecColour(feature.to.elec);
$: showFromEco = !!feature.from.eco;
$: showToEco = !!feature.to.eco;
</script>
<svg viewBox="0 0 64 64" width="64" height="64" style="overflow: visible;">
<line x1="32" y1="0" x2="32" y2="32" stroke={fromColour} stroke-width="6" />
<line x1="32" y1="32" x2="32" y2="64" stroke={toColour} stroke-width="6" />
<line x1="32" y1="0" x2="32" y2="32" stroke={fromColour} stroke-width="6" />
<line x1="32" y1="32" x2="32" y2="64" stroke={toColour} stroke-width="6" />
{#if showFromEco || showToEco}
<line x1="32" y1="32" x2="800" y2="32"
stroke="#ef4444" stroke-width="2" stroke-dasharray="6 3" />
{#if showFromEco || showToEco}
<line
x1="32"
y1="32"
x2="800"
y2="32"
stroke="#ef4444"
stroke-width="2"
stroke-dasharray="6 3"
/>
<g font-family="sans-serif" font-size="10" font-weight="800" text-anchor="start">
{#if showFromEco}
<text x="75" y="24" fill="#b91c1c" style="text-transform: uppercase;">
ECO: {feature.from.eco}
</text>
{/if}
<g font-family="sans-serif" font-size="10" font-weight="800" text-anchor="start">
{#if showFromEco}
<text x="75" y="24" fill="#b91c1c" style="text-transform: uppercase;">
ECO: {feature.from.eco}
</text>
{/if}
{#if showToEco}
<text x="75" y="48" fill="#b91c1c" style="text-transform: uppercase;">
ECO: {feature.to.eco}
</text>
{/if}
</g>
{/if}
{#if showToEco}
<text x="75" y="48" fill="#b91c1c" style="text-transform: uppercase;">
ECO: {feature.to.eco}
</text>
{/if}
</g>
{/if}
<rect x="24" y="30" width="16" height="4" fill="white" stroke="#b91c1c" stroke-width="1.5" />
<rect x="24" y="30" width="16" height="4" fill="white" stroke="#b91c1c" stroke-width="1.5" />
</svg>
<style>
svg { display: block; overflow: visible; }
svg {
display: block;
overflow: visible;
}
</style>

View File

@@ -1,39 +1,36 @@
<script lang="ts">
import {getElecColour} from '$lib/railStyles';
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
import { getElecColour } from '$lib/railStyles';
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
export let feature: {
direction: 'up' | 'down';
diverges: 'left' | 'right';
elecBranch?: string;
};
export let activeElec: any;
export let reversed: boolean = false;
export let feature: {
direction: 'up' | 'down';
diverges: 'left' | 'right';
elecBranch?: string;
};
export let activeElec: any;
export let reversed: boolean = false;
$: isUp = feature.direction === 'up';
$: visualUp = reversed ? !isUp : isUp;
$: isUp = feature.direction === 'up';
$: visualUp = reversed ? !isUp : isUp;
$: isRight = feature.diverges === 'right';
$: isRight = feature.diverges === 'right';
$: yStart = visualUp ? 64 : 0;
$: yEnd = visualUp ? 8 : 56;
$: xEnd = isRight ? 56 : 8;
$: yStart = visualUp ? 64 : 0;
$: yEnd = visualUp ? 8 : 56;
$: xEnd = isRight ? 56 : 8;
$: branchColour = getElecColour(feature.elecBranch || activeElec);
$: branchPath = `M 32 ${yStart} Q 32 32 ${xEnd} ${yEnd}`;
$: branchColour = getElecColour(feature.elecBranch || activeElec);
$: branchPath = `M 32 ${yStart} Q 32 32 ${xEnd} ${yEnd}`;
</script>
<svg viewBox="0 0 64 64" width="64" height="64" class="junction">
<path
d={branchPath}
fill="none"
stroke={branchColour}
stroke-width="5"
strone-linecap="round"
/>
<BaseTrack {activeElec} height={64} />
<path d={branchPath} fill="none" stroke={branchColour} stroke-width="5" strone-linecap="round" />
<BaseTrack {activeElec} height={64} />
</svg>
<style>
svg { display: block; overflow: visible; }
svg {
display: block;
overflow: visible;
}
</style>

View File

@@ -1,37 +1,36 @@
<script lang="ts">
import { getElecColour } from '$lib/railStyles';
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
import { getElecColour } from '$lib/railStyles';
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
export let feature: {
position: 'left' | 'right' | 'both';
elecLoop?: string;
};
export let feature: {
position: 'left' | 'right' | 'both';
elecLoop?: string;
};
export let reversed: boolean = false;
export let activeElec: any;
export let reversed: boolean = false;
export let activeElec: any;
$: loopColour = getElecColour(feature.elecLoop || activeElec);
$: loopColour = getElecColour(feature.elecLoop || activeElec);
$: effectivePosition = (() => {
if (!reversed || feature.position === 'both') return feature.position;
return feature.position === 'left' ? 'right' : 'left';
})();
$: effectivePosition = (() => {
if (!reversed || feature.position === 'both') return feature.position;
return feature.position === 'left' ? 'right' : 'left';
})();
const leftPath = `M 32 0 Q 8 32 32 64`;
const rightPath = `M 32 0 Q 56 32 32 64`;
const leftPath = `M 32 0 Q 8 32 32 64`;
const rightPath = `M 32 0 Q 56 32 32 64`;
</script>
<svg viewBox="0 0 64 64" width="64" height="64" class="loops">
<g fill="none" stroke={loopColour} stroke-width="4" stroke-linecap="round">
{#if effectivePosition === 'left' || feature.position === 'both'}
<path d={leftPath} />
{/if}
<g fill="none" stroke={loopColour} stroke-width="4" stroke-linecap="round">
{#if effectivePosition === 'left' || feature.position === 'both'}
<path d={leftPath} />
{/if}
{#if effectivePosition === 'right' || feature.position === 'both'}
<path d={rightPath} />
{/if}
</g>
<BaseTrack {activeElec} height={64} />
{#if effectivePosition === 'right' || feature.position === 'both'}
<path d={rightPath} />
{/if}
</g>
<BaseTrack {activeElec} height={64} />
</svg>

View File

@@ -1,26 +1,33 @@
<script lang="ts">
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
export let feature: {
from: string;
to: string;
};
export let feature: {
from: string;
to: string;
};
export let activeElec: any;
export let activeElec: any;
</script>
<svg viewBox="0 0 64 64" width="64" height="64" style="overflow: visible;">
<BaseTrack {activeElec} height={64} />
<BaseTrack {activeElec} height={64} />
<line x1="-500" y1="32" x2="800" y2="32"
stroke="#6366f1" stroke-width="2" stroke-dasharray="8 4" />
<line
x1="-500"
y1="32"
x2="800"
y2="32"
stroke="#6366f1"
stroke-width="2"
stroke-dasharray="8 4"
/>
<g font-family="sans-serif" font-weight="800" font-size="11">
<text x="70" y="24" fill="#4338ca" style="text-transform: uppercase;">
{feature.from}
</text>
<text x="70" y="46" fill="#4338ca" style="text-transform: uppercase;">
{feature.to}
</text>
</g>
<g font-family="sans-serif" font-weight="800" font-size="11">
<text x="70" y="24" fill="#4338ca" style="text-transform: uppercase;">
{feature.from}
</text>
<text x="70" y="46" fill="#4338ca" style="text-transform: uppercase;">
{feature.to}
</text>
</g>
</svg>

View File

@@ -1,11 +1,11 @@
<script lang="ts">
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
export let activeElec: string;
export let feature: any;
export let reversed: boolean;
export let activeElec: string;
export let feature: any;
export let reversed: boolean;
</script>
<svg viewBox="0 0 64 64" width="64" height="64" class="loops">
<BaseTrack {activeElec} height={64} />
<BaseTrack {activeElec} height={64} />
</svg>

View File

@@ -1,26 +1,19 @@
<script lang="ts">
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
import { type ElecType } from '$lib/railStyles';
import BaseTrack from '$lib/components/mapIcons/BaseTrack.svelte';
import { type ElecType } from '$lib/railStyles';
export let feature;
export let activeElec: ElecType;
export let feature;
export let activeElec: ElecType;
$: isTerminus = feature.terminus;
$: isTerminus = feature.terminus;
</script>
<svg viewBox="0 0 64 64" class="station">
{#if !isTerminus}
<BaseTrack {activeElec} height={64} />
<circle cx="32" cy="32" r="12" fill="white" />
<circle cx="32" cy="32" r="12" fill="none" stroke="#000000" stroke-width="3" />
{:else}
<rect
x="8" y="12"
width="50" height="50"
rx="8"
fill="white"
stroke="black"
stroke-width="3"
/>
{/if}
{#if !isTerminus}
<BaseTrack {activeElec} height={64} />
<circle cx="32" cy="32" r="12" fill="white" />
<circle cx="32" cy="32" r="12" fill="none" stroke="#000000" stroke-width="3" />
{:else}
<rect x="8" y="12" width="50" height="50" rx="8" fill="white" stroke="black" stroke-width="3" />
{/if}
</svg>

View File

@@ -9,18 +9,17 @@ import SignallerChange from '$lib/components/mapIcons/SignallerChange.svelte';
import ElectrificationChange from '$lib/components/mapIcons/ElectrificationChange.svelte';
import SiteOf from '$lib/components/mapIcons/SiteOf.svelte';
export const components = {
station: Station,
junction: Junction,
crossovers: Crossover,
siteof: SiteOf,
bridge: Bridge,
crossover: Crossover,
crossing: Crossing,
loop: Loop,
loops: Loop,
signallerChange: SignallerChange,
electrificationChange: ElectrificationChange,
default: BaseTrack,
}
station: Station,
junction: Junction,
crossovers: Crossover,
siteof: SiteOf,
bridge: Bridge,
crossover: Crossover,
crossing: Crossing,
loop: Loop,
loops: Loop,
signallerChange: SignallerChange,
electrificationChange: ElectrificationChange,
default: BaseTrack
};

View File

@@ -1,11 +1,11 @@
export type ElecType = 'none' | '25kvac' | '750vdc' | '650vdc' | '1500vdc';
export const elecColours: Record<ElecType, string> = {
'none': '#344415',
'25kvac': '#ed4444',
'750vdc': '#3b82f6',
'650vdc': '#eab308',
'1500vdc': '#f97316',
none: '#344415',
'25kvac': '#ed4444',
'750vdc': '#3b82f6',
'650vdc': '#eab308',
'1500vdc': '#f97316'
};
export const getElecColour = (type?: ElecType) => elecColours[type ?? 'none'];

View File

@@ -1,116 +1,116 @@
<script lang="ts">
import RouteRow from '$lib/components/RouteRow.svelte';
import RouteRow from '$lib/components/RouteRow.svelte';
const dummyFeatures = [
{
type: 'station',
miles: 0,
chains: 0,
name: 'Testington',
description: 'Terminus',
terminus: true,
elec: '25kvac',
},
{
type: 'station',
miles: 0,
chains: 76,
name: 'Closeby',
description: 'Temporarily closed',
elec: '25kvac',
},
{
type: 'junction',
name: 'Test Junction',
diverges: 'right',
direction: 'down',
elec: '25kvac',
elecBranch: 'none',
miles: 1,
chains: 13,
},
{
type: 'bridge',
position: 'over',
category: 'pipeline',
name: 'Waterway Bridge',
roadName: "TfL (LU)",
elec: '25kvac',
miles: 1,
chains: 41,
},
{
type: 'crossover',
name: 'Dolphin junction',
elec: '25kvac',
miles: 1,
chains: 42,
},
{
type: 'junction',
name: 'Test Junction South',
description: "To: Banbury West Junction & Birmingham",
diverges: 'left',
direction: 'down',
elec: '25kvac',
elecBranch: '650vdc',
miles: 1,
chains: 42,
},
{
type: 'electrificationChange',
from: {
elec: '25kvac',
eco: 'Didcot',
},
to: {
elec: 'none',
},
},
{
type: 'crossing',
kind: 'ahb',
elec: '25kvac',
name: 'Swindon Lane',
description: 'Controlled by TVSC (Level Crossing WS)'
},
{
type: 'loop',
side: 'both',
elec: '25kvac',
elecLoop: 'none',
},
{
type: 'signallerChange',
from: 'TVSC - Didcot WS (SB)',
to: 'TVSC - Swindon WS (SN)',
elec: '25kvac',
},
{
type: 'station',
miles: 4,
chains: 13,
name: 'Powerless',
description: "Doesn't exist",
elec: '750vdc',
}
]
const dummyFeatures = [
{
type: 'station',
miles: 0,
chains: 0,
name: 'Testington',
description: 'Terminus',
terminus: true,
elec: '25kvac'
},
{
type: 'station',
miles: 0,
chains: 76,
name: 'Closeby',
description: 'Temporarily closed',
elec: '25kvac'
},
{
type: 'junction',
name: 'Test Junction',
diverges: 'right',
direction: 'down',
elec: '25kvac',
elecBranch: 'none',
miles: 1,
chains: 13
},
{
type: 'bridge',
position: 'over',
category: 'pipeline',
name: 'Waterway Bridge',
roadName: 'TfL (LU)',
elec: '25kvac',
miles: 1,
chains: 41
},
{
type: 'crossover',
name: 'Dolphin junction',
elec: '25kvac',
miles: 1,
chains: 42
},
{
type: 'junction',
name: 'Test Junction South',
description: 'To: Banbury West Junction & Birmingham',
diverges: 'left',
direction: 'down',
elec: '25kvac',
elecBranch: '650vdc',
miles: 1,
chains: 42
},
{
type: 'electrificationChange',
from: {
elec: '25kvac',
eco: 'Didcot'
},
to: {
elec: 'none'
}
},
{
type: 'crossing',
kind: 'ahb',
elec: '25kvac',
name: 'Swindon Lane',
description: 'Controlled by TVSC (Level Crossing WS)'
},
{
type: 'loop',
side: 'both',
elec: '25kvac',
elecLoop: 'none'
},
{
type: 'signallerChange',
from: 'TVSC - Didcot WS (SB)',
to: 'TVSC - Swindon WS (SN)',
elec: '25kvac'
},
{
type: 'station',
miles: 4,
chains: 13,
name: 'Powerless',
description: "Doesn't exist",
elec: '750vdc'
}
];
</script>
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>
<div class="map-container">
{#each dummyFeatures as feature}
<RouteRow {feature} activeElec={feature.elec} />
{/each}
{#each dummyFeatures as feature}
<RouteRow {feature} activeElec={feature.elec} />
{/each}
</div>
<style>
.map-container {
width: 100%;
max-width: 600px;
margin: 0 auto;
font-family: sans-serif;
}
.map-container {
width: 100%;
max-width: 600px;
margin: 0 auto;
font-family: sans-serif;
}
</style>

View File

@@ -1,238 +1,240 @@
<script lang="ts">
import RouteRow from '$lib/components/RouteRow.svelte';
import { slide } from 'svelte/transition';
import RouteRow from '$lib/components/RouteRow.svelte';
import { slide } from 'svelte/transition';
// data.route contains: routeName, routeId, elecStart, elecEnd, routeDetail[]
export let data;
// data.route contains: routeName, routeId, elecStart, elecEnd, routeDetail[]
export let data;
let reversed = false; // Reverses Array, and passes value down to children
let reversed = false; // Reverses Array, and passes value down to children
let visibleTypes = {
station: true,
bridge: true,
crossovers: true,
loop: true,
signallerChange: true,
electrificationChange: true,
siteof: true,
junction: true,
}
let visibleTypes = {
station: true,
bridge: true,
crossovers: true,
loop: true,
signallerChange: true,
electrificationChange: true,
siteof: true,
junction: true
};
let showFilters = false;
let showFilters = false;
// Toggle feature types
const toggleFilter = (type: string) => {
visibleTypes[type] = !visibleTypes[type];
visibleTypes = visibleTypes;
};
// Toggle feature types
const toggleFilter = (type: string) => {
visibleTypes[type] = !visibleTypes[type];
visibleTypes = visibleTypes;
};
// Helper to prettify 'types'
const formatLabel = (str: string) => str.replace(/([A-Z])/g, ' $1').replace(/^./, (s) => s.toUpperCase());
// Helper to prettify 'types'
const formatLabel = (str: string) =>
str.replace(/([A-Z])/g, ' $1').replace(/^./, (s) => s.toUpperCase());
$: processedFeatures = (() => {
const list = reversed
? [...data.route.routeDetail].reverse()
: [...data.route.routeDetail];
$: processedFeatures = (() => {
const list = reversed ? [...data.route.routeDetail].reverse() : [...data.route.routeDetail];
// Seed currentElec from the YAML header boundary
let currentElec = reversed
? data.route.elecEnd.elec
: data.route.elecStart.elec;
// Seed currentElec from the YAML header boundary
let currentElec = reversed ? data.route.elecEnd.elec : data.route.elecStart.elec;
return list.map(f => {
if (f.type === 'electrificationChange') {
// Transition state: this tile and everything after it
// adopts the new electrification.
currentElec = reversed ? f.from.elec : f.to.elec;
}
return list.map((f) => {
if (f.type === 'electrificationChange') {
// Transition state: this tile and everything after it
// adopts the new electrification.
currentElec = reversed ? f.from.elec : f.to.elec;
}
return {
...f,
activeElec: currentElec
};
});
})();
return {
...f,
activeElec: currentElec
};
});
})();
$: filteredFeatures = processedFeatures.filter(f => {
return visibleTypes[f.type] ?? true;
})
$: filteredFeatures = processedFeatures.filter((f) => {
return visibleTypes[f.type] ?? true;
});
</script>
<div class="map-layout">
<header class="top-nav">
<h1>{data.route.routeName}</h1>
<span class="route-code">{data.route.routeId}</span>
<div class="quick-actions">
<button class="icon-btn" on:click={() => reversed = !reversed}>
{reversed ? 'UP' : 'DN'}
</button>
<button class="icon-btn" on:click={() => showFilters = !showFilters}>
Settings
</button>
</div>
</header>
<header class="top-nav">
<h1>{data.route.routeName}</h1>
<span class="route-code">{data.route.routeId}</span>
<div class="quick-actions">
<button class="icon-btn" on:click={() => (reversed = !reversed)}>
{reversed ? 'UP' : 'DN'}
</button>
<button class="icon-btn" on:click={() => (showFilters = !showFilters)}> Settings </button>
</div>
</header>
{#if showFilters}
<div class="backdrop" on:click={() => showFilters = false}></div>
{#if showFilters}
<div class="backdrop" on:click={() => (showFilters = false)}></div>
<div class="filter-drawer" transition:slide>
<div class="drawer-header">
<h3>Visibility Filters</h3>
<button class="close-icon" on:click={() => showFilters = false} aria-label="Close">
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2.5">
<path d="M18 6L6 18M6 6l12 12" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
<div class="filter-drawer" transition:slide>
<div class="drawer-header">
<h3>Visibility Filters</h3>
<button class="close-icon" on:click={() => (showFilters = false)} aria-label="Close">
<svg
viewBox="0 0 24 24"
width="20"
height="20"
fill="none"
stroke="currentColor"
stroke-width="2.5"
>
<path d="M18 6L6 18M6 6l12 12" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</button>
</div>
<div class="drawer-content">
<div class="filter-flex">
{#each Object.keys(visibleTypes) as type}
<button
class="filter-chip"
class:active={visibleTypes[type]}
on:click={() => toggleFilter(type)}
>
{formatLabel(type)}
</button>
{/each}
</div>
</div>
</div>
{/if}
<div class="drawer-content">
<div class="filter-flex">
{#each Object.keys(visibleTypes) as type}
<button
class="filter-chip"
class:active={visibleTypes[type]}
on:click={() => toggleFilter(type)}
>
{formatLabel(type)}
</button>
{/each}
</div>
</div>
</div>
{/if}
<main class="map-spine">
<div class="container">
{#each filteredFeatures as f, i (`${f.type}-${f.miles}-${f.chains}-${i}`)}
<RouteRow feature={f} activeElec={f.activeElec} {reversed} />
{/each}
</div>
</main>
<main class="map-spine">
<div class="container">
{#each filteredFeatures as f, i (`${f.type}-${f.miles}-${f.chains}-${i}`)}
<RouteRow feature={f} activeElec={f.activeElec} {reversed} />
{/each}
</div>
</main>
</div>
<style>
.map-layout {
display: flex;
flex-direction: column;
background: #ffffff;
min-height: 100vh;
}
.map-layout {
display: flex;
flex-direction: column;
background: #ffffff;
min-height: 100vh;
}
.top-nav {
position: sticky;
top: 0;
z-index: 100;
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
border-bottom: 1px solid #e2e8f0;
padding: 0.75rem 1rem;
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
}
.top-nav {
position: sticky;
top: 0;
z-index: 100;
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
border-bottom: 1px solid #e2e8f0;
padding: 0.75rem 1rem;
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
}
h1 {
flex: 1;
min-width: 0;
margin: 0;
font-size: 1.1rem;
font-weight: 800;
line-height: 1.2;
color: #0f172a;
letter-spacing: -0.02em;
white-space: normal;
overflow-wrap: break-word;
}
h1 {
flex: 1;
min-width: 0;
margin: 0;
font-size: 1.1rem;
font-weight: 800;
line-height: 1.2;
color: #0f172a;
letter-spacing: -0.02em;
white-space: normal;
overflow-wrap: break-word;
}
@media (min-width: 768px) {
.top-nav {
padding: 1rem 2rem;
}
@media (min-width: 768px) {
.top-nav {
padding: 1rem 2rem;
}
h1 {
font-size: 1.5rem;
letter-spacing: -0.03em;
}
}
h1 {
font-size: 1.5rem;
letter-spacing: -0.03em;
}
}
.container {
width: 100%;
max-width: 500px;
margin: 0 auto;
padding-top: 1rem;
}
.container {
width: 100%;
max-width: 500px;
margin: 0 auto;
padding-top: 1rem;
}
.backdrop {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.4);
z-index: 150;
}
.backdrop {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.4);
z-index: 150;
}
.filter-drawer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: white;
z-index: 200;
border-radius: 20px 20px 0 0;
box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.15);
/* Ensure it handles iOS home bar spacing */
padding-bottom: env(safe-area-inset-bottom, 1rem);
}
.filter-drawer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: white;
z-index: 200;
border-radius: 20px 20px 0 0;
box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.15);
/* Ensure it handles iOS home bar spacing */
padding-bottom: env(safe-area-inset-bottom, 1rem);
}
.drawer-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1.25rem 1.5rem 0.75rem;
border-bottom: 1px solid #f1f5f9;
}
.drawer-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1.25rem 1.5rem 0.75rem;
border-bottom: 1px solid #f1f5f9;
}
.drawer-header h3 {
margin: 0;
font-size: 1rem;
color: #1e293b;
}
.drawer-header h3 {
margin: 0;
font-size: 1rem;
color: #1e293b;
}
.close-icon {
background: #f1f5f9;
border: none;
border-radius: 50%;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
color: #64748b;
}
.close-icon {
background: #f1f5f9;
border: none;
border-radius: 50%;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
color: #64748b;
}
.drawer-content {
padding: 1.25rem 1.5rem;
}
.drawer-content {
padding: 1.25rem 1.5rem;
}
.filter-flex {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
}
.filter-flex {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
}
.filter-chip {
padding: 0.5rem 1rem;
border-radius: 999px;
border: 1px solid #e2e8f0;
background: #f8fafc;
font-size: 0.875rem;
cursor: pointer;
transition: all 0.2s;
}
.filter-chip {
padding: 0.5rem 1rem;
border-radius: 999px;
border: 1px solid #e2e8f0;
background: #f8fafc;
font-size: 0.875rem;
cursor: pointer;
transition: all 0.2s;
}
.filter-chip.active {
background: #1e293b;
color: white;
border-color: #1e293b;
}
.filter-chip.active {
background: #1e293b;
color: white;
border-color: #1e293b;
}
</style>

View File

@@ -2,28 +2,28 @@ import type { PageLoad } from '/$types';
import { error } from '@sveltejs/kit';
export const load: PageLoad = async ({ params, fetch }) => {
const { slug } = params;
const { slug } = params;
try {
const res = await fetch(`/mapFiles/json/${slug}.json`);
try {
const res = await fetch(`/mapFiles/json/${slug}.json`);
if (!res.ok) {
throw error(404, {
message: `Route ${slug} not found`
});
}
if (!res.ok) {
throw error(404, {
message: `Route ${slug} not found`
});
}
const rawData = await res.json();
const rawData = await res.json();
return {
route: rawData,
slug: slug,
};
} catch (err) {
console.error(`Error loading map ${slug}: `, err);
return {
route: rawData,
slug: slug
};
} catch (err) {
console.error(`Error loading map ${slug}: `, err);
throw error(500, {
message: `Failed to parse map data for ${slug}`
});
}
throw error(500, {
message: `Failed to parse map data for ${slug}`
});
}
};