Skip to content

Instantly share code, notes, and snippets.

@browniefed
Last active June 2, 2018 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save browniefed/d980328dd998cfa24224ba4188b2d6ce to your computer and use it in GitHub Desktop.
Save browniefed/d980328dd998cfa24224ba4188b2d6ce to your computer and use it in GitHub Desktop.
import React from "react";
import ReactModal from "react-modal";
import styled from "react-emotion";
export interface ModalProps {
open: boolean;
contentLabel?: string;
onClose: Function;
}
const Wrap = styled.div({
padding: "8px"
});
const Header = styled.div({
position: "relative",
paddingTop: "25px"
});
const Close = styled.img({
position: "absolute",
top: "0px",
right: "0px",
cursor: "pointer"
});
const CloseButton = styled.button({
outline: "none",
border: "none"
});
const Modal: React.StatelessComponent<ModalProps> = ({
open,
contentLabel,
children,
onClose
}) => {
// It complains about the onClick={onClose} :(
return (
<ReactModal isOpen={open} contentLabel={contentLabel}>
<Wrap>
<Header>
<CloseButton onClick={onClose}>
<Close src="/static/close.svg" />
</CloseButton>
</Header>
{children}
</Wrap>
</ReactModal>
);
};
export default Modal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment