Skip to content

Instantly share code, notes, and snippets.

@jepser
Created May 28, 2019 21:19
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 jepser/a35a93b859525f463f6c41cea19a31fc to your computer and use it in GitHub Desktop.
Save jepser/a35a93b859525f463f6c41cea19a31fc to your computer and use it in GitHub Desktop.
const Spacer = ({
top, left, bottom, right, children,
}) => {
return (
<Root
top={ top }
left={ left }
bottom={ bottom }
right={ right }
>
{children}
</Root>
);
};
// styled-components.js
const Root = styled.div`
$({
 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};
 `
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment