-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #967 from CodeForAfrica/fix/climatemappedafrica_panel
Improve @/climatemappedafrica `HURUmap/Panel`
- Loading branch information
Showing
29 changed files
with
705 additions
and
654 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
apps/climatemappedafrica/src/components/HURUmap/Panel/DesktopPanel/DesktopPanel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Box, Drawer } from "@mui/material"; | ||
import { useTour } from "@reactour/tour"; | ||
import PropTypes from "prop-types"; | ||
import React, { useCallback, useState } from "react"; | ||
|
||
import PanelButtons from "./PanelButtons"; | ||
import PanelItem from "./PanelItem"; | ||
|
||
function DesktopPanel({ sx, ...props }) { | ||
const [value, setValue] = useState(); | ||
const { isOpen: tutorialOpen } = useTour(); | ||
|
||
const closeDrawer = () => { | ||
setValue(undefined); | ||
}; | ||
const handleValueChange = useCallback((newValue) => { | ||
// toggle value if the same | ||
setValue((oldValue) => (oldValue !== newValue ? newValue : undefined)); | ||
}, []); | ||
|
||
const open = value === "rich-data" && !tutorialOpen; | ||
return ( | ||
<Box sx={sx}> | ||
<Drawer | ||
// variant="persistent" | ||
anchor="left" | ||
onClose={closeDrawer} | ||
open={open} | ||
sx={({ typography }) => ({ | ||
display: "flex", | ||
height: "100%", | ||
minWidth: typography.pxToRem(1050), | ||
maxWidth: "max-content", | ||
overflowY: "visible", | ||
position: "relative", | ||
})} | ||
// This needs to match panel button open/close duration | ||
transitionDuration={200} | ||
ModalProps={{ | ||
sx: { | ||
overflowY: "scroll", | ||
overscrollBehaviorBlock: "none", | ||
top: 104, // Toolbar height | ||
}, | ||
}} | ||
PaperProps={{ | ||
elevation: 0, | ||
square: true, | ||
sx: { | ||
background: "transparent", | ||
border: "none", | ||
display: "flex", | ||
flexDirection: "row", | ||
height: "100%", | ||
overflowY: "visible", | ||
position: "absolute", | ||
}, | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
height: "100%", | ||
}} | ||
> | ||
<PanelItem {...props} item={{ value: "rich-data" }} /> | ||
</Box> | ||
</Drawer> | ||
<PanelButtons | ||
{...props} | ||
onValueChange={handleValueChange} | ||
open={open} | ||
value={value} | ||
/> | ||
</Box> | ||
); | ||
} | ||
|
||
DesktopPanel.propTypes = { | ||
isCompare: PropTypes.bool, | ||
isPinning: PropTypes.bool, | ||
onClickPin: PropTypes.func, | ||
onClickUnpin: PropTypes.func, | ||
panelItems: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
value: PropTypes.string, | ||
children: PropTypes.node, | ||
tree: PropTypes.shape({}), | ||
}), | ||
), | ||
primaryProfile: PropTypes.shape({ | ||
items: PropTypes.arrayOf(PropTypes.shape({})), | ||
}), | ||
}; | ||
|
||
export default DesktopPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 1 addition & 49 deletions
50
apps/climatemappedafrica/src/components/HURUmap/Panel/DesktopPanel/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,3 @@ | ||
import { Drawer } from "@mui/material"; | ||
import PropTypes from "prop-types"; | ||
import React, { useRef } from "react"; | ||
|
||
import PanelButtons from "./PanelButtons"; | ||
import PanelItem from "./PanelItem"; | ||
import useStyles from "./useStyles"; | ||
|
||
function DesktopPanel(props) { | ||
const classes = useStyles(props); | ||
const paperRef = useRef(); | ||
|
||
return ( | ||
<> | ||
<Drawer | ||
variant="permanent" | ||
anchor="left" | ||
open | ||
classes={{ | ||
root: classes.root, | ||
paper: classes.paper, | ||
}} | ||
PaperProps={{ ref: paperRef }} | ||
> | ||
<div className={classes.tabPanel}> | ||
<PanelItem {...props} item={{ value: "rich-data" }} /> | ||
</div> | ||
</Drawer> | ||
<PanelButtons {...props} drawerRef={paperRef} /> | ||
</> | ||
); | ||
} | ||
|
||
DesktopPanel.propTypes = { | ||
isCompare: PropTypes.bool, | ||
isPinning: PropTypes.bool, | ||
onClickPin: PropTypes.func, | ||
onClickUnpin: PropTypes.func, | ||
panelItems: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
value: PropTypes.string, | ||
children: PropTypes.node, | ||
tree: PropTypes.shape({}), | ||
}), | ||
), | ||
primaryProfile: PropTypes.shape({ | ||
items: PropTypes.arrayOf(PropTypes.shape({})), | ||
}), | ||
}; | ||
import DesktopPanel from "./DesktopPanel"; | ||
|
||
export default DesktopPanel; |
45 changes: 0 additions & 45 deletions
45
apps/climatemappedafrica/src/components/HURUmap/Panel/DesktopPanel/useStyles.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.