From 1795c90a58c0652a6edec9c69b665aaf7d846219 Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Thu, 22 May 2025 19:33:26 +0200 Subject: [PATCH] layer control customizing --- src/Components/Map/Subcomponents/Controls/LayerControl.tsx | 4 ++-- src/Components/Map/UtopiaMap.tsx | 4 ++++ src/Components/Map/UtopiaMapInner.tsx | 6 +++--- src/types/UtopiaMapProps.d.ts | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Components/Map/Subcomponents/Controls/LayerControl.tsx b/src/Components/Map/Subcomponents/Controls/LayerControl.tsx index 64d60b95..10180de0 100644 --- a/src/Components/Map/Subcomponents/Controls/LayerControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/LayerControl.tsx @@ -5,8 +5,8 @@ import LayerSVG from '#assets/layer.svg' import { useIsLayerVisible, useToggleVisibleLayer } from '#components/Map/hooks/useFilter' import { useLayers } from '#components/Map/hooks/useLayers' -export function LayerControl() { - const [open, setOpen] = useState(false) +export function LayerControl({ expandLayerControl = false }: { expandLayerControl: boolean }) { + const [open, setOpen] = useState(expandLayerControl) const layers = useLayers() diff --git a/src/Components/Map/UtopiaMap.tsx b/src/Components/Map/UtopiaMap.tsx index d6832cff..8097928b 100644 --- a/src/Components/Map/UtopiaMap.tsx +++ b/src/Components/Map/UtopiaMap.tsx @@ -54,6 +54,7 @@ function UtopiaMap({ showThemeControl = false, defaultTheme, donationWidget, + expandLayerControl, }: { /** height of the map (default '500px') */ height?: string @@ -79,6 +80,8 @@ function UtopiaMap({ defaultTheme?: string /** ask to donate to the Utopia Project OpenCollective campaign (default false) */ donationWidget?: boolean + /** open layer control on map initialisation */ + expandLayerControl?: boolean }) { return ( @@ -97,6 +100,7 @@ function UtopiaMap({ donationWidget={donationWidget} showThemeControl={showThemeControl} defaultTheme={defaultTheme} + expandLayerControl={expandLayerControl} > {children} diff --git a/src/Components/Map/UtopiaMapInner.tsx b/src/Components/Map/UtopiaMapInner.tsx index 690d2410..1b423dbc 100644 --- a/src/Components/Map/UtopiaMapInner.tsx +++ b/src/Components/Map/UtopiaMapInner.tsx @@ -22,9 +22,7 @@ import { useAddVisibleLayer, useFilterTags, useResetFilterTags, - useResetVisibleLayers, useToggleVisibleLayer, - useVisibleLayer, } from './hooks/useFilter' import { useLayers } from './hooks/useLayers' import { useLeafletRefs } from './hooks/useLeafletRefs' @@ -56,6 +54,7 @@ export function UtopiaMapInner({ showThemeControl = false, defaultTheme = '', donationWidget, + expandLayerControl, }: { children?: React.ReactNode geo?: GeoJsonObject @@ -65,6 +64,7 @@ export function UtopiaMapInner({ donationWidget?: boolean showThemeControl?: boolean defaultTheme?: string + expandLayerControl?: boolean }) { const selectNewItemPosition = useSelectPosition() const setSelectNewItemPosition = useSetSelectPosition() @@ -272,7 +272,7 @@ export function UtopiaMapInner({ {showFilterControl && } - {showLayerControl && } + {showLayerControl && } {showGratitudeControl && }