Added allow close option to banner and fixed banner min width
This commit is contained in:
parent
7cc0e6cee0
commit
693c2967cd
@ -2,7 +2,7 @@ import React from "react";
|
|||||||
import Modal from "react-modal";
|
import Modal from "react-modal";
|
||||||
import { useThemeUI, Close } from "theme-ui";
|
import { useThemeUI, Close } from "theme-ui";
|
||||||
|
|
||||||
function Banner({ isOpen, onRequestClose, children }) {
|
function Banner({ isOpen, onRequestClose, children, allowClose }) {
|
||||||
const { theme } = useThemeUI();
|
const { theme } = useThemeUI();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -15,7 +15,7 @@ function Banner({ isOpen, onRequestClose, children }) {
|
|||||||
backgroundColor: theme.colors.highlight,
|
backgroundColor: theme.colors.highlight,
|
||||||
top: "initial",
|
top: "initial",
|
||||||
left: "50%",
|
left: "50%",
|
||||||
right: 0,
|
right: "initial",
|
||||||
// Offset for iOS safe zone
|
// Offset for iOS safe zone
|
||||||
bottom: "env(safe-area-inset-bottom)",
|
bottom: "env(safe-area-inset-bottom)",
|
||||||
border: "none",
|
border: "none",
|
||||||
@ -28,13 +28,19 @@ function Banner({ isOpen, onRequestClose, children }) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
{allowClose && (
|
||||||
<Close
|
<Close
|
||||||
m={0}
|
m={0}
|
||||||
sx={{ position: "absolute", top: "4px", right: 0 }}
|
sx={{ position: "absolute", top: "4px", right: 0 }}
|
||||||
onClick={onRequestClose}
|
onClick={onRequestClose}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Banner.defaultProps = {
|
||||||
|
allowClose: true,
|
||||||
|
};
|
||||||
|
|
||||||
export default Banner;
|
export default Banner;
|
||||||
|
Loading…
Reference in New Issue
Block a user