Last active
May 28, 2019 21:25
-
-
Save jepser/6bfd5205a46fc541607845e250cc3da5 to your computer and use it in GitHub Desktop.
This file contains 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
const Spacer = ({ | |
top, left, bottom, right, children, sm, md, lg, xl, | |
}) => { | |
return ( | |
<Root | |
top={ top } | |
left={ left } | |
bottom={ bottom } | |
right={ right } | |
sm={sm} | |
md={md} | |
lg={lg} | |
xl={xl} | |
> | |
{children} | |
</Root> | |
); | |
}; | |
// styled-components.js | |
const baseStyles = ({ top, left, right, bottom }) => css` | |
margin-top: ${top ? unitizedPx(top) : null}; | |
margin-right: ${right ? unitizedPx(right) : null}; | |
margin-bottom: ${bottom ? unitizedPx(bottom) : null}; | |
margin-left: ${left ? unitizedPx(left) : null}; | |
`; | |
export const Root = styled.div` | |
${({ top, left, right, bottom, sm, md, lg, xl }) => ` | |
${baseStyles({ top, left, right, bottom })} | |
${sm && baseStyles(sm)} | |
${md && baseStyles(md)} | |
${lg && baseStyles(lg)} | |
${xl && baseStyles(xl)} | |
`} | |
`; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment