From 159c758e156500bb967bb7333e7989762346b244 Mon Sep 17 00:00:00 2001 From: Jeremy Myers Date: Mon, 19 May 2025 16:34:03 -0400 Subject: [PATCH 01/17] Fix CSS issue with scale --- src/index.css | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.css b/src/index.css index 09831e3..f4667ff 100644 --- a/src/index.css +++ b/src/index.css @@ -42,7 +42,6 @@ body { .scale-control { font-size: 1.3em; - padding: 1px 0 1px 8px; border: 2px solid rgba(0, 0, 0, 0.3); border-top: none; right: 3em; @@ -50,6 +49,12 @@ body { position: absolute; background-color: rgba(255, 255, 255, 0.7); box-shadow: 0 0 5px #bbb; + box-sizing: border-box; +} + +.scale-control > div { + box-sizing: border-box; + padding-left: 8px; } .source-markers { From 55e1fa434b1785540e54c7663e6307a3dbb4d8ea Mon Sep 17 00:00:00 2001 From: Jeremy Myers Date: Tue, 27 May 2025 13:52:59 -0400 Subject: [PATCH 02/17] Refactor types, state, handlers to allow external baselayers --- src/App.tsx | 68 ++++++++++++++++---------------- src/components/BoxMenu.tsx | 1 + src/components/LayerSelector.tsx | 18 ++++++++- src/configs/mapSettings.ts | 18 ++++++++- src/reducers/baselayerReducer.ts | 67 ++++++++++++++++++++++--------- src/types/maps.ts | 12 +++++- src/utils/layerUtils.ts | 13 ++++++ 7 files changed, 140 insertions(+), 57 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index ffbb72b..c426179 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,6 +3,7 @@ import { MapMetadataResponse, Band, SourceList } from './types/maps'; import { ColorMapControls } from './components/ColorMapControls'; import { fetchProducts } from './utils/fetchUtils'; import { + assertBand, baselayerReducer, CHANGE_BASELAYER, CHANGE_CMAP_TYPE, @@ -13,6 +14,7 @@ import { useQuery } from './hooks/useQuery'; import { useHighlightBoxes } from './hooks/useHighlightBoxes'; import { OpenLayersMap } from './components/OpenLayersMap'; import { handleSelectChange } from './utils/layerUtils'; +import { EXTERNAL_BASELAYERS } from './configs/mapSettings'; function App() { /** contains useful state of the baselayer for tile requests and matplotlib color mapping */ @@ -98,10 +100,12 @@ function App() { * TileLayer requests. */ const onBaseLayerChange = useCallback( - (selectedBaselayerId: number) => { - const newActiveBaselayer = bands?.find( - (b) => b.id === selectedBaselayerId - ); + (selectedBaselayerId: string) => { + const isExternalBaselayer = selectedBaselayerId.includes('external'); + + const newActiveBaselayer = isExternalBaselayer + ? EXTERNAL_BASELAYERS.find((b) => b.id === selectedBaselayerId) + : bands?.find((b) => b.id === Number(selectedBaselayerId)); if (!newActiveBaselayer) return; @@ -149,7 +153,7 @@ function App() { /** Creates an object of data needed by the submap endpoints to download and to add regions. Since it's composed from state at this level, we must construct it here and pass it down. */ const submapData = useMemo(() => { - if (baselayerState.activeBaselayer) { + if (assertBand(baselayerState.activeBaselayer)) { const { map_id: mapId, id: bandId } = baselayerState.activeBaselayer; const { cmap, cmapValues } = baselayerState; return { @@ -162,33 +166,27 @@ function App() { } }, [baselayerState]); - if ( - !baselayerState.activeBaselayer || - !baselayerState.cmap || - !baselayerState.cmapValues - ) { - return null; - } else { - const { activeBaselayer, cmap, cmapValues } = baselayerState; - return ( - <> - {baselayerState.activeBaselayer && bands && ( - - )} + const { activeBaselayer, cmap, cmapValues } = baselayerState; + return ( + <> + {baselayerState.activeBaselayer && bands && ( + + )} + {assertBand(activeBaselayer) && cmap && cmapValues && ( - - ); - } + )} + + ); } export default App; diff --git a/src/components/BoxMenu.tsx b/src/components/BoxMenu.tsx index 2d26190..e987ad1 100644 --- a/src/components/BoxMenu.tsx +++ b/src/components/BoxMenu.tsx @@ -48,6 +48,7 @@ export function BoxMenu({