Created
September 4, 2017 20:03
-
-
Save RafalFilipek/f2a02e95b4c6501ae72509adf09036db 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
| import { css } from 'emotion'; | |
| import styled from 'react-emotion'; | |
| const box = props => css` | |
| composes: | |
| ${display(props)} | |
| ${flex(props)} | |
| ${direction(props)} | |
| ${alignItems(props)} | |
| ${alignSelf(props)} | |
| ${justifyContent(props)} | |
| ${alignContent(props)} | |
| ${margin(props)} | |
| ${padding(props)};`; | |
| export const Box = ({ as, ...props }) => { | |
| const Component = styled(as)`${box};`; | |
| return <Component {...props} />; | |
| }; |
const box = props => css`
${display(props)}
${flex(props)}
${direction(props)}
${alignItems(props)}
${alignSelf(props)}
${justifyContent(props)}
${alignContent(props)}
${margin(props)}
${padding(props)};`;
const createBox = (tag) => styled(tag)`${box}`
const A = createBox('a')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would not create a new styled component on every render. I would do something like this.