-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into update/href-interpolation
- Loading branch information
Showing
22 changed files
with
385 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"presets": [ | ||
"next/babel" | ||
], | ||
"plugins": [ | ||
"babel-plugin-macros" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# cssed compilation artifacts | ||
.*.module.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Example app with cssed | ||
|
||
This example shows how to use [cssed](https://github.com/okotoki/cssed), a CSS-in-JS library, with Next.js. | ||
|
||
We are creating `div` element with local scoped styles. The styles includes the use of pseudo-selector. | ||
|
||
## Deploy your own | ||
|
||
Deploy the example using [Vercel](https://vercel.com): | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/vercel/next.js/tree/canary/examples/with-cssed) | ||
|
||
## How to use | ||
|
||
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example: | ||
|
||
```bash | ||
npx create-next-app --example with-cssed with-cssed-app | ||
# or | ||
yarn create next-app --example with-cssed with-cssed-app | ||
``` | ||
|
||
Deploy it to the cloud with [Vercel](https://vercel.com/import?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const dark = '#333' | ||
export const light = '#ddd' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "with-cssed", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"dev": "next", | ||
"build": "next build", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"@types/react": "^16.9.48", | ||
"babel-plugin-macros": "^2.8.0", | ||
"cssed": "^1.1.2", | ||
"next": "latest", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1" | ||
}, | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { css } from 'cssed/macro' | ||
import Head from 'next/head' | ||
import { useState } from 'react' | ||
|
||
import { dark, light } from '../lib/theme' | ||
|
||
const styles = css` | ||
.box { | ||
height: 200px; | ||
width: 200px; | ||
margin: 0 auto; | ||
margin-top: 40px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
.dark { | ||
background-color: ${dark}; | ||
} | ||
.dark::before { | ||
content: '🌚'; | ||
} | ||
.light { | ||
background-color: ${light}; | ||
} | ||
.light::before { | ||
content: '🌞'; | ||
} | ||
` | ||
|
||
export default function Home() { | ||
const [isDark, setDark] = useState(false) | ||
return ( | ||
<> | ||
<Head> | ||
<title>With cssed</title> | ||
</Head> | ||
<div | ||
onClick={() => setDark(!isDark)} | ||
className={styles.box + ' ' + (isDark ? styles.dark : styles.light)} | ||
> | ||
Cssed demo | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/integration/trailing-slashes-href-resolving/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
trailingSlash: true, | ||
} |
3 changes: 3 additions & 0 deletions
3
test/integration/trailing-slashes-href-resolving/pages/404.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function NotFound() { | ||
return <div id="page-404">404</div> | ||
} |
11 changes: 11 additions & 0 deletions
11
test/integration/trailing-slashes-href-resolving/pages/[slug].js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useRouter } from 'next/router' | ||
|
||
export default function Page() { | ||
const router = useRouter() | ||
|
||
return ( | ||
<> | ||
<p id="slug">top level slug {router.query.slug}</p> | ||
</> | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
test/integration/trailing-slashes-href-resolving/pages/another.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Page() { | ||
return ( | ||
<> | ||
<p id="another">top level another</p> | ||
</> | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
test/integration/trailing-slashes-href-resolving/pages/blog/[slug].js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useRouter } from 'next/router' | ||
|
||
export default function Page() { | ||
const router = useRouter() | ||
|
||
return ( | ||
<> | ||
<p id="slug">blog slug {router.query.slug}</p> | ||
</> | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
test/integration/trailing-slashes-href-resolving/pages/blog/another.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Page() { | ||
return ( | ||
<> | ||
<p id="another">blog another</p> | ||
</> | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
test/integration/trailing-slashes-href-resolving/pages/catch-all/[...slug].js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useRouter } from 'next/router' | ||
|
||
export default function Page() { | ||
const router = useRouter() | ||
|
||
return ( | ||
<> | ||
<p id="slug">catch-all slug {router.query.slug?.join('/')}</p> | ||
</> | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
test/integration/trailing-slashes-href-resolving/pages/catch-all/first.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Page() { | ||
return ( | ||
<> | ||
<p id="first">catch-all first</p> | ||
</> | ||
) | ||
} |
32 changes: 32 additions & 0 deletions
32
test/integration/trailing-slashes-href-resolving/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Index() { | ||
return ( | ||
<> | ||
<Link href="/blog/another/"> | ||
<a id="to-blog-another">to /blog/another/</a> | ||
</Link> | ||
<br /> | ||
<Link href="/blog/first-post/"> | ||
<a id="to-blog-post">to /blog/first-post/</a> | ||
</Link> | ||
<br /> | ||
<Link href="/catch-all/hello/world/"> | ||
<a id="to-catch-all-item">to /catch-all/hello/world/</a> | ||
</Link> | ||
<br /> | ||
<Link href="/catch-all/first/"> | ||
<a id="to-catch-all-first">to /catch-all/first/</a> | ||
</Link> | ||
<br /> | ||
<Link href="/another/"> | ||
<a id="to-another">to /another/</a> | ||
</Link> | ||
<br /> | ||
<Link href="/top-level-slug/"> | ||
<a id="to-slug">to /top-level-slug/</a> | ||
</Link> | ||
<br /> | ||
</> | ||
) | ||
} |
Oops, something went wrong.