Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #5 from RyanClementsHax/support-next-9-to-12
Browse files Browse the repository at this point in the history
Support next 9 to 12
  • Loading branch information
RyanClementsHax authored Jan 26, 2022
2 parents ccacd0b + 4894a99 commit 4180508
Show file tree
Hide file tree
Showing 173 changed files with 51,792 additions and 1,451 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ jobs:
- name: restore dependencies
uses: bahmutov/npm-install@v1
- run: yarn lint:all
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: restore dependencies
uses: bahmutov/npm-install@v1
- run: yarn test
type_check:
name: type check
runs-on: ubuntu-latest
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@
## Required Versions

- [Storybook](https://storybook.js.org/) >= 6.x
- [Next.js](https://nextjs.org/) >= 12.x
- [Next.js](https://nextjs.org/) >= 9.x

## Examples

- Nextjs v12 - [Source](./examples/nextv12/README.md)
- Tailwindcss - [Source](./examples/with-tailwindcss/README.md)
- Nextjs v11.1 - [Source](./examples/nextv11_1/README.md)
- Nextjs v11.0 - [Source](./examples/nextv11_0/README.md)
- Nextjs v10 - [Source](./examples/nextv10/README.md)
- Nextjs v9 - [Source](./examples/nextv9/README.md)

## Getting Started

Expand Down Expand Up @@ -105,7 +109,7 @@ If something doesn't work as you would expect, feel free to [open up an issue](h

#### Local Images

[Local images](https://nextjs.org/docs/basic-features/image-optimization#local-images) work just fine with this addon!
[Local images](https://nextjs.org/docs/basic-features/image-optimization#local-images) work just fine with this addon! Keep in mind that this feature was [only added in Next.js v11](https://nextjs.org/blog/next-11#automatic-size-detection-local-images).

```js
import Image from 'next/image'
Expand Down
3 changes: 3 additions & 0 deletions examples/nextv10/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "plugin:storybook/recommended"]
}
37 changes: 37 additions & 0 deletions examples/nextv10/.gitignore
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

# storybook
storybook-static
15 changes: 15 additions & 0 deletions examples/nextv10/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
stories: [
'../stories/**/*.stories.mdx',
'../stories/**/*.stories.@(js|jsx|ts|tsx)'
],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'storybook-addon-next'
],
framework: '@storybook/react',
core: {
builder: 'webpack5'
}
}
17 changes: 17 additions & 0 deletions examples/nextv10/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import '../styles/globals.css'
import '../styles/globals.scss'

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/
}
},
nextRouter: {
query: {
foo: 'this-is-a-global-override'
}
}
}
36 changes: 36 additions & 0 deletions examples/nextv10/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Nextjs v10 Example

This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.

[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.

The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
33 changes: 33 additions & 0 deletions examples/nextv10/components/Links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Link from 'next/link'

export const Links = () => (
<ul>
<li>
<Link href="/">Home</Link>
</li>
<li>
<Link href="/nextjsRouting">Next.js Routing Example</Link>
</li>
<li>
<Link href="/nextjsImages">Next.js Images Example</Link>
</li>
<li>
<Link href="/globalStyleImports">Global Style Imports Example</Link>
</li>
<li>
<Link href="/cssModules">Css Module Example</Link>
</li>
<li>
<Link href="/scssModules">Scss Module Example</Link>
</li>
<li>
<Link href="/styledJsx">Styled JSX Example</Link>
</li>
<li>
<Link href="/absoluteImports">Absolute Import Example</Link>
</li>
<li>
<Link href="/typescript">Typescript Example</Link>
</li>
</ul>
)
2 changes: 2 additions & 0 deletions examples/nextv10/components/MyComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/** @type {import('react').FC} */
export const MyComponent = ({ children }) => <div>{children}</div>
2 changes: 2 additions & 0 deletions examples/nextv10/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
3 changes: 3 additions & 0 deletions examples/nextv10/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
reactStrictMode: true
}
32 changes: 32 additions & 0 deletions examples/nextv10/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "nextv10",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"storybook": "start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public"
},
"dependencies": {
"next": "^10.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"sass": "^1.49.0"
},
"devDependencies": {
"@babel/core": "^7.16.7",
"@storybook/addon-actions": "^6.4.9",
"@storybook/addon-essentials": "^6.4.9",
"@storybook/addon-links": "^6.4.9",
"@storybook/builder-webpack5": "^6.4.9",
"@storybook/manager-webpack5": "^6.4.9",
"@storybook/react": "^6.4.9",
"babel-loader": "^8.2.3",
"eslint": "8.6.0",
"eslint-config-next": "12.0.7",
"eslint-plugin-storybook": "^0.5.5",
"storybook-addon-next": "link:../../"
}
}
9 changes: 9 additions & 0 deletions examples/nextv10/pages/_app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import '../styles/globals.css'
import '../styles/globals.scss'

/** @param {import('next/app').AppProps} props */
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}

export default MyApp
19 changes: 19 additions & 0 deletions examples/nextv10/pages/absoluteImports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Links } from 'components/Links'
import { MyComponent } from 'components/MyComponent'
import Head from 'next/head'

export default function AbsoluteImports() {
return (
<div>
<Head>
<title>Absolute Imports</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<Links />
<main>
This uses an absolute import:{' '}
<MyComponent>Im absolutely imported</MyComponent>
</main>
</div>
)
}
18 changes: 18 additions & 0 deletions examples/nextv10/pages/cssModules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Links } from 'components/Links'
import Head from 'next/head'
import styles from '../styles/CssModules.module.css'

export default function CssModules() {
return (
<div>
<Head>
<title>CSS Modules</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<Links />
<main className={styles.main}>
<span>This is styled using CSS Modules</span>
</main>
</div>
)
}
19 changes: 19 additions & 0 deletions examples/nextv10/pages/globalStyleImports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Links } from 'components/Links'
import Head from 'next/head'

export default function CssModules() {
return (
<div>
<Head>
<title>Global style imports</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<Links />
<main>
The background of this page is set by "styles/globals.scss" and this
text size is set by "styles/globals.css". All global style imports need
to be done in ".storybook/preview.js" for storybook.
</main>
</div>
)
}
20 changes: 20 additions & 0 deletions examples/nextv10/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Links } from 'components/Links'
import Head from 'next/head'

export default function Home() {
return (
<div>
<Head>
<title>Storybook Addon Next</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main>
<h1>
Click on any one of these links to see supported features in action
</h1>
<Links />
</main>
</div>
)
}
19 changes: 19 additions & 0 deletions examples/nextv10/pages/nextjsImages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Links } from 'components/Links'
import Image from 'next/image'
import Head from 'next/head'

export default function NextjsImages() {
return (
<div>
<Head>
<title>Nextjs Images</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<Links />
<main>
<h2>This image uses a remote image</h2>
<Image src="/vercel.svg" alt="Vercel Logo" width={200} height={200} />
</main>
</div>
)
}
30 changes: 30 additions & 0 deletions examples/nextv10/pages/nextjsRouting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Links } from 'components/Links'
import Head from 'next/head'
import { useRouter } from 'next/router'

export default function NextjsRouting() {
const router = useRouter()
console.log('this is the router NextjsRouting received 👉', router)
return (
<div>
<Head>
<title>Nextjs Routing</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<Links />
<main>
<p>
Interact with any of the links and look at the "Actions" tab below (if
in storybook)
</p>
<p>
This is the router read by this page (functions not serialized; check
the console for the full object):
</p>
<pre>
<code>{JSON.stringify(router, null, 2)}</code>
</pre>
</main>
</div>
)
}
18 changes: 18 additions & 0 deletions examples/nextv10/pages/scssModules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Links } from 'components/Links'
import Head from 'next/head'
import styles from '../styles/ScssModules.module.scss'

export default function ScssModules() {
return (
<div>
<Head>
<title>SCSS Modules</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<Links />
<main className={styles.main}>
<span>This is styled using SCSS Modules</span>
</main>
</div>
)
}
Loading

0 comments on commit 4180508

Please sign in to comment.