Files
grungnet/src/components/Modal.js

50 lines
995 B
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,
...props
}) {
const { theme } = useThemeUI();
return (
<Modal
isOpen={isOpen}
onRequestClose={onRequestClose}
style={{
overlay: { backgroundColor: "rgba(0, 0, 0, 0.73)" },
content: {
backgroundColor: theme.colors.background,
top: "50%",
left: "50%",
right: "auto",
bottom: "auto",
marginRight: "-50%",
transform: "translate(-50%, -50%)",
maxHeight: "100%",
},
}}
2020-04-13 18:29:46 +10:00
{...props}
>
{children}
2020-04-14 16:05:44 +10:00
{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,
};
export default StyledModal;