Skip to content

Commit 5fd51d8

Browse files
committed
Add example site for styled-jsx as well as some fixes to its plugin
1 parent a4855d2 commit 5fd51d8

File tree

9 files changed

+60
-0
lines changed

9 files changed

+60
-0
lines changed

examples/using-styled-jsx/.eslintrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"env": {
3+
"browser": true
4+
},
5+
"globals": {
6+
"graphql": false
7+
}
8+
}

examples/using-styled-jsx/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public
2+
.cache
3+
node_modules

examples/using-styled-jsx/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# using-styled-jsx
2+
3+
https://using-styled-jsx.gatsbyjs.org
4+
5+
Demonstrates using [styled-jsx](https://github.com/zeit/styled-jsx) with the Gatsby plugin [gatsby-plugin-styled-jsx](https://www.gatsbyjs.org/packages/gatsby-plugin-styled-jsx/) which automatically provides SSR support.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
plugins: [`gatsby-plugin-styled-jsx`],
3+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "using-styled-jsx",
3+
"private": true,
4+
"description": "Gatsby example site using using-styled-jsx",
5+
"author": "Kyle Mathews <[email protected]>",
6+
"dependencies": {
7+
"gatsby": "latest",
8+
"gatsby-link": "latest",
9+
"gatsby-plugin-styled-jsx": "^1.0.7"
10+
},
11+
"license": "MIT",
12+
"main": "n/a",
13+
"scripts": {
14+
"develop": "gatsby develop",
15+
"build": "gatsby build"
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from "react"
2+
3+
export default () => (
4+
<div>
5+
<p>only this paragraph will get the style :)</p>
6+
{/* you can include <Component />s here that include
7+
other <p>s that don't get unexpected styles! */}
8+
<style jsx>{`
9+
p {
10+
color: red;
11+
}
12+
`}</style>
13+
</div>
14+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*.js
2+
!index.js
3+
yarn.lock
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Add babel plugin
2+
exports.modifyBabelrc = ({ babelrc }) => {
3+
return {
4+
...babelrc,
5+
plugins: babelrc.plugins.concat([`styled-jsx/babel`]),
6+
}
7+
}

0 commit comments

Comments
 (0)