Skip to content

Commit c8f3f0e

Browse files
committed
Refactor zoomControls
1 parent 9e7497f commit c8f3f0e

File tree

5 files changed

+50
-55
lines changed

5 files changed

+50
-55
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { Button, ButtonGroup, Stack } from "@mui/material";
2+
import { Minus, Plus, RotateCwSquare } from "lucide-react";
3+
import Circle from "../../assets/icons/circle.svg?react";
4+
import { theme } from "../../AppTheme";
5+
6+
const MapControls = ({ onZoomIn, onZoomOut, onFitToExtent, onRotate }) => {
7+
return (
8+
<Stack
9+
sx={{
10+
position: "absolute",
11+
top: theme.spacing(2),
12+
right: theme.spacing(2),
13+
zIndex: "500",
14+
gap: 1,
15+
}}>
16+
<ButtonGroup variant="contained" orientation="vertical">
17+
<Button data-cy="zoom-in-button" variant="text" color="secondary" onClick={onZoomIn}>
18+
<Plus />
19+
</Button>
20+
<Button data-cy="fit-to-extent-button" variant="text" color="secondary" onClick={onFitToExtent}>
21+
<Circle />
22+
</Button>
23+
<Button data-cy="zoom-out-button" variant="text" color="secondary" onClick={onZoomOut}>
24+
<Minus />
25+
</Button>
26+
</ButtonGroup>
27+
{!!onRotate && (
28+
<Button
29+
variant="text"
30+
onClick={onRotate}
31+
sx={{
32+
height: "44px",
33+
boxShadow:
34+
"0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12)",
35+
}}>
36+
<RotateCwSquare />
37+
</Button>
38+
)}
39+
</Stack>
40+
);
41+
};
42+
43+
export default MapControls;

src/client/src/components/buttons/zoomControls.jsx

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/client/src/components/map/mapComponent.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { register } from "ol/proj/proj4";
2020
import proj4 from "proj4";
2121
import { getGeojson } from "../../api-lib";
2222
import { Box } from "@mui/material";
23-
import ZoomControls from "../buttons/zoomControls.jsx";
23+
import MapControls from "../buttons/mapControls.jsx";
2424
import NamePopup from "./namePopup.jsx";
2525
import { BasemapSelector } from "../basemapSelector/basemapSelector.tsx";
2626
import { swissExtent, updateBasemap } from "../basemapSelector/basemaps.ts";
@@ -653,7 +653,7 @@ class MapComponent extends React.Component {
653653
/>
654654
<NamePopup state={this.state}></NamePopup>
655655
<BasemapSelector marginBottom={"30px"} />
656-
<ZoomControls onZoomIn={this.onZoomIn} onZoomOut={this.onZoomOut} onFitToExtent={this.onFitToExtent} />
656+
<MapControls onZoomIn={this.onZoomIn} onZoomOut={this.onZoomOut} onFitToExtent={this.onFitToExtent} />
657657
</Box>
658658
);
659659
}

src/client/src/components/map/pointComponent.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Button, Icon, Label } from "semantic-ui-react";
1616
import { Box, Card } from "@mui/material";
1717
import { getHeight } from "../../api-lib";
1818
import { fetchApiV2 } from "../../api/fetchApiV2.js";
19-
import ZoomControls from "../buttons/zoomControls.jsx";
19+
import MapControls from "../buttons/mapControls.jsx";
2020
import { BasemapSelector } from "../basemapSelector/basemapSelector.tsx";
2121
import { attributions, crossOrigin, swissExtent, updateBasemap } from "../basemapSelector/basemaps.ts";
2222
import { BasemapContext } from "../basemapSelector/basemapContext.tsx";
@@ -312,7 +312,7 @@ class PointComponent extends React.Component {
312312
height: 670,
313313
}}
314314
/>
315-
<ZoomControls onZoomIn={this.onZoomIn} onZoomOut={this.onZoomOut} onFitToExtent={this.onFitToExtent} />
315+
<MapControls onZoomIn={this.onZoomIn} onZoomOut={this.onZoomOut} onFitToExtent={this.onFitToExtent} />
316316
<Box sx={{ position: "absolute", right: 0, top: 645 }}>
317317
<BasemapSelector marginBottom="0px" />
318318
</Box>

src/client/src/pages/detail/labeling/labelingPanel.tsx

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Box, Button, ButtonGroup, Stack, ToggleButton, ToggleButtonGroup, Typography } from "@mui/material";
22
import { labelingFileFormat, PanelPosition, useLabelingContext } from "./labelingInterfaces.tsx";
3-
import { ChevronLeft, ChevronRight, FileIcon, PanelBottom, PanelRight, Plus, RotateCwSquare } from "lucide-react";
3+
import { ChevronLeft, ChevronRight, FileIcon, PanelBottom, PanelRight, Plus } from "lucide-react";
44
import { FC, MouseEvent, useCallback, useContext, useEffect, useRef, useState } from "react";
55
import { theme } from "../../../AppTheme.ts";
66
import { File as FileInterface, FileResponse, maxFileSizeKB } from "../../../api/file/fileInterfaces.ts";
@@ -13,7 +13,7 @@ import Map from "ol/Map.js";
1313
import Projection from "ol/proj/Projection.js";
1414
import Static from "ol/source/ImageStatic.js";
1515
import { getCenter } from "ol/extent.js";
16-
import ZoomControls from "../../../components/buttons/zoomControls";
16+
import MapControls from "../../../components/buttons/mapControls";
1717
import { ButtonSelect } from "../../../components/buttons/buttonSelect.tsx";
1818
import { defaults as defaultControls } from "ol/control/defaults";
1919
import { View } from "ol";
@@ -260,26 +260,7 @@ const LabelingPanel: FC<LabelingPanelProps> = ({ boreholeId }) => {
260260
}}
261261
/>
262262
</Stack>
263-
<Stack
264-
sx={{
265-
position: "absolute",
266-
top: theme.spacing(2),
267-
right: theme.spacing(2),
268-
zIndex: "500",
269-
gap: 1,
270-
}}>
271-
<ZoomControls onZoomIn={zoomIn} onZoomOut={zoomOut} onFitToExtent={fitToExtent} applyBaseStyling={false} />
272-
<Button
273-
variant="text"
274-
onClick={rotateImage}
275-
sx={{
276-
height: "44px",
277-
boxShadow:
278-
"0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12)",
279-
}}>
280-
<RotateCwSquare />
281-
</Button>
282-
</Stack>
263+
<MapControls onZoomIn={zoomIn} onZoomOut={zoomOut} onFitToExtent={fitToExtent} onRotate={rotateImage} />
283264
<ButtonGroup
284265
variant="contained"
285266
sx={{

0 commit comments

Comments
 (0)