From 758b612fa3db9f347b9cf76c08a416da81c5fe35 Mon Sep 17 00:00:00 2001 From: Connor Howington Date: Mon, 14 Aug 2023 15:12:42 -0400 Subject: [PATCH 1/3] Have the active map type config panel open by default --- packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx b/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx index 9be247db30..4fb7be82dd 100644 --- a/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx +++ b/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx @@ -737,7 +737,7 @@ function MapAnalysisImpl(props: ImplProps) { }, { type: 'item', - id: 'single-variable-bar', + id: 'single-variable-barplot', labelText: MarkerTypeLabels.barplot, leftIcon: activeMarkerConfigurationType === 'barplot' ? ( @@ -1165,8 +1165,9 @@ function MapAnalysisImpl(props: ImplProps) { } // activeSideMenuId is derived from the label text since labels must be unique in a navigation menu - const [activeSideMenuId, setActiveSideMenuId] = - useState(); + const [activeSideMenuId, setActiveSideMenuId] = useState( + 'single-variable-' + appState.activeMarkerConfigurationType + ); const toggleStarredVariable = useToggleStarredVariable(analysisState); From 1b9f33a7f0373a3ee5f6403424ab44a99759cf9b Mon Sep 17 00:00:00 2001 From: Connor Howington Date: Mon, 21 Aug 2023 16:27:10 -0400 Subject: [PATCH 2/3] Remember whether side panel is expanded on subsequent page loads --- .../libs/eda/src/lib/map/analysis/MapAnalysis.tsx | 14 ++++++-------- packages/libs/eda/src/lib/map/analysis/appState.ts | 3 +++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx b/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx index 4fb7be82dd..380cac8340 100644 --- a/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx +++ b/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx @@ -194,6 +194,7 @@ function MapAnalysisImpl(props: ImplProps) { setBoundsZoomLevel, setSubsetVariableAndEntity, sharingUrl, + setIsSidePanelExpanded, setIsSubsetPanelOpen = () => {}, setMarkerConfigurations, setActiveMarkerConfigurationType, @@ -553,7 +554,7 @@ function MapAnalysisImpl(props: ImplProps) { function openSubsetPanelFromControlOutsideOfNavigation() { setIsSubsetPanelOpen(true); setActiveSideMenuId(MapSideNavItemLabels.Filter); - setSideNavigationIsExpanded(true); + setIsSidePanelExpanded(true); } const FilterChipListForHeader = () => { @@ -582,7 +583,7 @@ function MapAnalysisImpl(props: ImplProps) { disabled={ // You don't need this button if whenever the filter // section is active and expanded. - sideNavigationIsExpanded && + appState.isSidePanelExpanded && activeSideMenuId === MapSideNavItemLabels.Filter } themeRole="primary" @@ -1171,9 +1172,6 @@ function MapAnalysisImpl(props: ImplProps) { const toggleStarredVariable = useToggleStarredVariable(analysisState); - const [sideNavigationIsExpanded, setSideNavigationIsExpanded] = - useState(true); - // for flyTo functionality const [willFlyTo, setWillFlyTo] = useState(false); @@ -1205,7 +1203,7 @@ function MapAnalysisImpl(props: ImplProps) { const index = zIndicies.findIndex( (panelTitle) => panelTitle === requestedPanelTitle ); - const zIndexFactor = sideNavigationIsExpanded ? 2 : 10; + const zIndexFactor = appState.isSidePanelExpanded ? 2 : 10; return index + zIndexFactor; } @@ -1262,9 +1260,9 @@ function MapAnalysisImpl(props: ImplProps) { }} > - setSideNavigationIsExpanded((isExpanded) => !isExpanded) + setIsSidePanelExpanded(!appState.isSidePanelExpanded) } siteInformationProps={props.siteInformationProps} sidePanelDrawerContents={activeSideNavigationItemMenu} diff --git a/packages/libs/eda/src/lib/map/analysis/appState.ts b/packages/libs/eda/src/lib/map/analysis/appState.ts index e36ca240c1..c8cd51105e 100644 --- a/packages/libs/eda/src/lib/map/analysis/appState.ts +++ b/packages/libs/eda/src/lib/map/analysis/appState.ts @@ -86,6 +86,7 @@ export const AppState = t.intersection([ }), activeMarkerConfigurationType: MarkerType, markerConfigurations: t.array(MarkerConfiguration), + isSidePanelExpanded: t.boolean, }), t.partial({ boundsZoomLevel: t.type({ @@ -132,6 +133,7 @@ export function useAppState(uiStateKey: string, analysisState: AnalysisState) { viewport: defaultViewport, mouseMode: 'default', activeMarkerConfigurationType: 'pie', + isSidePanelExpanded: true, markerConfigurations: [ { type: 'pie', @@ -222,6 +224,7 @@ export function useAppState(uiStateKey: string, analysisState: AnalysisState) { ), setMarkerConfigurations: useSetter('markerConfigurations'), setBoundsZoomLevel: useSetter('boundsZoomLevel'), + setIsSidePanelExpanded: useSetter('isSidePanelExpanded'), setIsSubsetPanelOpen: useSetter('isSubsetPanelOpen'), setSubsetVariableAndEntity: useSetter('subsetVariableAndEntity'), setViewport: useSetter('viewport'), From cadcba363ae6ff68079ecb61210a8511bef5f3b7 Mon Sep 17 00:00:00 2001 From: Connor Howington Date: Wed, 30 Aug 2023 12:59:09 -0400 Subject: [PATCH 3/3] Remove unused app state property --- packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx | 2 -- packages/libs/eda/src/lib/map/analysis/appState.ts | 2 -- 2 files changed, 4 deletions(-) diff --git a/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx b/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx index 380cac8340..77c79d2118 100644 --- a/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx +++ b/packages/libs/eda/src/lib/map/analysis/MapAnalysis.tsx @@ -195,7 +195,6 @@ function MapAnalysisImpl(props: ImplProps) { setSubsetVariableAndEntity, sharingUrl, setIsSidePanelExpanded, - setIsSubsetPanelOpen = () => {}, setMarkerConfigurations, setActiveMarkerConfigurationType, geoConfigs, @@ -552,7 +551,6 @@ function MapAnalysisImpl(props: ImplProps) { : 0; function openSubsetPanelFromControlOutsideOfNavigation() { - setIsSubsetPanelOpen(true); setActiveSideMenuId(MapSideNavItemLabels.Filter); setIsSidePanelExpanded(true); } diff --git a/packages/libs/eda/src/lib/map/analysis/appState.ts b/packages/libs/eda/src/lib/map/analysis/appState.ts index c8cd51105e..0dec5eac9f 100644 --- a/packages/libs/eda/src/lib/map/analysis/appState.ts +++ b/packages/libs/eda/src/lib/map/analysis/appState.ts @@ -100,7 +100,6 @@ export const AppState = t.intersection([ entityId: t.string, variableId: t.string, }), - isSubsetPanelOpen: t.boolean, }), ]); @@ -225,7 +224,6 @@ export function useAppState(uiStateKey: string, analysisState: AnalysisState) { setMarkerConfigurations: useSetter('markerConfigurations'), setBoundsZoomLevel: useSetter('boundsZoomLevel'), setIsSidePanelExpanded: useSetter('isSidePanelExpanded'), - setIsSubsetPanelOpen: useSetter('isSubsetPanelOpen'), setSubsetVariableAndEntity: useSetter('subsetVariableAndEntity'), setViewport: useSetter('viewport'), };