import { useMemo } from 'react'; import type { DepthColorStop } from '../../features/mapSettings/types'; interface DepthLegendProps { depthStops: DepthColorStop[]; } export function DepthLegend({ depthStops }: DepthLegendProps) { const sorted = useMemo( () => [...depthStops].sort((a, b) => a.depth - b.depth), [depthStops], ); const gradient = useMemo(() => { if (sorted.length === 0) return 'transparent'; const stops = sorted.map((s, i) => { const pct = (i / (sorted.length - 1)) * 100; return `${s.color} ${pct.toFixed(0)}%`; }); return `linear-gradient(to bottom, ${stops.join(', ')})`; }, [sorted]); return (
{sorted.map((s) => ( {Math.abs(s.depth).toLocaleString()}m ))}
); }