Created
April 23, 2018 14:38
-
-
Save pozylon/5a77548554ea89f63206bd92c3c79b75 to your computer and use it in GitHub Desktop.
Styled JSX magic
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 connectApollo from '../lib/connectApollo'; | |
import withRegion from '../lib/withRegion'; | |
const InnerComponent = props => ( | |
<div {...props}> | |
<p>Hello World</p> | |
<style jsx>{` | |
p { | |
color: blue; | |
} | |
@media only screen and (min-width: ${props.min}) { | |
[color] { | |
background-color: ${props.color}; | |
} | |
} | |
`} | |
</style> | |
</div> | |
); | |
const Home = ({ className }) => ( | |
<div className={className}> | |
<div className="outer-context"> | |
<InnerComponent color="blue" min="768px" /> | |
</div> | |
<style jsx>{` | |
.outer-context { | |
background-color: black | |
} | |
`} | |
</style> | |
</div> | |
); | |
export default connectApollo(withRegion('home')(Home)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment