Add homepage and make bridges look nice
This commit is contained in:
@@ -1,116 +1,236 @@
|
||||
<script lang="ts">
|
||||
import RouteRow from '$lib/components/RouteRow.svelte';
|
||||
import type { PageData } from './$types';
|
||||
export let data: PageData;
|
||||
|
||||
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'
|
||||
}
|
||||
];
|
||||
let searchTerm = '';
|
||||
|
||||
const formatDate = (dateVal: string | null) => {
|
||||
if (!dateVal) return '---';
|
||||
const d = new Date(dateVal);
|
||||
return d.toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: '2-digit' });
|
||||
};
|
||||
|
||||
$: filteredMaps = data.maps.filter(m =>
|
||||
m.routeId.toString().includes(searchTerm) ||
|
||||
m.routeStart.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
m.routeEnd.toLowerCase().includes(searchTerm.toLowerCase())
|
||||
);
|
||||
|
||||
const isVerifiedRecently = (dateVal: string | null) => {
|
||||
if (!dateVal) return 'draft';
|
||||
|
||||
const checkedDate = new Date(dateVal).getTime();
|
||||
const oneYearAgo = Date.now() - (365 * 24 * 60 * 60 * 1000);
|
||||
|
||||
return checkedDate > oneYearAgo ? 'verified' : 'stale';
|
||||
};
|
||||
</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="page-wrapper">
|
||||
<header class="main-header">
|
||||
<h1>ROUTE_DB</h1>
|
||||
<div class="search-container">
|
||||
<input
|
||||
type="text"
|
||||
bind:value={searchTerm}
|
||||
placeholder="Search index..."
|
||||
class="search-input"
|
||||
/>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="map-container">
|
||||
{#each dummyFeatures as feature}
|
||||
<RouteRow {feature} activeElec={feature.elec} />
|
||||
{/each}
|
||||
<div class="list-container">
|
||||
{#each filteredMaps as map}
|
||||
<a href="/map/{map.routeId.toString().padStart(4, '0')}" class="card">
|
||||
<div class="card-top">
|
||||
<span class="route-id">{map.routeId.toString().padStart(4, '0')}</span>
|
||||
<span class="status-badge {isVerifiedRecently(map.checked)}">
|
||||
{#if isVerifiedRecently(map.checked) === 'verified'}
|
||||
Reviewed
|
||||
{:else if isVerifiedRecently(map.checked) === 'stale'}
|
||||
Needs review
|
||||
{:else}
|
||||
Draft
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="location origin">{map.routeStart}</div>
|
||||
<div class="path-arrow">↓</div>
|
||||
<div class="location destination">{map.routeEnd}</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
<span>Created: {formatDate(map.created)}</span>
|
||||
{#if map.checked}
|
||||
<span>• Checked: {formatDate(map.checked)}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</a>
|
||||
{:else}
|
||||
<div class="empty-state">No maps found.</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.map-container {
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
</style>
|
||||
/* Mobile-First Base Styles */
|
||||
:global(body) {
|
||||
margin: 0;
|
||||
background-color: #f8fafc;
|
||||
color: #0f172a;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
}
|
||||
|
||||
.page-wrapper {
|
||||
padding: 1rem;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.main-header {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 900;
|
||||
letter-spacing: -0.05em;
|
||||
margin: 0 0 1rem 0;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 100%;
|
||||
padding: 0.8rem 1rem;
|
||||
border: 2px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
font-size: 1rem;
|
||||
box-sizing: border-box; /* Ensures padding doesn't break width */
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.search-input:focus {
|
||||
border-color: #3b82f6;
|
||||
}
|
||||
|
||||
/* Card Layout (Mobile) */
|
||||
.list-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
display: block;
|
||||
background: white;
|
||||
padding: 1.25rem;
|
||||
border-radius: 16px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
border: 1px solid #e2e8f0;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
|
||||
transition: transform 0.1s ease;
|
||||
}
|
||||
|
||||
.card:active {
|
||||
transform: scale(0.98); /* Tactile feedback for mobile */
|
||||
}
|
||||
|
||||
.card-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.route-id {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||
font-weight: 800;
|
||||
color: #3b82f6;
|
||||
background: #eff6ff;
|
||||
padding: 0.2rem 0.5rem;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.location {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.path-arrow {
|
||||
color: #cbd5e1;
|
||||
font-size: 0.9rem;
|
||||
margin: 0.2rem 0;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
font-size: 0.7rem;
|
||||
color: #64748b;
|
||||
text-transform: uppercase;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.05em;
|
||||
border-top: 1px solid #f1f5f9;
|
||||
padding-top: 0.75rem;
|
||||
}
|
||||
|
||||
/* Update your existing badge styles */
|
||||
.status-badge {
|
||||
font-size: 0.65rem;
|
||||
font-weight: 800;
|
||||
text-transform: uppercase;
|
||||
padding: 0.3rem 0.6rem;
|
||||
border-radius: 999px;
|
||||
white-space: nowrap; /* Prevents label snapping on small screens */
|
||||
}
|
||||
|
||||
.verified {
|
||||
background: #dcfce7;
|
||||
color: #166534;
|
||||
}
|
||||
|
||||
.stale {
|
||||
background: #fef3c7; /* Amber/Yellow background */
|
||||
color: #92400e; /* Dark brown/gold text */
|
||||
border: 1px solid #fcd34d;
|
||||
}
|
||||
|
||||
.draft {
|
||||
background: #f1f5f9;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
/* Desktop Adjustments */
|
||||
@media (min-width: 640px) {
|
||||
.page-wrapper {
|
||||
padding: 3rem 1.5rem;
|
||||
}
|
||||
|
||||
.main-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.path-arrow {
|
||||
display: inline-block;
|
||||
margin: 0 0.5rem;
|
||||
transform: rotate(-90deg); /* Turn down arrow into right arrow */
|
||||
}
|
||||
|
||||
.card-body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
17
src/routes/+page.ts
Normal file
17
src/routes/+page.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { PageLoad } from "./$types";
|
||||
|
||||
export const load: PageLoad = async ({ fetch }) => {
|
||||
const response = await fetch('map-index.json');
|
||||
|
||||
if (!response.ok) {
|
||||
return { maps: [] };
|
||||
}
|
||||
|
||||
const maps = await response.json();
|
||||
|
||||
return {
|
||||
maps: maps.sort((a: any, b: any) => {
|
||||
return Number(a.routeId) - Number(b.routeId);
|
||||
})
|
||||
};
|
||||
};
|
||||
@@ -2,7 +2,10 @@ import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const GET: RequestHandler = () => {
|
||||
return json({ status: 'ok', uptime: process.uptime() }, {
|
||||
status: 200
|
||||
});
|
||||
};
|
||||
return json(
|
||||
{ status: 'ok', uptime: process.uptime() },
|
||||
{
|
||||
status: 200
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script lang="ts">
|
||||
import RouteRow from '$lib/components/RouteRow.svelte';
|
||||
import RouteEndLink from '$lib/components/mapIcons/RouteEndLink.svelte';
|
||||
import RouteEndLink from '$lib/components/mapIcons/RouteEndLink.svelte';
|
||||
import { slide } from 'svelte/transition';
|
||||
|
||||
// data.route contains: routeName, routeId, elecStart, elecEnd, routeDetail[]
|
||||
// data.route contains: routeStart, routeEnd, routeId, elecStart, elecEnd, routeDetail[]
|
||||
export let data;
|
||||
|
||||
let reversed = false; // Reverses Array, and passes value down to children
|
||||
@@ -17,7 +17,7 @@
|
||||
electrificationChange: true,
|
||||
siteof: true,
|
||||
junction: true,
|
||||
tunnel: true,
|
||||
tunnel: true
|
||||
};
|
||||
|
||||
let showFilters = false;
|
||||
@@ -58,16 +58,31 @@
|
||||
</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">
|
||||
<div class="nav-cluster">
|
||||
<a href="/" class="home-link" title="Back to Index">
|
||||
<span class="home-icon">⌂</span>
|
||||
</a>
|
||||
|
||||
<div class="route-stack">
|
||||
{#if data?.route}
|
||||
<h1 class="primary-station">
|
||||
{reversed ? data.route.routeEnd : data.route.routeStart}
|
||||
</h1>
|
||||
<span class="secondary-station">
|
||||
to {reversed ? data.route.routeStart : data.route.routeEnd}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
@@ -108,53 +123,130 @@
|
||||
<main class="map-spine">
|
||||
<div class="container">
|
||||
{#each filteredFeatures as f, i (`${f.type}-${f.miles}-${f.chains}-${i}`)}
|
||||
{#if (f.type === 'continues')}
|
||||
<RouteEndLink feature={f} />
|
||||
{:else}
|
||||
<RouteRow feature={f} activeElec={f.activeElec} {reversed} />
|
||||
{/if}
|
||||
{#if f.type === 'continues'}
|
||||
<RouteEndLink feature={f} />
|
||||
{:else}
|
||||
<RouteRow feature={f} activeElec={f.activeElec} {reversed} />
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.map-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #ffffff;
|
||||
min-height: 100vh;
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.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 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.5rem 1rem;
|
||||
background: #0f172a;
|
||||
color: white;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.nav-cluster {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
min-width: 0; /* Prevents flex children from overflowing */
|
||||
}
|
||||
|
||||
.home-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
background: #1e293b;
|
||||
border: 1px solid #334155;
|
||||
border-radius: 8px;
|
||||
color: #94a3b8;
|
||||
text-decoration: none;
|
||||
font-size: 1.2rem;
|
||||
flex-shrink: 0; /* Keeps button from squishing on mobile */
|
||||
}
|
||||
|
||||
.home-link:hover {
|
||||
background: #334155;
|
||||
color: white;
|
||||
border-color: #475569;
|
||||
}
|
||||
|
||||
.route-stack {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.primary-station {
|
||||
font-size: 1rem;
|
||||
font-weight: 800;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.secondary-station {
|
||||
font-size: 0.7rem;
|
||||
color: #94a3b8;
|
||||
text-transform: uppercase;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.quick-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
background: #1e293b;
|
||||
border: 1px solid #334155;
|
||||
color: white;
|
||||
padding: 0.4rem 0.6rem;
|
||||
border-radius: 6px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.map-spine {
|
||||
padding-top: 72px;
|
||||
}
|
||||
|
||||
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;
|
||||
.secondary-station {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
color: #64748b;
|
||||
letter-spacing: 0.025em;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.primary-station {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
.secondary-station {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.top-nav {
|
||||
padding: 1rem 2rem;
|
||||
padding: 0 2rem;
|
||||
height: 90px;
|
||||
}
|
||||
|
||||
.map-spine {
|
||||
padding-top: 90px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
@@ -242,4 +334,37 @@
|
||||
color: white;
|
||||
border-color: #1e293b;
|
||||
}
|
||||
|
||||
.quick-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
padding: 0.5rem 0.8rem;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
color: #475569;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.icon-btn:hover {
|
||||
background: #f1f5f9;
|
||||
border-color: #cbd5e1;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.icon-btn:active {
|
||||
transform: scale(0.96);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user