From 79f8a4d80adb280ffddbd3fa8331adb7ac959155 Mon Sep 17 00:00:00 2001 From: Clara Ni Date: Tue, 11 Feb 2025 14:54:07 +0100 Subject: [PATCH] front: introduce MapStyle type Signed-off-by: Clara Ni --- front/src/applications/editor/Map.tsx | 4 ++-- front/src/applications/editor/types.ts | 3 ++- .../Map/Layers/InfraObjectLayers/InfraObjectLayers.tsx | 3 ++- front/src/common/Map/Layers/OSMLayers/OSMLayers.tsx | 3 ++- front/src/reducers/map/index.ts | 5 ++++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/front/src/applications/editor/Map.tsx b/front/src/applications/editor/Map.tsx index 1ecbd77a1e1..d0a0d9102e1 100644 --- a/front/src/applications/editor/Map.tsx +++ b/front/src/applications/editor/Map.tsx @@ -27,7 +27,7 @@ import { removeSearchItemMarkersOnMap } from 'common/Map/utils'; import { LAYER_GROUPS_ORDER, LAYERS } from 'config/layerOrder'; import VirtualLayers from 'modules/simulationResult/components/SimulationResultsMap/VirtualLayers'; import { getEditorState } from 'reducers/editor/selectors'; -import type { Viewport } from 'reducers/map'; +import type { MapStyle, Viewport } from 'reducers/map'; import { getMap, getShowOSM, getTerrain3DExaggeration } from 'reducers/map/selectors'; import { useAppDispatch } from 'store'; import { getMapMouseEventNearestFeature } from 'utils/mapHelper'; @@ -37,7 +37,7 @@ interface MapProps { toolState: S; setToolState: (state: Partial) => void; activeTool: Tool; - mapStyle: 'normal' | 'dark' | 'blueprint' | 'minimal'; + mapStyle: MapStyle; viewport: Viewport; setViewport: (newViewport: Partial, updateRouter?: boolean) => void; mapRef: React.RefObject; diff --git a/front/src/applications/editor/types.ts b/front/src/applications/editor/types.ts index 7e548a21811..20312b6eee1 100644 --- a/front/src/applications/editor/types.ts +++ b/front/src/applications/editor/types.ts @@ -9,6 +9,7 @@ import type { SwitchType } from 'applications/editor/tools/switchEdition/types'; import type { Operation } from 'common/api/osrdEditoastApi'; import type { ModalContextType } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider'; import type { EditorState } from 'reducers/editor'; +import type { MapStyle } from 'reducers/map'; import type { AppDispatch } from 'store'; import type { Layer } from './consts'; @@ -20,7 +21,7 @@ export type Reducer = (value: T) => T; export type PartialOrReducer = Partial | Reducer; export type MapState = { - mapStyle: 'normal' | 'dark' | 'blueprint' | 'minimal'; + mapStyle: MapStyle; viewport: ViewState; }; diff --git a/front/src/common/Map/Layers/InfraObjectLayers/InfraObjectLayers.tsx b/front/src/common/Map/Layers/InfraObjectLayers/InfraObjectLayers.tsx index c4f53c5af08..3240650b6e2 100644 --- a/front/src/common/Map/Layers/InfraObjectLayers/InfraObjectLayers.tsx +++ b/front/src/common/Map/Layers/InfraObjectLayers/InfraObjectLayers.tsx @@ -1,5 +1,6 @@ import colors from 'common/Map/Consts/colors'; import { LAYER_GROUPS_ORDER, LAYERS } from 'config/layerOrder'; +import type { MapStyle } from 'reducers/map'; import BufferStops from './BufferStops'; import Detectors from './Detectors'; @@ -15,7 +16,7 @@ import TracksGeographic from './TracksGeographic'; type InfraObjectLayersProps = { infraId: number; - mapStyle: 'normal' | 'dark' | 'blueprint' | 'minimal'; + mapStyle: MapStyle; hoveredOperationalPointId?: string; }; diff --git a/front/src/common/Map/Layers/OSMLayers/OSMLayers.tsx b/front/src/common/Map/Layers/OSMLayers/OSMLayers.tsx index 2175600c50c..030d85f9d18 100644 --- a/front/src/common/Map/Layers/OSMLayers/OSMLayers.tsx +++ b/front/src/common/Map/Layers/OSMLayers/OSMLayers.tsx @@ -1,5 +1,6 @@ import colors from 'common/Map/Consts/colors'; import { LAYER_GROUPS_ORDER, LAYERS } from 'config/layerOrder'; +import type { MapStyle } from 'reducers/map'; import Background from '../Background'; import Hillshade from '../Hillshade'; @@ -9,7 +10,7 @@ import Terrain from '../Terrain'; import TracksOSM from '../TracksOSM'; type OSMLayersProps = { - mapStyle: 'normal' | 'dark' | 'blueprint' | 'minimal'; + mapStyle: MapStyle; showOSM: boolean; hidePlatforms?: boolean; }; diff --git a/front/src/reducers/map/index.ts b/front/src/reducers/map/index.ts index 8d08f925472..5bff230d1c4 100644 --- a/front/src/reducers/map/index.ts +++ b/front/src/reducers/map/index.ts @@ -18,9 +18,12 @@ export interface MapSearchMarker { subtitle?: string; lonlat: Position; } + +export type MapStyle = 'normal' | 'dark' | 'blueprint' | 'minimal'; + export interface MapState { url: typeof MAP_URL; - mapStyle: 'normal' | 'dark' | 'blueprint' | 'minimal'; + mapStyle: MapStyle; showIGNBDORTHO: boolean; showIGNSCAN25: boolean; showIGNCadastre: boolean;