Skip to content

Instantly share code, notes, and snippets.

@nazifbara
Created May 10, 2021 10:23
Show Gist options
  • Select an option

  • Save nazifbara/88b725be833921b2c3490c6a4ec4ad6a to your computer and use it in GitHub Desktop.

Select an option

Save nazifbara/88b725be833921b2c3490c6a4ec4ad6a to your computer and use it in GitHub Desktop.
// src/modal.js
function ModalContent({ children, title, imageSrc }) {
const [isOpen, setIsOpen] = React.useContext(ModalContext);
return isOpen ? (
<Overlay onClick={() => setIsOpen(false)}>
<div
css={{...}}
onClick={(e) => e.stopPropagation()}
>
<div css={{...}}>
<h2 css={{..}}>
{title}
</h2>
<ModalCloseButton />
</div>
<div css={{...}}>{children}</div>
</div>
</Overlay>
) : null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment