"use client"; import type { OverlayMode } from "./location-score-panel"; interface MapLegendProps { overlayMode: OverlayMode; 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, 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
); } // Default: absolute accessibility score return (
Accessibility
Low
High
); }