Skip to content

Add styled-jsx-postcss example #781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/with-styled-jsx-postcss/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": [
"next/babel"
],
"plugins": [
"styled-jsx-postcss/babel"
]
}
26 changes: 26 additions & 0 deletions examples/with-styled-jsx-postcss/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# Example app with styled-jsx-postcss

This example features how you use PostCSS with styled-jsx via [styled-jsx-postcss](https://github.com/giuseppeg/styled-jsx-postcss)

## How to use

Download the example (or clone the repo)[https://github.com/zeit/next.js.git]:

```bash
curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/with-styled-jsx-postcss
cd with-styled-jsx-postcss
```

Install it and run:

```bash
npm install
npm run dev
```

Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))

```bash
now
```
16 changes: 16 additions & 0 deletions examples/with-styled-jsx-postcss/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "with-styled-jsx-postcss",
"version": "1.0.0",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "^2.0.0-beta",
"postcss-cssnext": "^2.9.0",
"styled-jsx-postcss": "^0.1.5"
},
"author": "Giuseppe Gurgone",
"license": "MIT"
}
22 changes: 22 additions & 0 deletions examples/with-styled-jsx-postcss/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default () => (
<div className='hello'>
<p>Hello World</p>
<style jsx>{`
:global(:root) {
--bgColor: green;
--color: white;
}
.hello {
font: 15px Helvetica, Arial, sans-serif;
background: var(--bgColor);
color: var(--color);
padding: 100px;
text-align: center;
transition: 100ms ease-in background;
}
.hello:hover {
color: color(var(--color) blackness(+80%));
}
`}</style>
</div>
)
5 changes: 5 additions & 0 deletions examples/with-styled-jsx-postcss/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = () => ({
plugins: {
'postcss-cssnext': {}
}
})