"use client"; import type { OverlayMode } from "./location-score-panel"; import type { BaseOverlay } from "./map-view"; interface MapLegendProps { overlayMode: OverlayMode; baseOverlay: BaseOverlay; threshold: number; hasPinData: boolean; } // Shared score ramp stops — matches makeColorExpr in map-view.tsx const SCORE_STOPS: [number, string][] = [ [0, "#d73027"], [0.25, "#fc8d59"], [0.5, "#fee08b"], [0.75, "#d9ef8b"], [1, "#1a9850"], ]; function gradientCss(stops: [number, string][]): string { return `linear-gradient(to right, ${stops.map(([p, c]) => `${c} ${p * 100}%`).join(", ")})`; } export function MapLegend({ overlayMode, baseOverlay, threshold, hasPinData }: MapLegendProps) { if (overlayMode === "isochrone" && hasPinData) { // Travel-time legend: green (near) → red (far) const stops: [number, string][] = [ [0, "#1a9850"], [0.5, "#fee08b"], [1, "#d73027"], ]; return (
Travel time
0 min
{threshold} min
); } if (overlayMode === "relative" && hasPinData) { const stops: [number, string][] = [ [0, "#d73027"], [0.25, "#fc8d59"], [0.5, "#ffffbf"], [0.75, "#91cf60"], [1, "#1a9850"], ]; return (
vs. pin
Worse
Better
); } // Hidden gem score if (baseOverlay === "hidden-gem" && !hasPinData) { const stops: [number, string][] = [ [0, "#d73027"], [0.4, "#fee08b"], [0.7, "#d9ef8b"], [1, "#1a9850"], ]; return (
Hidden Gem Score
Poor value
High value
); } // Estate value (land price) if (baseOverlay === "estate-value" && !hasPinData) { const stops: [number, string][] = [ [0, "#ffffb2"], [0.07, "#fecc5c"], [0.2, "#fd8d3c"], [0.47, "#f03b20"], [1, "#bd0026"], ]; return (
Land Value
0
1500+ €/m²
); } // Default: absolute accessibility score return (
Accessibility
Low
High
); }