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

@@ -7,10 +7,10 @@ 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 => { fs.readdirSync(inputDir).forEach((file) => {
if (file.endsWith('.yaml')) { if (file.endsWith('.yaml')) {
const content = yaml.load(fs.readFileSync(path.join(inputDir, file), 'utf8')); const content = yaml.load(fs.readFileSync(path.join(inputDir, file), 'utf8'));
const fileName = file.replace('.yaml', '.json'); const fileName = file.replace('.yaml', '.json');
fs.writeFileSync(path.join(outputDir, fileName), JSON.stringify(content)); fs.writeFileSync(path.join(outputDir, fileName), JSON.stringify(content));
} }
}) });

View File

@@ -2,7 +2,10 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <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% %sveltekit.head%
</head> </head>
<body data-sveltekit-preload-data="hover"> <body data-sveltekit-preload-data="hover">

View File

@@ -10,17 +10,12 @@
<div class="row-container"> <div class="row-container">
<div class="mileage-col"> <div class="mileage-col">
<span class="miles">{feature.miles + "m" || "" }</span> <span class="miles">{feature.miles + 'm' || ''}</span>
<span class="chains">{feature.chains + "ch" || "" }</span> <span class="chains">{feature.chains + 'ch' || ''}</span>
</div> </div>
<div class="icon-col"> <div class="icon-col">
<svelte:component <svelte:component this={Icon} {feature} {activeElec} {reversed} />
this={Icon}
{feature}
{activeElec}
{reversed}
/>
</div> </div>
<div class="label-col"> <div class="label-col">

View File

@@ -8,10 +8,15 @@
$: colour = getElecColour(activeElec); $: colour = getElecColour(activeElec);
</script> </script>
<line x1="32" y1="0" x2="32" y2={height} <line
x1="32"
y1="0"
x2="32"
y2={height}
stroke={colour} stroke={colour}
stroke-width={width} stroke-width={width}
stroke-linecap="butt" /> stroke-linecap="butt"
/>
<style> <style>
svg { svg {

View File

@@ -5,7 +5,7 @@
position: 'over' | 'under'; position: 'over' | 'under';
category: 'rail' | 'footbridge' | 'aroad' | 'minorRoad' | 'motorway' | 'waterway'; category: 'rail' | 'footbridge' | 'aroad' | 'minorRoad' | 'motorway' | 'waterway';
roadName?: string; roadName?: string;
} };
export let activeElec: string; export let activeElec: string;
@@ -16,14 +16,14 @@
minorRoad: { color: '#ffffff', stroke: '#64748b', width: 20, text: '#334155' }, minorRoad: { color: '#ffffff', stroke: '#64748b', width: 20, text: '#334155' },
motorway: { color: '#005da1', stroke: '#003e6b', width: 32, text: '#ffffff' }, motorway: { color: '#005da1', stroke: '#003e6b', width: 32, text: '#ffffff' },
waterway: { color: '#bae6fd', stroke: '#0369a1', width: 24, text: '#075985' }, waterway: { color: '#bae6fd', stroke: '#0369a1', width: 24, text: '#075985' },
pipeline: { color: '#334155', stroke: '#1e293b', width: 4, text: '#334155'}, pipeline: { color: '#334155', stroke: '#1e293b', width: 4, text: '#334155' }
} };
$: s = bridgeStyles[feature.category] || bridgeStyles.minorRoad; $: s = bridgeStyles[feature.category] || bridgeStyles.minorRoad;
$: isOver = feature.position === 'over'; $: isOver = feature.position === 'over';
$: topY = 32 - (s.width / 2); $: topY = 32 - s.width / 2;
$: bottomY = 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}`; $: 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}`; $: bottomPath = `M 0 ${bottomY} Q 8 ${bottomY} 8 ${bottomY + 4} M 56 ${bottomY + 4} Q 56 ${bottomY} 64 ${bottomY}`;
@@ -53,13 +53,14 @@
{#if feature.roadName} {#if feature.roadName}
<text <text
x="32" y="32" x="32"
y="32"
text-anchor="middle" text-anchor="middle"
dominant-baseline="central" dominant-baseline="central"
fill={s.text} fill={s.text}
font-family="sans-serif" font-family="sans-serif"
font-weight="bold" font-weight="bold"
font-size={s.width > 20 ? "10" : "8"} font-size={s.width > 20 ? '10' : '8'}
style="pointer-events: none; text-transform: uppercase; letter-spacing: 0.5px;" style="pointer-events: none; text-transform: uppercase; letter-spacing: 0.5px;"
> >
{feature.roadName} {feature.roadName}
@@ -69,6 +70,11 @@
</svg> </svg>
<style> <style>
svg { display: block; overflow: visible; } svg {
text { user-select: none; } display: block;
overflow: visible;
}
text {
user-select: none;
}
</style> </style>

View File

@@ -9,31 +9,43 @@
$: type = feature.kind.toLowerCase(); $: type = feature.kind.toLowerCase();
$: isFoot = type === 'foot'; $: isFoot = type === 'foot';
$: filterCategory = isFoot ? 'foot' : (type === 'uwc' ? 'uwc' : 'level-crossing'); $: filterCategory = isFoot ? 'foot' : type === 'uwc' ? 'uwc' : 'level-crossing';
</script> </script>
<svg viewBox="0 0 64 64" width="64" height="64" class={filterCategory}> <svg viewBox="0 0 64 64" width="64" height="64" class={filterCategory}>
<BaseTrack {activeElec} height={64} /> <BaseTrack {activeElec} height={64} />
{#if type === 'foot'} {#if type === 'foot'}
<line x1="12" y1="32" x2="52" y2="32" stroke="#475569" stroke-width="2" stroke-dasharray="4 2" /> <line
x1="12"
y1="32"
x2="52"
y2="32"
stroke="#475569"
stroke-width="2"
stroke-dasharray="4 2"
/>
{:else if type === 'uwc'} {:else if type === 'uwc'}
<g stroke="#1e293b" stroke-width="3"> <g stroke="#1e293b" stroke-width="3">
<line x1="12" y1="26" x2="26" y2="26" /> <line x1="12" y1="26" x2="26" y2="26" />
<line x1="38" y1="38" x2="52" y2="38" /> <line x1="38" y1="38" x2="52" y2="38" />
</g> </g>
<text x="50" y="32" class="label-right">UWC</text> <text x="50" y="32" class="label-right">UWC</text>
{:else} {:else}
<rect x="18" y="22" width="28" height="20" rx="1" fill="#1e293b" /> <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> <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} {/if}
</svg> </svg>
<style> <style>
svg { display: block; overflow: visible; } svg {
display: block;
overflow: visible;
}
.label-right { .label-right {
text-anchor: start; /* Align to the left of the start point */ text-anchor: start; /* Align to the left of the start point */
dominant-baseline: central; dominant-baseline: central;

View File

@@ -5,12 +5,12 @@
from: { from: {
elec: string; elec: string;
eco?: string; eco?: string;
}, };
to: { to: {
elec: string; elec: string;
eco?: string; eco?: string;
} };
} };
$: fromColour = getElecColour(feature.from.elec); $: fromColour = getElecColour(feature.from.elec);
$: toColour = getElecColour(feature.to.elec); $: toColour = getElecColour(feature.to.elec);
@@ -23,8 +23,15 @@
<line x1="32" y1="32" x2="32" y2="64" stroke={toColour} stroke-width="6" /> <line x1="32" y1="32" x2="32" y2="64" stroke={toColour} stroke-width="6" />
{#if showFromEco || showToEco} {#if showFromEco || showToEco}
<line x1="32" y1="32" x2="800" y2="32" <line
stroke="#ef4444" stroke-width="2" stroke-dasharray="6 3" /> 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"> <g font-family="sans-serif" font-size="10" font-weight="800" text-anchor="start">
{#if showFromEco} {#if showFromEco}
@@ -45,5 +52,8 @@
</svg> </svg>
<style> <style>
svg { display: block; overflow: visible; } svg {
display: block;
overflow: visible;
}
</style> </style>

View File

@@ -24,16 +24,13 @@
</script> </script>
<svg viewBox="0 0 64 64" width="64" height="64" class="junction"> <svg viewBox="0 0 64 64" width="64" height="64" class="junction">
<path <path d={branchPath} fill="none" stroke={branchColour} stroke-width="5" strone-linecap="round" />
d={branchPath}
fill="none"
stroke={branchColour}
stroke-width="5"
strone-linecap="round"
/>
<BaseTrack {activeElec} height={64} /> <BaseTrack {activeElec} height={64} />
</svg> </svg>
<style> <style>
svg { display: block; overflow: visible; } svg {
display: block;
overflow: visible;
}
</style> </style>

View File

@@ -33,5 +33,4 @@
</g> </g>
<BaseTrack {activeElec} height={64} /> <BaseTrack {activeElec} height={64} />
</svg> </svg>

View File

@@ -12,8 +12,15 @@
<svg viewBox="0 0 64 64" width="64" height="64" style="overflow: visible;"> <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" <line
stroke="#6366f1" stroke-width="2" stroke-dasharray="8 4" /> 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"> <g font-family="sans-serif" font-weight="800" font-size="11">
<text x="70" y="24" fill="#4338ca" style="text-transform: uppercase;"> <text x="70" y="24" fill="#4338ca" style="text-transform: uppercase;">

View File

@@ -14,13 +14,6 @@
<circle cx="32" cy="32" r="12" fill="white" /> <circle cx="32" cy="32" r="12" fill="white" />
<circle cx="32" cy="32" r="12" fill="none" stroke="#000000" stroke-width="3" /> <circle cx="32" cy="32" r="12" fill="none" stroke="#000000" stroke-width="3" />
{:else} {:else}
<rect <rect x="8" y="12" width="50" height="50" rx="8" fill="white" stroke="black" stroke-width="3" />
x="8" y="12"
width="50" height="50"
rx="8"
fill="white"
stroke="black"
stroke-width="3"
/>
{/if} {/if}
</svg> </svg>

View File

@@ -9,7 +9,6 @@ import SignallerChange from '$lib/components/mapIcons/SignallerChange.svelte';
import ElectrificationChange from '$lib/components/mapIcons/ElectrificationChange.svelte'; import ElectrificationChange from '$lib/components/mapIcons/ElectrificationChange.svelte';
import SiteOf from '$lib/components/mapIcons/SiteOf.svelte'; import SiteOf from '$lib/components/mapIcons/SiteOf.svelte';
export const components = { export const components = {
station: Station, station: Station,
junction: Junction, junction: Junction,
@@ -22,5 +21,5 @@ export const components = {
loops: Loop, loops: Loop,
signallerChange: SignallerChange, signallerChange: SignallerChange,
electrificationChange: ElectrificationChange, electrificationChange: ElectrificationChange,
default: BaseTrack, default: BaseTrack
} };

View File

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

View File

@@ -1,7 +1,6 @@
<script lang="ts"> <script lang="ts">
import RouteRow from '$lib/components/RouteRow.svelte'; import RouteRow from '$lib/components/RouteRow.svelte';
const dummyFeatures = [ const dummyFeatures = [
{ {
type: 'station', type: 'station',
@@ -10,7 +9,7 @@
name: 'Testington', name: 'Testington',
description: 'Terminus', description: 'Terminus',
terminus: true, terminus: true,
elec: '25kvac', elec: '25kvac'
}, },
{ {
type: 'station', type: 'station',
@@ -18,7 +17,7 @@
chains: 76, chains: 76,
name: 'Closeby', name: 'Closeby',
description: 'Temporarily closed', description: 'Temporarily closed',
elec: '25kvac', elec: '25kvac'
}, },
{ {
type: 'junction', type: 'junction',
@@ -28,45 +27,45 @@
elec: '25kvac', elec: '25kvac',
elecBranch: 'none', elecBranch: 'none',
miles: 1, miles: 1,
chains: 13, chains: 13
}, },
{ {
type: 'bridge', type: 'bridge',
position: 'over', position: 'over',
category: 'pipeline', category: 'pipeline',
name: 'Waterway Bridge', name: 'Waterway Bridge',
roadName: "TfL (LU)", roadName: 'TfL (LU)',
elec: '25kvac', elec: '25kvac',
miles: 1, miles: 1,
chains: 41, chains: 41
}, },
{ {
type: 'crossover', type: 'crossover',
name: 'Dolphin junction', name: 'Dolphin junction',
elec: '25kvac', elec: '25kvac',
miles: 1, miles: 1,
chains: 42, chains: 42
}, },
{ {
type: 'junction', type: 'junction',
name: 'Test Junction South', name: 'Test Junction South',
description: "To: Banbury West Junction & Birmingham", description: 'To: Banbury West Junction & Birmingham',
diverges: 'left', diverges: 'left',
direction: 'down', direction: 'down',
elec: '25kvac', elec: '25kvac',
elecBranch: '650vdc', elecBranch: '650vdc',
miles: 1, miles: 1,
chains: 42, chains: 42
}, },
{ {
type: 'electrificationChange', type: 'electrificationChange',
from: { from: {
elec: '25kvac', elec: '25kvac',
eco: 'Didcot', eco: 'Didcot'
}, },
to: { to: {
elec: 'none', elec: 'none'
}, }
}, },
{ {
type: 'crossing', type: 'crossing',
@@ -79,13 +78,13 @@
type: 'loop', type: 'loop',
side: 'both', side: 'both',
elec: '25kvac', elec: '25kvac',
elecLoop: 'none', elecLoop: 'none'
}, },
{ {
type: 'signallerChange', type: 'signallerChange',
from: 'TVSC - Didcot WS (SB)', from: 'TVSC - Didcot WS (SB)',
to: 'TVSC - Swindon WS (SN)', to: 'TVSC - Swindon WS (SN)',
elec: '25kvac', elec: '25kvac'
}, },
{ {
type: 'station', type: 'station',
@@ -93,10 +92,11 @@
chains: 13, chains: 13,
name: 'Powerless', name: 'Powerless',
description: "Doesn't exist", description: "Doesn't exist",
elec: '750vdc', elec: '750vdc'
} }
] ];
</script> </script>
<h1>Welcome to SvelteKit</h1> <h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p> <p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>

View File

@@ -15,8 +15,8 @@
signallerChange: true, signallerChange: true,
electrificationChange: true, electrificationChange: true,
siteof: true, siteof: true,
junction: true, junction: true
} };
let showFilters = false; let showFilters = false;
@@ -27,19 +27,16 @@
}; };
// Helper to prettify 'types' // Helper to prettify 'types'
const formatLabel = (str: string) => str.replace(/([A-Z])/g, ' $1').replace(/^./, (s) => s.toUpperCase()); const formatLabel = (str: string) =>
str.replace(/([A-Z])/g, ' $1').replace(/^./, (s) => s.toUpperCase());
$: processedFeatures = (() => { $: processedFeatures = (() => {
const list = reversed const list = reversed ? [...data.route.routeDetail].reverse() : [...data.route.routeDetail];
? [...data.route.routeDetail].reverse()
: [...data.route.routeDetail];
// Seed currentElec from the YAML header boundary // Seed currentElec from the YAML header boundary
let currentElec = reversed let currentElec = reversed ? data.route.elecEnd.elec : data.route.elecStart.elec;
? data.route.elecEnd.elec
: data.route.elecStart.elec;
return list.map(f => { return list.map((f) => {
if (f.type === 'electrificationChange') { if (f.type === 'electrificationChange') {
// Transition state: this tile and everything after it // Transition state: this tile and everything after it
// adopts the new electrification. // adopts the new electrification.
@@ -53,9 +50,9 @@
}); });
})(); })();
$: filteredFeatures = processedFeatures.filter(f => { $: filteredFeatures = processedFeatures.filter((f) => {
return visibleTypes[f.type] ?? true; return visibleTypes[f.type] ?? true;
}) });
</script> </script>
<div class="map-layout"> <div class="map-layout">
@@ -63,23 +60,28 @@
<h1>{data.route.routeName}</h1> <h1>{data.route.routeName}</h1>
<span class="route-code">{data.route.routeId}</span> <span class="route-code">{data.route.routeId}</span>
<div class="quick-actions"> <div class="quick-actions">
<button class="icon-btn" on:click={() => reversed = !reversed}> <button class="icon-btn" on:click={() => (reversed = !reversed)}>
{reversed ? 'UP' : 'DN'} {reversed ? 'UP' : 'DN'}
</button> </button>
<button class="icon-btn" on:click={() => showFilters = !showFilters}> <button class="icon-btn" on:click={() => (showFilters = !showFilters)}> Settings </button>
Settings
</button>
</div> </div>
</header> </header>
{#if showFilters} {#if showFilters}
<div class="backdrop" on:click={() => showFilters = false}></div> <div class="backdrop" on:click={() => (showFilters = false)}></div>
<div class="filter-drawer" transition:slide> <div class="filter-drawer" transition:slide>
<div class="drawer-header"> <div class="drawer-header">
<h3>Visibility Filters</h3> <h3>Visibility Filters</h3>
<button class="close-icon" on:click={() => showFilters = false} aria-label="Close"> <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"> <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" /> <path d="M18 6L6 18M6 6l12 12" stroke-linecap="round" stroke-linejoin="round" />
</svg> </svg>
</button> </button>

View File

@@ -17,7 +17,7 @@ export const load: PageLoad = async ({ params, fetch }) => {
return { return {
route: rawData, route: rawData,
slug: slug, slug: slug
}; };
} catch (err) { } catch (err) {
console.error(`Error loading map ${slug}: `, err); console.error(`Error loading map ${slug}: `, err);