Skip to content

Commit dee4f50

Browse files
SarahBellahaAkctarus
authored andcommitted
front: add search tool in editor map
1 parent 532a211 commit dee4f50

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

front/src/applications/editor/Editor.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
overflow-y: auto;
104104
}
105105

106-
.nav-box {
106+
.nav-box {
107107
position: absolute;
108108
right: 0;
109109
top: 0;
@@ -142,6 +142,10 @@
142142
& > .map {
143143
flex-grow: 1;
144144

145+
.map-modal {
146+
width: clamp(25%, 50%, 100%);
147+
}
148+
145149
.popup {
146150
text-align: center;
147151

front/src/applications/editor/Editor.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { updateInfraID } from 'reducers/osrdconf';
1616
import { updateViewport, Viewport } from 'reducers/map';
1717
import { getInfraID } from 'reducers/osrdconf/selectors';
1818
import useKeyboardShortcuts from 'utils/hooks/useKeyboardShortcuts';
19+
import MapSearch from 'common/Map/Search/MapSearch';
1920
import Tipped from './components/Tipped';
2021
import Map from './Map';
2122
import NavButtons from './nav';
@@ -50,6 +51,7 @@ const Editor: FC = () => {
5051
tool: TOOLS[TOOL_TYPES.SELECTION],
5152
state: TOOLS[TOOL_TYPES.SELECTION].getInitialState({ infraID, switchTypes }),
5253
});
54+
const [isSearchToolOpened, setIsSearchToolOpened] = useState(false);
5355
const [renderingFingerprint, setRenderingFingerprint] = useState(Date.now());
5456
const forceRender = useCallback(() => {
5557
setRenderingFingerprint(Date.now());
@@ -283,6 +285,12 @@ const Editor: FC = () => {
283285
setToolState,
284286
}}
285287
/>
288+
{isSearchToolOpened && (
289+
<MapSearch
290+
map={mapRef.current!}
291+
closeMapSearchPopUp={() => setIsSearchToolOpened(false)}
292+
/>
293+
)}
286294

287295
<div className="nav-box">
288296
{NavButtons.flatMap((navButtons, i, a) => {
@@ -308,6 +316,7 @@ const Editor: FC = () => {
308316
viewport,
309317
openModal,
310318
closeModal,
319+
setIsSearchToolOpened,
311320
editorState,
312321
mapRef: mapRef.current,
313322
},

front/src/applications/editor/nav.tsx

+13-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Dispatch } from 'redux';
33
import { IconType } from 'react-icons';
44
import { BiTargetLock } from 'react-icons/bi';
55
import { BsFillExclamationOctagonFill } from 'react-icons/bs';
6-
import { FiLayers, FiZoomIn, FiZoomOut } from 'react-icons/fi';
76
import { FaCompass } from 'react-icons/fa';
87
import { GiRailway } from 'react-icons/gi';
98
import { isNil } from 'lodash';
@@ -15,6 +14,7 @@ import { selectLayers } from 'reducers/editor';
1514
import { Shortcut } from 'utils/hooks/useKeyboardShortcuts';
1615
import { ModalContextType } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider';
1716
import InfraSelectorModal from 'common/InfraSelector/InfraSelectorModal';
17+
import { GoSearch, GoStack, GoZoomIn, GoZoomOut } from 'react-icons/go';
1818
import { EditorState, EDITOAST_TO_LAYER_DICT, EditoastType } from './tools/types';
1919
import LayersModal from './components/LayersModal';
2020
import { SelectionState } from './tools/selection/types';
@@ -52,6 +52,7 @@ export interface NavButton {
5252
setViewport: (newViewport: Partial<Viewport>) => void;
5353
openModal: ModalContextType['openModal'];
5454
closeModal: ModalContextType['closeModal'];
55+
setIsSearchToolOpened: React.Dispatch<React.SetStateAction<boolean>>;
5556
mapRef: MapRef;
5657
},
5758
toolContext: {
@@ -65,9 +66,17 @@ export interface NavButton {
6566

6667
const NavButtons: NavButton[][] = [
6768
[
69+
{
70+
id: 'search',
71+
icon: GoSearch,
72+
labelTranslationKey: 'common.search',
73+
onClick({ setIsSearchToolOpened }) {
74+
setIsSearchToolOpened((state) => !state);
75+
},
76+
},
6877
{
6978
id: 'zoom-in',
70-
icon: FiZoomIn,
79+
icon: GoZoomIn,
7180
labelTranslationKey: 'common.zoom-in',
7281
onClick({ setViewport, viewport }) {
7382
setViewport({
@@ -78,7 +87,7 @@ const NavButtons: NavButton[][] = [
7887
},
7988
{
8089
id: 'zoom-out',
81-
icon: FiZoomOut,
90+
icon: GoZoomOut,
8291
labelTranslationKey: 'common.zoom-out',
8392
onClick({ setViewport, viewport }) {
8493
setViewport({
@@ -114,7 +123,7 @@ const NavButtons: NavButton[][] = [
114123
[
115124
{
116125
id: 'layers',
117-
icon: FiLayers,
126+
icon: GoStack,
118127
labelTranslationKey: 'Editor.nav.toggle-layers',
119128
shortcut: { code: 'KeyL', optionalKeys: { ctrlKey: true, shiftKey: true } },
120129
onClick({ openModal, editorState }, { activeTool, toolState, setToolState }) {

0 commit comments

Comments
 (0)