Skip to content

Commit 9554662

Browse files
author
Nick Stokoe
committed
Merge branch '20-link-DatasetService-to-front-end-part-3' into nick/dev3
Relates to #20
2 parents 87eb49f + 0c9cc21 commit 9554662

File tree

14 files changed

+216
-143
lines changed

14 files changed

+216
-143
lines changed

apps/front-end/src/App.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,21 @@ import Popup from "./components/popup/Popup";
1010
const App = () => {
1111
const dispatch = useAppDispatch();
1212

13+
/** Startup tasks */
1314
useEffect(() => {
1415
dispatch(fetchConfig()).then(() => {
1516
const urlParamLang = getUrlSearchParam("lang")?.toLowerCase();
1617
if (urlParamLang) dispatch(setLanguage(urlParamLang));
1718
});
19+
20+
fetch(`${import.meta.env.VITE_API_URL}/version`)
21+
.then((response) => response.json())
22+
.then((versionInfo) => {
23+
console.log("API version info", versionInfo);
24+
})
25+
.catch((error) => {
26+
console.error("Error fetching API version info", error);
27+
});
1828
}, []);
1929

2030
return (

apps/front-end/src/app/configSlice.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const configSlice = createAppSlice({
4242
},
4343
{
4444
fulfilled: (state, action) => {
45-
console.log("Mock config", action.payload);
45+
console.log("Config", action.payload);
4646
state.vocabs = action.payload.vocabs;
4747
state.languages = action.payload.languages;
4848
state.currentLanguage = action.payload.languages[0];

apps/front-end/src/components/map/MapWrapper.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ const MapWrapper = () => {
2020
const map = useRef<MapLibreMap | null>(null);
2121
const dispatch = useAppDispatch();
2222

23-
const popupCreatedCallback = () => {
23+
const popupCreatedCallback = (itemIx: number) => {
2424
console.log("Popup created");
25-
dispatch(openPopup());
25+
dispatch(openPopup(itemIx));
2626
};
2727

2828
const popupClosedCallback = () => {
@@ -58,7 +58,7 @@ const MapWrapper = () => {
5858
console.log(`Found ${visibleIndexes?.length} features that matched`);
5959
}
6060

61-
console.log("Rendering data in MapLibreGL", features);
61+
console.log(`Rendering ${features.length} points in MapLibreGL`);
6262

6363
(map.current?.getSource("items-geojson") as GeoJSONSource)?.setData({
6464
type: "FeatureCollection",

apps/front-end/src/components/map/mapLibre.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const disableRotation = (map: Map) => {
6060
const onMarkerClick = async (
6161
map: Map,
6262
feature: GeoJSON.Feature<GeoJSON.Point>,
63-
popupCreatedCallback: () => void,
63+
popupCreatedCallback: (itemIx: number) => void,
6464
popupClosedCallback: () => void,
6565
offset?: [number, number],
6666
) => {
@@ -86,7 +86,7 @@ const onMarkerClick = async (
8686
.setOffset(popupOffset)
8787
.on("close", popupClosedCallback);
8888

89-
popupCreatedCallback();
89+
popupCreatedCallback(ix);
9090
};
9191

9292
const onMarkerHover = (
@@ -119,7 +119,7 @@ const onMarkerHover = (
119119
* Set up the sources and layers of the MapLibreGL map instance.
120120
*/
121121
export const createMap = (
122-
popupCreatedCallback: () => void,
122+
popupCreatedCallback: (itemIx: number) => void,
123123
popupClosedCallback: () => void,
124124
): Map => {
125125
const map = new MapLibreGL.Map({

apps/front-end/src/components/map/mapSlice.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const mapSlice = createAppSlice({
5353
rejected: (state, action) => {
5454
state.status = "failed";
5555
state.allLocations = [];
56-
console.error("Error detching locations", action.payload);
56+
console.error("Error fetching locations", action.payload);
5757
},
5858
},
5959
),

apps/front-end/src/components/panel/directoryPanel/directoryItem/DirectoryItem.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ interface DirectoryItemProps {
1212
onClick?: (e: React.MouseEvent) => void; // for storybook testing
1313
}
1414

15-
const StyledButton = styled(Button)(({ active }: { active: boolean }) => ({
15+
/** Passing active as a boolean gives a React error so just pass as a number 0 or 1. */
16+
const StyledButton = styled(Button)(({ active }: { active: number }) => ({
1617
width: "100%",
1718
padding: "var(--spacing-small) var(--spacing-medium)",
1819
display: "block",
@@ -49,7 +50,7 @@ const DirectoryItem = ({
4950

5051
return (
5152
<ListItem>
52-
<StyledButton role="button" active={active} onClick={handleClick}>
53+
<StyledButton role="button" active={+active} onClick={handleClick}>
5354
{label}
5455
</StyledButton>
5556
</ListItem>

apps/front-end/src/components/panel/searchPanel/SearchPanel.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ const SearchPanel = () => {
4444
};
4545

4646
return (
47-
<form onSubmit={onSubmit}>
47+
<form
48+
onSubmit={onSubmit}
49+
style={{ display: "flex", flexDirection: "column", overflow: "hidden" }} // Fix for search filter overflow issue
50+
>
4851
<Heading title="Search">
4952
<SearchBox
5053
value={currentText}

apps/front-end/src/components/popup/Popup.stories.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CssBaseline } from "@mui/material";
66
import { store } from "../../app/store";
77
import { Provider } from "react-redux";
88
import Popup from "./Popup";
9-
import { togglePopup } from "./popupSlice";
9+
// import { togglePopup } from "./popupSlice";
1010

1111
const meta = {
1212
title: "Common/Popup",
@@ -33,6 +33,8 @@ type Story = StoryObj<typeof meta>;
3333

3434
export const Default: Story = {
3535
play: () => {
36-
store.dispatch(togglePopup());
36+
// TODO: feed in mock item data
37+
// https://storybook.js.org/tutorials/intro-to-storybook/react/en/data/
38+
// store.dispatch(togglePopup());
3739
},
3840
};

apps/front-end/src/components/popup/Popup.tsx

+16-61
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
import { createPortal } from "react-dom";
22
import Box from "@mui/material/Box";
3-
import Modal from "@mui/material/Modal";
4-
import Fade from "@mui/material/Fade";
53
import LeftPane from "./leftPane/LeftPane";
64
import RightPane from "./rightPane/RightPane";
7-
import CloseButton from "../common/closeButton/CloseButton";
85
import { styled } from "@mui/material/styles";
9-
import { useAppDispatch, useAppSelector } from "../../app/hooks";
10-
import { closePopup, popupIsOpen } from "./popupSlice";
11-
import mockItem from "../../data/mockItem";
6+
import { useAppSelector } from "../../app/hooks";
7+
import { selectPopupIsOpen, selectPopupData } from "./popupSlice";
128
import { POPUP_CONTAINER_ID } from "../map/mapLibre";
139

1410
const StyledPopup = styled(Box)(({ theme }) => ({
15-
width: "calc (100% - (var(--spacing-large) * 2))",
16-
height: "calc(100% - (var(--spacing-large) * 2 + 80px))",
11+
width: "300px",
12+
height: "500px",
1713
display: "flex",
1814
backgroundColor: theme.palette.background.paper,
1915
padding: 0,
2016
borderRadius: "var(--border-radius-xlarge)",
21-
margin: "auto var(--spacing-large)",
2217
outline: "none",
2318
position: "relative",
19+
textAlign: "left",
20+
overflowY: "auto",
2421
"@media (min-width: 768px)": {
2522
width: "100%",
2623
height: "auto",
27-
maxWidth: 900,
28-
maxHeight: 600,
24+
minWidth: 600,
25+
maxWidth: 700,
26+
maxHeight: 450,
2927
margin: "auto",
28+
overflow: "hidden",
3029
},
3130
}));
3231

3332
const StylePopupInner = styled(Box)(() => ({
33+
width: "100%",
3434
display: "flex",
3535
flexDirection: "column",
3636
overflowY: "auto",
@@ -54,65 +54,20 @@ const StylePopupInner = styled(Box)(() => ({
5454
},
5555
}));
5656

57-
const StyledPointer = styled(Box)(({ theme }) => ({
58-
position: "absolute",
59-
bottom: -17,
60-
left: "50%",
61-
transform: "translateX(-50%)",
62-
width: 0,
63-
borderLeft: "17px solid transparent",
64-
borderRight: "17px solid transparent",
65-
borderTop: `20px solid ${theme.palette.background.paper}`,
66-
}));
67-
6857
const Popup = () => {
69-
const dispatch = useAppDispatch();
70-
const open = useAppSelector(popupIsOpen);
71-
72-
const handleClosePopup = () => {
73-
dispatch(closePopup());
74-
};
58+
const open = useAppSelector(selectPopupIsOpen);
59+
const data = useAppSelector(selectPopupData);
7560

7661
return (
7762
open &&
7863
document.getElementById(POPUP_CONTAINER_ID) &&
7964
createPortal(
80-
// <Modal
81-
// open={open}
82-
// onClose={handleClosePopup}
83-
// aria-labelledby={`pop-up-${mockItem.id}`}
84-
// aria-describedby="pop-up-description"
85-
// closeAfterTransition
86-
// >
87-
// <Fade in={open}>
88-
<StyledPopup id="'aaaaaaaaaa">
89-
{/* <CloseButton
90-
sx={{
91-
position: "absolute",
92-
right: "14px",
93-
top: "14px",
94-
}}
95-
buttonAction={handleClosePopup}
96-
/> */}
65+
<StyledPopup>
9766
<StylePopupInner>
98-
<LeftPane
99-
name={mockItem.name}
100-
primaryActivity={mockItem.primary_activity}
101-
description={mockItem.description}
102-
dcDomains={mockItem.dc_domains}
103-
/>
104-
<RightPane
105-
geocodedAddr={mockItem.geocoded_addr}
106-
website={mockItem.website}
107-
organisationalStructure={mockItem.organisational_structure}
108-
typology={mockItem.typology}
109-
dataSources={mockItem.data_sources}
110-
/>
67+
<LeftPane {...data} />
68+
<RightPane {...data} />
11169
</StylePopupInner>
112-
{/* <StyledPointer /> */}
11370
</StyledPopup>,
114-
// </Fade>
115-
// </Modal>
11671
document.getElementById(POPUP_CONTAINER_ID)!!,
11772
)
11873
);

apps/front-end/src/components/popup/leftPane/LeftPane.tsx

+8-15
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ const StyledLeftPane = styled(Box)(() => ({
1717
flexDirection: "column",
1818
margin: "var(--spacing-large)",
1919
"@media (min-width: 768px)": {
20-
width: "60%",
20+
width: "70%",
2121
flexDirection: "column",
2222
margin:
23-
"var(--spacing-xlarge) 0 var(--spacing-xxlarge) var(--spacing-xxlarge)",
23+
"var(--spacing-large) 0 var(--spacing-xlarge) var(--spacing-xlarge)",
2424
overflowY: "hidden",
2525
},
2626
}));
@@ -35,14 +35,14 @@ const StyledHeaderContainer = styled(Box)(() => ({
3535
top: 0,
3636
left: 0,
3737
"& h1": {
38-
fontSize: "var(--font-size-large)",
38+
fontSize: "var(--font-size-xxlarge)",
3939
color: "var(--color-primary)",
4040
},
4141
"@media (min-width: 768px)": {
4242
position: "sticky",
43-
padding: "0 var(--spacing-xxlarge) var(--spacing-xlarge) 0",
43+
padding: "0 var(--spacing-xlarge) var(--spacing-large) 0",
4444
"& h1": {
45-
fontSize: "28px",
45+
fontSize: "26px",
4646
},
4747
},
4848
}));
@@ -61,11 +61,11 @@ const StyledContentContainer = styled(Box)(() => ({
6161
},
6262
"&::-webkit-scrollbar-track": {
6363
background: "rgba(0, 0, 0, 0.1)",
64-
borderRadius: "10px",
64+
borderRadius: "8px",
6565
},
6666
"&::-webkit-scrollbar-thumb": {
6767
backgroundColor: "rgba(0, 0, 0, 0.3)",
68-
borderRadius: "10px",
68+
borderRadius: "8px",
6969
},
7070
"& h4": {
7171
fontSize: "var(--font-size-small)",
@@ -78,14 +78,7 @@ const StyledContentContainer = styled(Box)(() => ({
7878
"@media (min-width: 768px)": {
7979
overflowY: "auto",
8080
paddingRight: "var(--spacing-large)",
81-
marginRight: "var(--spacing-medium)",
82-
"& h4": {
83-
fontSize: "var(--font-size-large)",
84-
},
85-
86-
"& p": {
87-
fontSize: "var(--font-size-medium)",
88-
},
81+
marginRight: "var(--spacing-small)",
8982
},
9083
}));
9184

0 commit comments

Comments
 (0)