Small changes

This commit is contained in:
Andras Schmelczer 2026-03-12 22:11:33 +00:00
parent eae78df3ca
commit 593f380581
7 changed files with 48 additions and 48 deletions

View file

@ -46,16 +46,22 @@ const ROUTE_COLORS: Record<string, { color: string; darkText?: boolean }> = {
const NON_TUBE_NAMES = new Set(['DLR', 'London Overground', 'Elizabeth line']);
/** Strip trailing parenthesized GTFS route IDs and NaPTAN stop codes (e.g. "(6757261)", "(9400ZZLUCGT1)") */
function stripId(label: string): string {
return label.replace(/\s+\([A-Za-z0-9]+\)$/, '');
}
function getRouteDisplay(mode: string): { label: string; color: string; darkText: boolean } {
const known = ROUTE_COLORS[mode];
const clean = stripId(mode);
const known = ROUTE_COLORS[clean];
if (known) {
const label = NON_TUBE_NAMES.has(mode) || mode.includes('line') ? mode : `${mode} line`;
const label = NON_TUBE_NAMES.has(clean) || clean.includes('line') ? clean : `${clean} line`;
return { label, color: known.color, darkText: !!known.darkText };
}
if (/^\d+[A-Za-z]?$/.test(mode.trim())) {
return { label: `Bus ${mode}`, color: '#0d9488', darkText: false };
if (/^\d+[A-Za-z]?$/.test(clean.trim())) {
return { label: `Bus ${clean}`, color: '#0d9488', darkText: false };
}
return { label: mode, color: '#6b7280', darkText: false };
return { label: clean, color: '#6b7280', darkText: false };
}
function invertLegs(legs: JourneyLeg[]): JourneyLeg[] {
@ -120,8 +126,8 @@ function TimelineLeg({ leg, isLast }: { leg: JourneyLeg; isLast: boolean }) {
<span className="text-[11px] text-warm-500 dark:text-warm-400">{leg.minutes} min</span>
</div>
{leg.from && leg.to && (
<div className="text-[11px] text-warm-600 dark:text-warm-300 mt-0.5 truncate">
{leg.from} {leg.to}
<div className="text-[11px] text-warm-600 dark:text-warm-300 mt-0.5">
{stripId(leg.from)} {stripId(leg.to)}
</div>
)}
</div>

View file

@ -19,7 +19,7 @@ import LocationSearch, { type SearchedLocation } from './LocationSearch';
import MapLegend from './MapLegend';
import HoverCard from './HoverCard';
import type { FeatureFilters } from '../../types';
import { useDeckLayers, osmIdToUrl } from '../../hooks/useDeckLayers';
import { useDeckLayers } from '../../hooks/useDeckLayers';
import { MODE_LABELS, type TravelTimeEntry } from '../../hooks/useTravelTime';
interface MapProps {
@ -295,16 +295,6 @@ export default memo(function Map({
</div>
</div>
</div>
{osmIdToUrl(popupInfo.id) && (
<a
href={osmIdToUrl(popupInfo.id)!}
target="_blank"
rel="noopener noreferrer"
className="text-teal-600 dark:text-teal-400 hover:text-teal-800 dark:hover:text-teal-300 text-xs mt-1 block pointer-events-auto"
>
View on OSM
</a>
)}
</div>
)}
</div>

View file

@ -157,7 +157,6 @@ export default function MapPage({
features,
viewFeature,
activeFeature,
dragValue,
travelTimeEntries: travelTime.entries,
});