Skip to content

Commit ec0c3ea

Browse files
authored
Merge branch 'next' into fix/interactions-disable-parameter
2 parents 345e3cc + 3d9a2a5 commit ec0c3ea

18 files changed

Lines changed: 81 additions & 143 deletions

docs/_snippets/ghp-github-action.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ name: Build and Publish Storybook to GitHub Pages
33
on:
44
push:
55
branches:
6-
- "your-branch-name" # Use specific branch name
6+
- 'your-branch-name' # Use specific branch name
77
permissions:
88
contents: read
99
pages: write
1010
id-token: write
1111
concurrency:
12-
group: "pages"
12+
group: 'pages'
1313
cancel-in-progress: false
1414
jobs:
1515
deploy:
@@ -25,8 +25,8 @@ jobs:
2525
- name: Setup Node
2626
uses: actions/setup-node@v4
2727
with:
28-
node-version: "20"
29-
cache: "npm" # Adjust caching strategy and configuration if using other package managers
28+
node-version: '20'
29+
cache: 'npm' # Adjust caching strategy and configuration if using other package managers
3030
- name: Install dependencies
3131
run: npm ci # Replace with appropriate command if using other package managers
3232
- name: Build Storybook
@@ -35,7 +35,7 @@ jobs:
3535
- name: Upload Pages artifact
3636
uses: actions/upload-pages-artifact@v3
3737
with:
38-
path: "storybook-static"
38+
path: 'storybook-static'
3939
# Deploy to Github Pages
4040
- id: deploy
4141
name: Deploy to GitHub Pages

docs/_snippets/nextjs-styling-sass-config.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ export default {
1010
```
1111

1212
```ts filename="next.config.ts" language="ts" renderer="react"
13-
import * as path from 'path';
1413
import type { NextConfig } from 'next';
1514

15+
import * as path from 'node:path';
16+
1617
const config: NextConfig = {
1718
// Any options here are included in Sass compilation for your stories
1819
sassOptions: {

docs/_snippets/nextjs-styling-sass-preview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import '../styles/globals.scss';
44

55
```ts filename=".storybook/preview.ts" language="ts" renderer="react"
66
import '../styles/globals.scss';
7-
```
7+
```

docs/_snippets/nextjs-styling-styled-jsx-component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ function HelloWorld() {
6060
}
6161

6262
export default HelloWorld;
63-
```
63+
```

docs/_snippets/nextjs-styling-tailwind.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import '../app/globals.css';
44

55
```ts filename=".storybook/preview.ts" language="ts" renderer="react"
66
import '../app/globals.css';
7-
```
7+
```

docs/_snippets/react-native-web-vite-add-framework.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
```js filename=".storybook/main.js" renderer="react-native-web" language="js"
1+
```js filename=".storybook/main.js" renderer="react" language="js"
22
export default {
33
addons: [
44
'@storybook/addon-react-native-web', // 👈 Remove the addon
@@ -8,7 +8,7 @@ export default {
88
};
99
```
1010

11-
```ts filename=".storybook/main.ts" renderer="react-native-web" language="ts"
11+
```ts filename=".storybook/main.ts" renderer="react" language="ts"
1212
import type { StorybookConfig } from '@storybook/react-native-web-vite';
1313

1414
const config: StorybookConfig = {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
```shell renderer="react-native-web" language="js" packageManager="npm"
1+
```shell renderer="common" language="sh" packageManager="npm"
22
npm install --save-dev @storybook/react-native-web-vite vite
33
```
44

5-
```shell renderer="react-native-web" language="js" packageManager="pnpm"
5+
```shell renderer="common" language="sh" packageManager="pnpm"
66
pnpm add --save-dev @storybook/react-native-web-vite vite
77
```
88

9-
```shell renderer="react-native-web" language="js" packageManager="yarn"
9+
```shell renderer="common" language="sh" packageManager="yarn"
1010
yarn add --dev @storybook/react-native-web-vite vite
1111
```

docs/get-started/frameworks/angular.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To install Storybook in an existing Angular project, run this command in your pr
1414

1515
<CodeSnippets path="create-command.md" variant="new-users" copyEvent="CreateCommandCopy" />
1616

17-
You can then get started [writing stories](/docs/get-started/whats-a-story/), [running tests](/docs/writing-tests/) and [documenting your components](/docs/writing-docs/). For more control over the installation process, refer to the [installation guide](/docs/install/).
17+
You can then get started [writing stories](../whats-a-story.mdx), [running tests](../../writing-tests/index.mdx) and [documenting your components](../../writing-docs/index.mdx). For more control over the installation process, refer to the [installation guide](../install.mdx).
1818

1919
### Requirements
2020

@@ -46,7 +46,7 @@ You will find the output in the configured `outputDir` (default is `dist/storybo
4646

4747
## Configure
4848

49-
To make the most out of Storybook in your Angular project, you can set up Compodoc integration and Storybook [decorators](/docs/writing-stories/decorators/) based on your project needs.
49+
To make the most out of Storybook in your Angular project, you can set up Compodoc integration and Storybook [decorators](../../writing-stories/decorators.mdx) based on your project needs.
5050

5151
### Compodoc
5252

@@ -122,7 +122,7 @@ export default preview;
122122

123123
### Application-wide providers
124124

125-
If your component relies on application-wide providers, like the ones defined by [`BrowserAnimationsModule`](https://angular.dev/api/platform-browser/animations/BrowserAnimationsModule) or any other modules that use the forRoot pattern to provide a [`ModuleWithProviders`](https://angular.dev/api/core/ModuleWithProviders), you can apply the `applicationConfig` [decorator](../../writing-stories/decorators.mdx) to all stories for that component. This will provide them with the [bootstrapApplication function](https://angular.io/guide/standalone-components#configuring-dependency-injection), used to bootstrap the component in Storybook.
125+
If your component relies on application-wide providers, like the ones defined by [`BrowserAnimationsModule`](https://angular.dev/api/platform-browser/animations/BrowserAnimationsModule) or any other modules that use the forRoot pattern to provide a [`ModuleWithProviders`](https://angular.dev/api/core/ModuleWithProviders), you can apply the `applicationConfig` [decorator](../../writing-stories/decorators.mdx) to all stories for that component. This will provide them with the [bootstrapApplication function](https://angular.dev/api/platform-browser/bootstrapApplication), used to bootstrap the component in Storybook.
126126

127127
```ts title="ChipsModule.stories.ts"
128128
import { Meta, applicationConfig, StoryObj } from '@storybook/angular';
@@ -203,7 +203,6 @@ export const WithCustomProvider: Story = {
203203
};
204204
```
205205

206-
207206
## FAQ
208207

209208
### How do I manually install the Angular framework?

docs/get-started/frameworks/nextjs-vite.mdx

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ sidebar:
66
title: Next.js (Vite)
77
---
88

9-
Storybook for Next.js (Vite) is the **recommended** [framework](../../contribute/framework.mdx) for developing and testing UI components in isolation for [Next.js](https://nextjs.org/) applications. It uses [Vite](https://vitejs.dev/) for faster builds, better performance and [Storybook Testing](https://storybook.js.org/docs/writing-tests) support.
9+
Storybook for Next.js (Vite) is the **recommended** [framework](../../contribute/framework.mdx) for developing and testing UI components in isolation for [Next.js](https://nextjs.org/) applications. It uses [Vite](https://vitejs.dev/) for faster builds, better performance and [Storybook Testing](../../writing-tests/index.mdx) support.
1010

1111
## Install
1212

1313
To install Storybook in an existing Next.js project, run this command in your project's root directory:
1414

1515
<CodeSnippets path="create-command.md" variant="new-users" copyEvent="CreateCommandCopy" />
1616

17-
You can then get started [writing stories](/docs/get-started/whats-a-story/), [running tests](/docs/writing-tests/) and [documenting your components](/docs/writing-docs/). For more control over the installation process, refer to the [installation guide](/docs/install/).
18-
17+
You can then get started [writing stories](../whats-a-story.mdx), [running tests](../../writing-tests/index.mdx) and [documenting your components](../../writing-docs/index.mdx). For more control over the installation process, refer to the [installation guide](../install.mdx).
1918

2019
### Requirements
2120

@@ -56,9 +55,6 @@ To build Storybook, run:
5655

5756
You will find the output in the configured `outputDir` (default is `storybook-static`).
5857

59-
60-
61-
6258
## Configure
6359

6460
Storybook for Next.js with Vite supports many Next.js features including:
@@ -410,54 +406,60 @@ const preview: Preview = {
410406

411407
[`next/head`](https://nextjs.org/docs/pages/api-reference/components/head) is supported out of the box. You can use it in your stories like you would in your Next.js application. Please keep in mind, that the Head `children` are placed into the head element of the iframe that Storybook uses to render your stories.
412408

413-
### Styling
414409

415-
#### Sass/Scss
410+
## Next.js styling
416411

417-
[Global Sass/Scss stylesheets](https://nextjs.org/docs/pages/building-your-application/styling/sass) are supported without any additional configuration as well. Just import them into [`.storybook/preview.js|ts`](../../configure/index.mdx#configure-story-rendering)
412+
### Sass/Scss
418413

419-
```js title=".storybook/preview.js|ts"
420-
import '../styles/globals.scss';
421-
```
414+
[Global Sass/SCSS stylesheets](https://nextjs.org/docs/pages/building-your-application/styling/sass) are also supported without any additional configuration. Just import them into [the preview config file](../../configure/index.mdx#configure-story-rendering).
422415

423-
This will automatically include any of your [custom Sass configurations](https://nextjs.org/docs/pages/building-your-application/styling/sass#customizing-sass-options) in your `next.config.js` file.
416+
{/* prettier-ignore-start */}
424417

425-
```js title="next.config.js"
426-
import * as path from 'path';
418+
<CodeSnippets path="nextjs-styling-sass-preview.md" />
427419

428-
export default {
429-
// Any options here are included in Sass compilation for your stories
430-
sassOptions: {
431-
includePaths: [path.join(process.cwd(), 'styles')],
432-
},
433-
};
434-
```
420+
{/* prettier-ignore-end */}
421+
422+
This will automatically include any of your [custom Sass configurations](https://nextjs.org/docs/pages/building-your-application/styling/sass#customizing-sass-options) in your Next.js config file.
435423

436-
#### CSS/Sass/Scss Modules
424+
{/* prettier-ignore-start */}
425+
426+
<CodeSnippets path="nextjs-styling-sass-config.md" />
427+
428+
{/* prettier-ignore-end */}
429+
430+
### CSS/Sass/Scss Modules
437431

438432
[CSS modules](https://nextjs.org/docs/pages/building-your-application/styling/css-modules) work as expected.
439433

440-
```jsx title="src/components/Button.jsx"
441-
// This import will work in Storybook
442-
import styles from './Button.module.css';
443-
// Sass/Scss is also supported
444-
// import styles from './Button.module.scss'
445-
// import styles from './Button.module.sass'
434+
{/* prettier-ignore-start */}
446435

447-
export function Button() {
448-
return (
449-
<button type="button" className={styles.error}>
450-
Destroy
451-
</button>
452-
);
453-
}
454-
```
436+
<CodeSnippets path="nextjs-styling-css-modules.md" />
437+
438+
{/* prettier-ignore-end */}
455439

456-
#### PostCSS
440+
### Styled JSX
457441

458-
Next.js lets you [customize PostCSS config](https://nextjs.org/docs/pages/building-your-application/configuring/post-css). Thus this framework will automatically handle your PostCSS config for you.
442+
The built-in CSS-in-JS solution for Next.js is [styled-jsx](https://nextjs.org/docs/pages/building-your-application/styling/css-in-js), and this framework supports that out of the box, too, with zero config.
443+
444+
{/* prettier-ignore-start */}
445+
446+
<CodeSnippets path="nextjs-styling-styled-jsx-component.md" />
447+
448+
{/* prettier-ignore-end */}
449+
450+
### Tailwind
459451

460-
This allows for cool things like zero-config Tailwind! (See [Next.js' example](https://github.com/vercel/next.js/tree/canary/packages/create-next-app/templates/default-tw))
452+
Tailwind in Next.js [is supported via PostCSS](https://nextjs.org/docs/app/getting-started/css#tailwind-css). Storybook will automatically handle the PostCSS config for you, including any custom PostCSS configuration, so that you can import your global CSS directly into [the preview config file](../../configure/index.mdx#configure-story-rendering):
453+
454+
{/* prettier-ignore-start */}
455+
456+
<CodeSnippets path="nextjs-styling-tailwind.md" />
457+
458+
{/* prettier-ignore-end */}
459+
460+
### PostCSS
461+
462+
Next.js lets you [customize PostCSS config](https://nextjs.org/docs/pages/building-your-application/configuring/post-css). Thus this framework will automatically handle your PostCSS config for you.
461463

462464
### Imports
463465
#### Absolute imports
@@ -638,7 +640,7 @@ To enable this set the `experimentalRSC` feature flag in your `.storybook/main.j
638640

639641
Setting this flag automatically wraps your story in a [Suspense](https://react.dev/reference/react/Suspense) wrapper, which is able to render asynchronous components in NextJS's version of React.
640642

641-
If this wrapper causes problems in any of your existing stories, you can selectively disable it using the `react.rsc` [parameter](https://storybook.js.org/docs/writing-stories/parameters) at the global/component/story level:
643+
If this wrapper causes problems in any of your existing stories, you can selectively disable it using the `react.rsc` [parameter](../../writing-stories/parameters.mdx) at the global/component/story level:
642644

643645
{/* prettier-ignore-start */}
644646

@@ -654,7 +656,6 @@ In the future we will provide better mocking support in Storybook and support fo
654656

655657
## FAQ
656658

657-
658659
### How do I migrate from the `nextjs` (Webpack 5) addon?
659660

660661
#### Automatic migration
@@ -673,7 +674,7 @@ This automigration tool performs the following actions:
673674

674675
<Callout variant="info">
675676

676-
If your project has custom Webpack configurations in `.storybook/main.js|ts` (via `webpackFinal`), you'll need to migrate those to Vite configuration (via `viteFinal`) after running this automigration. See the [Vite builder documentation](../builders/vite.mdx#migrating-from-webpack) for more information.
677+
If your project has custom Webpack configurations in `.storybook/main.js|ts` (via `webpackFinal`), you'll need to migrate those to Vite configuration (via `viteFinal`) after running this automigration. See the [Vite builder documentation](../../builders/vite.mdx#migrating-from-webpack) for more information.
677678

678679
</Callout>
679680

@@ -711,8 +712,6 @@ Finally, if you were using Storybook plugins to integrate with Next.js, those ar
711712

712713
{/* prettier-ignore-end */}
713714

714-
715-
716715
### Stories for pages/components which fetch data
717716

718717
Next.js pages can fetch data directly within server components in the `app` directory, which often include module imports that only run in a node environment. This does not (currently) work within Storybook, because if you import from a Next.js page file containing those node module imports in your stories, your Storybook's Vite build will crash because those modules will not run in a browser. To get around this, you can extract the component in your page file into a separate file and import that pure component in your stories. Or, if that's not feasible for some reason, you can [configure Vite to handle those modules](https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude) in your Storybook's [`viteFinal` configuration](../../builders/vite.mdx#configuration).

docs/get-started/frameworks/nextjs.mdx

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ sidebar:
88

99
Storybook for Next.js (Webpack) is a [framework](../../contribute/framework.mdx) that makes it easy to develop and test UI components in isolation for [Next.js](https://nextjs.org/) applications using [Webpack 5](https://webpack.js.org/).
1010

11-
1211
<Callout variant="info">
1312

1413
**We recommend using [`@storybook/nextjs-vite`](./nextjs-vite.mdx)** for most Next.js projects. The Vite-based framework is faster, more modern, and offers better support for testing features.
@@ -27,8 +26,7 @@ To install Storybook in an existing Next.js project, run this command in your pr
2726

2827
The command will prompt you to choose between this framework and [`@storybook/nextjs-vite`](./nextjs-vite.mdx). We recommend the Vite-based framework ([learn why](./nextjs-vite.mdx#choose-between-vite-and-webpack)).
2928

30-
You can then get started [writing stories](/docs/get-started/whats-a-story/), [running tests](/docs/writing-tests/) and [documenting your components](/docs/writing-docs/). For more control over the installation process, refer to the [installation guide](/docs/install/).
31-
29+
You can then get started [writing stories](../whats-a-story.mdx), [running tests](../../writing-tests/index.mdx) and [documenting your components](../../writing-docs/index.mdx). For more control over the installation process, refer to the [installation guide](../install.mdx).
3230

3331
### Requirements
3432

@@ -54,9 +52,6 @@ To build Storybook, run:
5452

5553
You will find the output in the configured `outputDir` (default is `storybook-static`).
5654

57-
58-
59-
6055
## Configure
6156

6257
Storybook for Next.js with Vite supports many Next.js features including:
@@ -70,16 +65,6 @@ Storybook for Next.js with Vite supports many Next.js features including:
7065
* 🎭 [Module mocking](#mocking-modules)
7166
* ☁️ [React Server Component (experimental)](#react-server-components-rsc)
7267

73-
74-
75-
76-
77-
78-
79-
80-
81-
82-
8368
### Next.js's Image component
8469

8570
This framework allows you to use Next.js's [next/image](https://nextjs.org/docs/pages/api-reference/components/image) with no configuration.
@@ -420,7 +405,7 @@ const preview: Preview = {
420405

421406
### Sass/Scss
422407

423-
[Global Sass/Scss stylesheets](https://nextjs.org/docs/pages/building-your-application/styling/sass) are supported without any additional configuration as well. Just import them into [the preview config file](../../configure/index.mdx#configure-story-rendering)
408+
[Global Sass/SCSS stylesheets](https://nextjs.org/docs/pages/building-your-application/styling/sass) are also supported without any additional configuration. Just import them into [the preview config file](../../configure/index.mdx#configure-story-rendering).
424409

425410
{/* prettier-ignore-start */}
426411

@@ -448,15 +433,15 @@ This will automatically include any of your [custom Sass configurations](https:/
448433

449434
### Styled JSX
450435

451-
The built in CSS-in-JS solution for Next.js is [styled-jsx](https://nextjs.org/docs/pages/building-your-application/styling/css-in-js), and this framework supports that out of the box too, zero config.
436+
The built-in CSS-in-JS solution for Next.js is [styled-jsx](https://nextjs.org/docs/pages/building-your-application/styling/css-in-js), and this framework supports that out of the box, too, with zero config.
452437

453438
{/* prettier-ignore-start */}
454439

455440
<CodeSnippets path="nextjs-styling-styled-jsx-component.md" />
456441

457442
{/* prettier-ignore-end */}
458443

459-
You can use your own babel config too. This is an example of how you can customize styled-jsx.
444+
You can use your own Babel config, too. This is an example of how you can customize styled-jsx.
460445

461446
```jsonc
462447
// .babelrc (or whatever config file you use)
@@ -476,8 +461,7 @@ You can use your own babel config too. This is an example of how you can customi
476461

477462
### Tailwind
478463

479-
Tailwind in Next.js [is supported via PostCSS](https://nextjs.org/docs/app/getting-started/css#tailwind-css). Storybook will automatically handle the PostCSS config for you, including any custom PostCSS configuration,
480-
so you can just import your global CSS directly into [the preview config file](../../configure/index.mdx#configure-story-rendering):
464+
Tailwind in Next.js [is supported via PostCSS](https://nextjs.org/docs/app/getting-started/css#tailwind-css). Storybook will automatically handle the PostCSS config for you, including any custom PostCSS configuration, so that you can import your global CSS directly into [the preview config file](../../configure/index.mdx#configure-story-rendering):
481465

482466
{/* prettier-ignore-start */}
483467

@@ -674,7 +658,7 @@ To enable this set the `experimentalRSC` feature flag in your `.storybook/main.j
674658

675659
Setting this flag automatically wraps your story in a [Suspense](https://react.dev/reference/react/Suspense) wrapper, which is able to render asynchronous components in NextJS's version of React.
676660

677-
If this wrapper causes problems in any of your existing stories, you can selectively disable it using the `react.rsc` [parameter](https://storybook.js.org/docs/writing-stories/parameters) at the global/component/story level:
661+
If this wrapper causes problems in any of your existing stories, you can selectively disable it using the `react.rsc` [parameter](../../writing-stories/parameters.mdx) at the global/component/story level:
678662

679663
{/* prettier-ignore-start */}
680664

0 commit comments

Comments
 (0)