Last active
November 1, 2018 15:39
-
-
Save LeeCheneler/212fd1539beb6ca06235953441354429 to your computer and use it in GitHub Desktop.
Flag using flex instead of table
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 React from 'react' | |
import Flag from './Flag' | |
const Consumer = () => ( | |
<Flag.Wrapper spacer="md"> | |
<Flag.Component>Component</Flag.Component> | |
<Flag.Body>Body</Flag.Body> | |
</Flag.Wrapper> | |
) |
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' | |
const spacers = { | |
xs: '0.25rem', | |
sm: '0.5rem', | |
md: '1rem', | |
lg: '1.5rem', | |
xl: '2rem' | |
} | |
const Wrapper = styled.div` | |
display: flex; | |
align-items: center; | |
${({ spacer }) => | |
spacer ? `& > :first-child { padding-right: ${spacers[spacer]}; }` : null}; | |
` | |
Wrapper.propTypes = { | |
spacer: T.oneOf(['xs', 'sm', 'md', 'lg']) | |
} | |
Wrapper.defaultProps = { | |
spacer: null | |
} | |
const Body = styled.div` | |
flex-grow: 1; | |
` | |
const Component = styled.div`` | |
export default { Wrapper, Body, Component } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment