Skip to content

Commit ffeb851

Browse files
committed
feat: geomap visualization height depends on the list
1 parent 6b22b2d commit ffeb851

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { FC, PropsWithChildren } from "react";
2+
import { useSelector } from "react-redux";
3+
4+
import { getMapHeight } from "./selectors";
5+
6+
export const HeightContainer: FC<PropsWithChildren> = ({ children }) => {
7+
const height = useSelector(getMapHeight);
8+
9+
return <div style={{ height }}>{children}</div>;
10+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { State } from "@/js/types";
2+
3+
export const getMapHeight = (state: State) => state.chart.height;

vis/js/templates/Geomap/index.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useData } from "@/hooks/useData";
88
import { selectPaper } from "@/js/actions";
99
import { AllPossiblePapersType } from "@/js/types";
1010

11+
import { HeightContainer } from "./HeightContainer";
1112
import { OPTIONS } from "./options";
1213
import { Pin } from "./Pin";
1314
import { getHoveredItemId, getSelectedItemId } from "./selectors";
@@ -28,22 +29,24 @@ export const Geomap: FC = () => {
2829
);
2930

3031
return (
31-
<MapContainer {...MAP} className="geomap_container">
32-
<TileLayer {...LAYER} />
33-
{filteredData &&
34-
filteredData.map((item) => {
35-
const { safe_id: id } = item;
36-
const isActive = selectedItemId === id || hoveredItemId === id;
37-
38-
return (
39-
<Pin
40-
key={id + isActive}
41-
data={item}
42-
isActive={isActive}
43-
onClick={handlePinClick}
44-
/>
45-
);
46-
})}
47-
</MapContainer>
32+
<HeightContainer>
33+
<MapContainer className="geomap_container" {...MAP}>
34+
<TileLayer {...LAYER} />
35+
{filteredData &&
36+
filteredData.map((item) => {
37+
const { safe_id: id } = item;
38+
const isActive = selectedItemId === id || hoveredItemId === id;
39+
40+
return (
41+
<Pin
42+
key={id + isActive}
43+
data={item}
44+
isActive={isActive}
45+
onClick={handlePinClick}
46+
/>
47+
);
48+
})}
49+
</MapContainer>
50+
</HeightContainer>
4851
);
4952
};

vis/js/templates/Geomap/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Options } from "./types";
33
export const OPTIONS: Options = {
44
MAP: {
55
center: [48.216651235748074, 16.39589688527869],
6-
zoom: 4,
6+
zoom: 2,
77
minZoom: 2,
88
maxBounds: [
99
[-85, -180],

vis/stylesheets/modules/_geomap.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* ########### Geomap ########### */
22

33
.geomap_container {
4-
height: 100vh;
4+
height: 100%;
55
width: 100%;
66
}
77

0 commit comments

Comments
 (0)