Last active
August 28, 2019 13:47
-
-
Save SebastianHGonzalez/2c109989c0a08f0ec825017c91e3e777 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function mobile(string) { | |
return `@media (max-width: 767px) {${string}}` | |
} | |
export function desktop(string) { | |
return `@media (min-width: 767px) {${string}}` | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import styled from "styled-components"; | |
import Modal from "react-modal"; | |
import { desktop, mobile } from "styled/media"; | |
const StyledModal = styled(Modal)` | |
${mobile` | |
position: absolute; | |
top: 0; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
`} | |
${desktop` | |
position: relative; | |
top: 10%; | |
width: fit-content; | |
margin: auto; | |
`} | |
border: 1px solid ${({ theme }) => theme.table.separator}; | |
background: white; | |
border-radius: 4px; | |
outline: none; | |
outline-color: initial; | |
outline-style: none; | |
outline-width: initial; | |
padding: 2rem; | |
display: grid; | |
grid-gap: 1rem; | |
grid-template-areas: "head" "body" "actions"; | |
grid-template-rows: min-content minmax(5rem, 1fr) min-content; | |
`; | |
StyledModal.defaultProps = { | |
shouldCloseOnOverlayClick: true, | |
shouldCloseOnEsc: true, | |
shouldReturnFocusAfterClose: true, | |
role: "dialog" | |
}; | |
export const ModalHead = styled.div` | |
grid-area: head; | |
border-bottom: 1px solid ${({ theme }) => theme.table.separator}; | |
padding-bottom: 1.5rem; | |
`; | |
export const ModalBody = styled.div` | |
grid-area: body; | |
overflow: auto; | |
`; | |
export const ModalActions = styled.div` | |
grid-area: actions; | |
${mobile` | |
display: grid; | |
grid-gap: 1rem; | |
`} | |
${desktop` | |
display: flex; | |
justify-content: flex-end; | |
align-items: center; | |
& > * { | |
margin-left: 1rem; | |
} | |
`} | |
`; | |
export default StyledModal; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment