mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Add styled-jsx-postcss example (#781)
* Add styled-jsx-postcss example * Remove commented code
This commit is contained in:
parent
782807bb8b
commit
0d6ceec8db
8
examples/with-styled-jsx-postcss/.babelrc
Normal file
8
examples/with-styled-jsx-postcss/.babelrc
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
"next/babel"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"styled-jsx-postcss/babel"
|
||||||
|
]
|
||||||
|
}
|
26
examples/with-styled-jsx-postcss/README.md
Normal file
26
examples/with-styled-jsx-postcss/README.md
Normal file
|
@ -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
examples/with-styled-jsx-postcss/package.json
Normal file
16
examples/with-styled-jsx-postcss/package.json
Normal file
|
@ -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
examples/with-styled-jsx-postcss/pages/index.js
Normal file
22
examples/with-styled-jsx-postcss/pages/index.js
Normal file
|
@ -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
examples/with-styled-jsx-postcss/postcss.config.js
Normal file
5
examples/with-styled-jsx-postcss/postcss.config.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
module.exports = () => ({
|
||||||
|
plugins: {
|
||||||
|
'postcss-cssnext': {}
|
||||||
|
}
|
||||||
|
})
|
Loading…
Reference in a new issue