Created
October 1, 2017 14:30
-
-
Save adamseckel/e15b083a574dfba5eb9fa088a88f1be1 to your computer and use it in GitHub Desktop.
Basic Flexbox Component with Emotion
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 'emotion/react'; | |
import {css} from 'emotion'; | |
const justifyMap = { | |
start: 'flex-start', | |
end: 'flex-end', | |
'space-between': 'space-between', | |
'space-around': 'space-around' | |
}; | |
const alignMap = { | |
start: 'flex-start', | |
end: 'flex-end', | |
'space-between': 'space-between', | |
'space-around': 'space-around', | |
stretch: 'stretch' | |
}; | |
export const box = css` | |
display: flex; | |
flex-direction: ${props => props.column ? 'column' : 'row'}; | |
justify-content: ${props => justifyMap[props.justify] || 'center'}; | |
align-items: ${props => alignMap[props.align] || 'center'}; | |
flex-wrap: ${props => props.wrap ? 'wrap' : ' no-wrap'}; | |
flex-grow: ${props => props.grow ? 1 : 0}; | |
`; | |
const Box = styled.div` | |
composes: ${box}; | |
`; | |
export const Row = styled(Box)` | |
flex-direction: row; | |
`; | |
export const Column = styled(Box)` | |
flex-direction: column; | |
`; | |
export default Box; |
can you please give me in tsx format ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
e.g.