From 589de0c5ac56a2f19ddf64e8cc3c9a0059358cad Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Tue, 5 May 2026 22:12:01 +0100 Subject: [PATCH] Add state reset --- frontend/src/components/map/MapLegend.tsx | 70 ++++++++++++++++++++--- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/map/MapLegend.tsx b/frontend/src/components/map/MapLegend.tsx index e037e44..186c9d9 100644 --- a/frontend/src/components/map/MapLegend.tsx +++ b/frontend/src/components/map/MapLegend.tsx @@ -11,6 +11,23 @@ import { gradientToCss } from '../../lib/utils'; import { CloseIcon } from '../ui/icons/CloseIcon'; import { TickerValue } from '../ui/TickerValue'; +function ResetScaleIcon({ className = 'w-4 h-4' }: { className?: string }) { + return ( + + + + + + + ); +} + function EnumSwatches({ values, palette, @@ -76,6 +93,8 @@ export default function MapLegend({ suffix, raw, totalCount, + onResetScale, + resetScaleDisabled = false, }: { featureLabel: string; range: [number, number]; @@ -89,9 +108,12 @@ export default function MapLegend({ suffix?: string; raw?: boolean; totalCount?: number; + onResetScale?: () => void; + resetScaleDisabled?: boolean; }) { const { t } = useTranslation(); const isEnum = enumValues && enumValues.length > 0; + const showResetScale = Boolean(onResetScale) && !isEnum; const enumPalette = getEnumPaletteForFeature(featureName ?? null, enumValues); const densityGradient = theme === 'dark' ? DENSITY_GRADIENT_DARK : DENSITY_GRADIENT; const gradientStyle = @@ -121,11 +143,23 @@ export default function MapLegend({ {featureLabel} + {showResetScale && ( + + )} {showCancel && ( @@ -149,15 +183,33 @@ export default function MapLegend({ return (
- {featureLabel} - {showCancel && ( - + + {featureLabel} + + {(showResetScale || showCancel) && ( +
+ {showResetScale && ( + + )} + {showCancel && ( + + )} +
)}
{isEnum ? (