Unverified Commit 4e5a359a authored by Turadg Aleahmad's avatar Turadg Aleahmad Committed by GitHub

update with-linaria example (#23332)

## Documentation / Examples

* removes deprecated `@zeit/next-css`.
* adds https://github.com/Mistereo/next-linaria to work with the new built-in CSS functionality.
* updates Linaria to latest release (v3 will require https://github.com/Mistereo/next-linaria/pull/3 ) 
* adds an example of using Linaria without React
* gitignores `.linaria-cache`
parent f28ea89a
...@@ -32,3 +32,6 @@ yarn-error.log* ...@@ -32,3 +32,6 @@ yarn-error.log*
# vercel # vercel
.vercel .vercel
# Linaria
.linaria-cache/
const withCSS = require('@zeit/next-css') const withLinaria = require('next-linaria')
module.exports = withCSS({ module.exports = withLinaria({})
webpack(config, options) {
config.module.rules.push({
test: /\.js$/,
use: [
{
loader: 'linaria/loader',
options: {
sourceMap: process.env.NODE_ENV !== 'production',
},
},
],
})
return config
},
})
...@@ -7,11 +7,14 @@ ...@@ -7,11 +7,14 @@
"start": "next start" "start": "next start"
}, },
"dependencies": { "dependencies": {
"@zeit/next-css": "^1.0.1", "linaria": "^2.1.0",
"linaria": "2.0.0-alpha.5",
"next": "latest", "next": "latest",
"next-linaria": "^0.10.0",
"react": "^16.13.1", "react": "^16.13.1",
"react-dom": "^16.13.1" "react-dom": "^16.13.1"
}, },
"devDependencies": {
"@babel/core": "^7.13.10"
},
"license": "MIT" "license": "MIT"
} }
import Head from 'next/head' import Head from 'next/head'
import { styled } from 'linaria/react' import { styled } from 'linaria/react'
import { css } from 'linaria'
const Box = styled.div` const Box = styled.div`
margin-top: 40px; margin-top: 40px;
...@@ -20,13 +21,17 @@ const Box = styled.div` ...@@ -20,13 +21,17 @@ const Box = styled.div`
} }
` `
const anotherClass = css`
color: blue;
`
export default function Home() { export default function Home() {
return ( return (
<> <>
<Head> <Head>
<title>With Linaria</title> <title>With Linaria</title>
</Head> </Head>
<Box>Zero runtime CSS in JS</Box> <Box className={anotherClass}>Zero runtime CSS in JS</Box>
</> </>
) )
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment