Skip to content

Commit 0d6ceec

Browse files
giuseppegrauchg
authored andcommitted
Add styled-jsx-postcss example (#781)
* Add styled-jsx-postcss example * Remove commented code
1 parent 782807b commit 0d6ceec

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": [
3+
"next/babel"
4+
],
5+
"plugins": [
6+
"styled-jsx-postcss/babel"
7+
]
8+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# Example app with styled-jsx-postcss
3+
4+
This example features how you use PostCSS with styled-jsx via [styled-jsx-postcss](https://github.com/giuseppeg/styled-jsx-postcss)
5+
6+
## How to use
7+
8+
Download the example (or clone the repo)[https://github.com/zeit/next.js.git]:
9+
10+
```bash
11+
curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/with-styled-jsx-postcss
12+
cd with-styled-jsx-postcss
13+
```
14+
15+
Install it and run:
16+
17+
```bash
18+
npm install
19+
npm run dev
20+
```
21+
22+
Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))
23+
24+
```bash
25+
now
26+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "with-styled-jsx-postcss",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"dev": "next",
6+
"build": "next build",
7+
"start": "next start"
8+
},
9+
"dependencies": {
10+
"next": "^2.0.0-beta",
11+
"postcss-cssnext": "^2.9.0",
12+
"styled-jsx-postcss": "^0.1.5"
13+
},
14+
"author": "Giuseppe Gurgone",
15+
"license": "MIT"
16+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export default () => (
2+
<div className='hello'>
3+
<p>Hello World</p>
4+
<style jsx>{`
5+
:global(:root) {
6+
--bgColor: green;
7+
--color: white;
8+
}
9+
.hello {
10+
font: 15px Helvetica, Arial, sans-serif;
11+
background: var(--bgColor);
12+
color: var(--color);
13+
padding: 100px;
14+
text-align: center;
15+
transition: 100ms ease-in background;
16+
}
17+
.hello:hover {
18+
color: color(var(--color) blackness(+80%));
19+
}
20+
`}</style>
21+
</div>
22+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = () => ({
2+
plugins: {
3+
'postcss-cssnext': {}
4+
}
5+
})

0 commit comments

Comments
 (0)