Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move action buttons into MapCard #131

Open
wants to merge 2 commits into
base: layers-visible-bug
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions src/components/Map/GenericMapHolder.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React from "react";
import { useSelector } from "react-redux";
import { Box } from "@mui/material";
import Grid from "@mui/material/Unstable_Grid2";
import { styled } from "@mui/system";
import PropTypes from "prop-types";

import ActionButtons from "./ActionButtons.jsx";
import MapLayerList from "../MapLayerList/MapLayerList.jsx";
import { ThreeColumnGrid } from "../All/StyledComponents.jsx";

Expand All @@ -22,19 +20,10 @@ const ContentHolderGrid = styled(Grid)(({ theme }) => ({
},
}));

const ContentMapBox = styled(Box)(({ theme }) => ({
height: "100%",
padding: theme.spacing(0),
backgroundColor: theme.palette.CRESTGridBackground.dark,
borderColor: theme.palette.CRESTBorderColor.main,
borderStyle: "solid",
borderWidth: "1px",
}));

const listVisibleSelector = (state) => state.mapLayerList.visible;

export default function GenericMapHolder(props) {
const { leftColumn, mapCard, map } = props;
const { leftColumn, mapCard } = props;
const layerListVisible = useSelector(listVisibleSelector);

return (
Expand Down Expand Up @@ -73,10 +62,7 @@ export default function GenericMapHolder(props) {
xl={layerListVisible ? 6.25 : 9}
order={{ xs: 1, sm: 1, md: 2 }}
>
<ContentMapBox>
{mapCard}
<ActionButtons map={map} />
</ContentMapBox>
{mapCard}
</ThreeColumnGrid>

{/* RIGHT COLUMN FOR LAYER LIST */}
Expand All @@ -101,5 +87,4 @@ export default function GenericMapHolder(props) {
GenericMapHolder.propTypes = {
leftColumn: PropTypes.node,
mapCard: PropTypes.node,
map: PropTypes.object,
};
28 changes: 22 additions & 6 deletions src/components/Map/MapCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@ import React, { useEffect } from "react";
import PropTypes from "prop-types";
import { useSelector } from "react-redux";
import { useMapEvents } from "react-leaflet";
import { styled } from "@mui/system";
import { Box } from "@mui/material";

import LeafletMapContainer from "./LeafletMapContainer.jsx";
import ActiveTileLayers from "./ActiveTileLayers.jsx";
import BasemapLayer from "./BasemapLayer.jsx";
import ActionButtons from "./ActionButtons.jsx";

const ContentMapBox = styled(Box)(({ theme }) => ({
height: "100%",
padding: theme.spacing(0),
backgroundColor: theme.palette.CRESTGridBackground.dark,
borderColor: theme.palette.CRESTBorderColor.main,
borderStyle: "solid",
borderWidth: "1px",
}));

export default function MapCard({ children, map, setMap, mapEventHandlers }) {
const selectedCenterSelector = (state) => state.mapProperties.center;
Expand All @@ -31,12 +44,15 @@ export default function MapCard({ children, map, setMap, mapEventHandlers }) {
};

return (
<LeafletMapContainer center={center} zoom={zoom} innerRef={setMap}>
{children}
<ActiveTileLayers />
<BasemapLayer map={map} />
<MapEventsComponent />
</LeafletMapContainer>
<ContentMapBox>
<LeafletMapContainer center={center} zoom={zoom} innerRef={setMap}>
{children}
<ActiveTileLayers />
<BasemapLayer map={map} />
<MapEventsComponent />
</LeafletMapContainer>
<ActionButtons map={map} />
</ContentMapBox>
);
}

Expand Down
77 changes: 36 additions & 41 deletions src/pages/AnalyzeProjectSites.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,50 +130,45 @@ export default function AnalyzeProjectSite(props) {
}

return (
<>
<GenericMapHolder
map={map}
isItAGraph={analyzeAreaState.isItAGraph}
leftColumn={
<AnalyzeProjectSiteLeftColumn
mapActionCard={
<MapActionCard
map={map}
drawAreaDisabled={drawAreaDisabled}
setGeoToRedraw={setGeoToRedraw}
setErrorState={setErrorState}
/>
}
chartCard={
<ChartsHolder
map={map}
featureGroupRef={leafletFeatureGroupRef}
setHover={setHover}
chartData={
featuresForCurrentRegion.length > 0
? featuresForCurrentRegion
: null
}
/>
}
noDataState={<EmptyState />}
/>
}
tableData="Insert Table Data Here"
mapCard={
<React.Fragment>
<AnalyzeProjectSitesMapCard
<GenericMapHolder
isItAGraph={analyzeAreaState.isItAGraph}
leftColumn={
<AnalyzeProjectSiteLeftColumn
mapActionCard={
<MapActionCard
map={map}
setMap={setMap}
leafletFeatureGroupRef={leafletFeatureGroupRef}
setDrawAreaDisabled={setDrawAreaDisabled}
hover={hover}
drawAreaDisabled={drawAreaDisabled}
setGeoToRedraw={setGeoToRedraw}
setErrorState={setErrorState}
/>
</React.Fragment>
}
/>
</>
}
chartCard={
<ChartsHolder
map={map}
featureGroupRef={leafletFeatureGroupRef}
setHover={setHover}
chartData={
featuresForCurrentRegion.length > 0
? featuresForCurrentRegion
: null
}
/>
}
noDataState={<EmptyState />}
/>
}
tableData="Insert Table Data Here"
mapCard={
<AnalyzeProjectSitesMapCard
map={map}
setMap={setMap}
leafletFeatureGroupRef={leafletFeatureGroupRef}
setDrawAreaDisabled={setDrawAreaDisabled}
hover={hover}
setErrorState={setErrorState}
/>
}
/>
);
}

Expand Down
Loading