Last active
May 5, 2017 03:11
-
-
Save oojr/50a51cbca796453a04ba2b1b2d11121d to your computer and use it in GitHub Desktop.
css-in-js example
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
class Post extends React.Component { | |
onSponsorPost(){ | |
if(this.props.post.type === 'sponsored'){ | |
return '#F9BF3B' //gold color | |
} | |
} | |
render(){ | |
// web | |
<div> | |
<div style={[styles.thumbnail, {backgroundColor: this.onSponsorPost()}]}> | |
</div> | |
// react native | |
<View> | |
<View style={[styles.thumbnail, {backgroundColor: this.onSponsorPost()}]}> | |
</View> | |
} | |
} | |
//next.js web framework | |
const styles = { | |
thumbnail: { | |
margin: 5, | |
padding: 5, | |
backgroundColor: '#91969A', //grey | |
borderRadius: 3, | |
minWidth: 66 | |
} | |
} | |
// react native | |
const styles = StyleSheet.create({ | |
thumbnail: { | |
margin: 5, | |
padding: 5, | |
backgroundColor: '#91969A', //grey | |
borderRadius: 3, | |
minWidth: 66 | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment