2020-03-20 14:48:46 +11:00
|
|
|
import React from "react";
|
|
|
|
|
import Modal from "react-modal";
|
|
|
|
|
import { useThemeUI, Close } from "theme-ui";
|
|
|
|
|
|
2020-04-14 16:05:44 +10:00
|
|
|
function StyledModal({
|
|
|
|
|
isOpen,
|
|
|
|
|
onRequestClose,
|
|
|
|
|
children,
|
|
|
|
|
allowClose,
|
2020-09-06 13:20:05 +10:00
|
|
|
style,
|
2020-04-14 16:05:44 +10:00
|
|
|
...props
|
|
|
|
|
}) {
|
2020-03-20 14:48:46 +11:00
|
|
|
const { theme } = useThemeUI();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal
|
|
|
|
|
isOpen={isOpen}
|
|
|
|
|
onRequestClose={onRequestClose}
|
|
|
|
|
style={{
|
2021-05-09 12:04:31 +10:00
|
|
|
overlay: {
|
|
|
|
|
backgroundColor: "rgba(0, 0, 0, 0.73)",
|
|
|
|
|
zIndex: 100,
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
},
|
2020-03-20 14:48:46 +11:00
|
|
|
content: {
|
|
|
|
|
backgroundColor: theme.colors.background,
|
2021-05-09 12:04:31 +10:00
|
|
|
inset: "initial",
|
2020-04-09 22:48:21 +10:00
|
|
|
maxHeight: "100%",
|
2020-09-06 13:20:05 +10:00
|
|
|
...style,
|
2020-04-09 13:39:25 +10:00
|
|
|
},
|
2020-03-20 14:48:46 +11:00
|
|
|
}}
|
2020-04-13 18:29:46 +10:00
|
|
|
{...props}
|
2020-03-20 14:48:46 +11:00
|
|
|
>
|
2020-07-18 11:06:02 +10:00
|
|
|
{children}
|
|
|
|
|
{allowClose && (
|
|
|
|
|
<Close
|
|
|
|
|
m={0}
|
|
|
|
|
sx={{ position: "absolute", top: 0, right: 0 }}
|
|
|
|
|
onClick={onRequestClose}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2020-03-20 14:48:46 +11:00
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-14 16:05:44 +10:00
|
|
|
StyledModal.defaultProps = {
|
|
|
|
|
allowClose: true,
|
2020-09-06 13:20:05 +10:00
|
|
|
style: {},
|
2020-04-14 16:05:44 +10:00
|
|
|
};
|
|
|
|
|
|
2020-03-20 14:48:46 +11:00
|
|
|
export default StyledModal;
|