Files
grungnet/src/components/Modal.js

54 lines
1.0 KiB
JavaScript
Raw Normal View History

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,
style,
2020-04-14 16:05:44 +10:00
...props
}) {
const { theme } = useThemeUI();
return (
<Modal
isOpen={isOpen}
onRequestClose={onRequestClose}
style={{
overlay: {
backgroundColor: "rgba(0, 0, 0, 0.73)",
zIndex: 100,
display: "flex",
alignItems: "center",
justifyContent: "center",
},
content: {
backgroundColor: theme.colors.background,
inset: "initial",
maxHeight: "100%",
...style,
},
}}
2020-04-13 18:29:46 +10:00
{...props}
>
{children}
{allowClose && (
<Close
m={0}
sx={{ position: "absolute", top: 0, right: 0 }}
onClick={onRequestClose}
/>
)}
</Modal>
);
}
2020-04-14 16:05:44 +10:00
StyledModal.defaultProps = {
allowClose: true,
style: {},
2020-04-14 16:05:44 +10:00
};
export default StyledModal;