Last active
June 25, 2018 08:16
-
-
Save drenther/4b44155fd28664bc31fd83613e96f8c3 to your computer and use it in GitHub Desktop.
Leveraging the power of props and css helper in styled-components
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
/* src/components/User.js */ | |
. | |
. | |
. | |
/* line 16 - 30 */ | |
const maleBorder = props => | |
props.gender === 'male' ? `solid 4px ${props.theme.color.primary}` : '0'; | |
const femaleBorder = props => | |
props.gender === 'female' ? `solid 4px ${props.theme.color.primary}` : '0'; | |
const Avatar = styled.img` | |
border-radius: 50%; | |
width: 60px; | |
height: 60px; | |
position: relative; | |
border-bottom: ${femaleBorder}; | |
border-left: ${femaleBorder}; | |
border-right: ${maleBorder}; | |
border-top: ${maleBorder}; | |
`; | |
. | |
. | |
. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment