Skip to content

Instantly share code, notes, and snippets.

@pozylon
Created April 23, 2018 14:38
Show Gist options
  • Save pozylon/5a77548554ea89f63206bd92c3c79b75 to your computer and use it in GitHub Desktop.
Save pozylon/5a77548554ea89f63206bd92c3c79b75 to your computer and use it in GitHub Desktop.
Styled JSX magic
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