Skip to content

Commit

Permalink
Merge pull request #23246 from storybookjs/chore_docs_addon_changes
Browse files Browse the repository at this point in the history
Docs: Updates for the addon documentation
  • Loading branch information
jonniebigodes authored Jul 3, 2023
2 parents 47446f4 + c4356f4 commit e053703
Show file tree
Hide file tree
Showing 65 changed files with 1,318 additions and 353 deletions.
Binary file removed docs/addons/addon-final-stage-optimized.mp4
Binary file not shown.
Binary file added docs/addons/addon-kit-clone-repo.mp4
Binary file not shown.
10 changes: 7 additions & 3 deletions docs/addons/addon-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ Use this boilerplate code while writing your own preset addon.

<!-- prettier-ignore-end -->

<div class="aside">
Learn more about writing your own preset addon <a href="./writing-presets">here</a>.
</div>
## Learn more about the Storybook addon ecosystem

- Types of addons for other types of addons
- [Writing addons](./writing-addons.md) for the basics of addon development
- [Presets](./writing-presets.md) for preset development
- [Integration catalog](./integration-catalog.md) for requirements and available recipes
- [API reference](./addons-api.md) to learn about the available APIs
8 changes: 8 additions & 0 deletions docs/addons/addons-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,11 @@ Hook that allows you to retrieve or update a story's [`args`](../writing-stories
/>

<!-- prettier-ignore-end -->

## Learn more about the Storybook addon ecosystem

- [Types of addons](./addon-types.md) for other types of addons
- [Writing addons](./writing-addons.md) for the basics of addon development
- [Presets](./writing-presets.md) for preset development
- [Integration catalog](./integration-catalog.md) for requirements and available recipes
- API reference to learn about the available APIs
Binary file added docs/addons/github-secrets-screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions docs/addons/integration-catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,11 @@ Not finding the recipe that you want? If it's popular in the community, our docs
### Request a recipe

If you'd like to request a recipe, head over to the [#maintenance channel](https://discord.com/channels/486522875931656193/490070912448724992) of our community Discord and ask.

## Learn more about the Storybook addon ecosystem

- [Types of addons](./addon-types.md) for other types of addons
- [Writing addons](./writing-addons.md) for the basics of addon development
- [Presets](./writing-presets.md) for preset development
- Integration catalog for requirements and available recipes
- [API reference](./addons-api.md) to learn about the available APIs
Binary file added docs/addons/storybook-addon-finished-state.mp4
Binary file not shown.
Binary file added docs/addons/storybook-addon-initial-state.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
363 changes: 220 additions & 143 deletions docs/addons/writing-addons.md

Large diffs are not rendered by default.

168 changes: 66 additions & 102 deletions docs/addons/writing-presets.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/main-config-manager-head.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Parent: [main.js|ts configuration](./main-config.md)

Type: `(head: string) => string`

Programmatically adjust the manager's `<head>` of your Storybook. For example, load a custom font or add a script. Most often used by [addon authors](../addons/writing-presets.md#babel).
Programmatically adjust the manager's `<head>` of your Storybook. For example, load a custom font or add a script. Most often used by [addon authors](../addons/writing-presets.md#ui-configuration).

<div class="aside">

Expand Down
2 changes: 1 addition & 1 deletion docs/api/main-config-preview-body.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Parent: [main.js|ts configuration](./main-config.md)

Type: `(body: string) => string`

Programmatically adjust the [preview `<body>`](../configure/story-rendering.md#adding-to-body) of your Storybook. Most often used by [addon authors](../addons/writing-presets.md#babel).
Programmatically adjust the [preview `<body>`](../configure/story-rendering.md#adding-to-body) of your Storybook. Most often used by [addon authors](../addons/writing-presets.md#ui-configuration).

<div class="aside">

Expand Down
2 changes: 1 addition & 1 deletion docs/api/main-config-preview-head.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Parent: [main.js|ts configuration](./main-config.md)

Type: `(head: string) => string`

Programmatically adjust the [preview `<head>`](../configure/story-rendering.md#adding-to-head) of your Storybook. Most often used by [addon authors](../addons/writing-presets.md#babel).
Programmatically adjust the [preview `<head>`](../configure/story-rendering.md#adding-to-head) of your Storybook. Most often used by [addon authors](../addons/writing-presets.md#ui-configuration).

<div class="aside">

Expand Down
4 changes: 2 additions & 2 deletions docs/configure/story-rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Storybook will inject these tags into the _preview iframe_ where your components

</div>

It's also possible to modify the preview head HTML programmatically using a preset defined in the `main.js` file. For more information see [Preview/Manager templates](../addons/writing-presets.md#previewmanager-templates).
However, it's also possible to modify the preview head HTML programmatically using a preset defined in the `main.js` file. Read the [presets documentation](../addons/writing-presets.md#ui-configuration) for more information.

## Adding to &#60;body&#62;

Expand Down Expand Up @@ -60,4 +60,4 @@ Storybook will inject these tags into the _preview iframe_ where your components

</div>

Similarly to the preview head HTML, preview body HTML can also be updated programmatically using a preset. See [Preview/Manager templates](../addons/writing-presets.md#previewmanager-templates) for more information.
Just like how you have the ability to customize the preview `head` HTML tag, you can also follow the same steps to customize the preview `body` with a preset. To obtain more information on how to do this, refer to the [presets documentation](../addons/writing-presets.md#ui-configuration).
2 changes: 1 addition & 1 deletion docs/contribute/framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ The [preset API](../addons/writing-presets) is where you will configure the Stor

#### `preview.js` ([example](https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/src/preview.tsx))

The (optional) [preview API](../configure/overview#configure-story-rendering) is where you configure the rendering of stories, such as global decorators or initializing some runtime config needed for your framework to behave as expected. If your framework requires this file, note that you also need to [configure the `previewAnnotations` in `preset.js`](https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/src/preset.ts#L66-L69).
The (optional) [preview API](../configure/overview#configure-story-rendering) is where you configure the rendering of stories, such as global decorators or initializing some runtime config needed for your framework to behave as expected. If your framework requires this file, note that you also need to [configure the `previewAnnotations` in `preset.js`](https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/src/preset.ts#L71-L74).

#### `types.ts` ([example](https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/src/types.ts))

Expand Down
12 changes: 12 additions & 0 deletions docs/snippets/common/main-config-preview.body.js.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```js
// .storybook/main.js

export default {
previewBody: (body) => `
${body}
${
process.env.ANALYTICS_ID ? '<script src="https://cdn.example.com/analytics.js"></script>' : ''
}
`,
};
```
17 changes: 17 additions & 0 deletions docs/snippets/common/main-config-preview.body.ts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```ts
// .storybook/main.ts

// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
import type { StorybookConfig } from '@storybook/your-framework';

const config: StorybookConfig = {
previewBody: (body) => `
${body}
${
process.env.ANALYTICS_ID ? '<script src="https://cdn.example.com/analytics.js"></script>' : ''
}
`,
};

export default config;
```
14 changes: 14 additions & 0 deletions docs/snippets/common/main-config-preview.head.js.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```js
// .storybook/main.js

export default {
previewHead: (head) => `
${head}
<style>
html, body {
background: #827979;
}
</style>
`,
};
```
19 changes: 19 additions & 0 deletions docs/snippets/common/main-config-preview.head.ts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```ts
// .storybook/main.ts

// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
import type { StorybookConfig } from '@storybook/your-framework';

const config: StorybookConfig = {
previewHead: (head) => `
${head}
<style>
html, body {
background: #827979;
}
</style>
`,
};

export default config;
```
7 changes: 0 additions & 7 deletions docs/snippets/common/my-addon-babel-configuration.js.mdx

This file was deleted.

27 changes: 0 additions & 27 deletions docs/snippets/common/my-addon-initial-panel-state.js.mdx

This file was deleted.

9 changes: 0 additions & 9 deletions docs/snippets/common/my-addon-preset-implementation.js.mdx

This file was deleted.

5 changes: 0 additions & 5 deletions docs/snippets/common/my-addon-root-level-preset.js.mdx

This file was deleted.

13 changes: 0 additions & 13 deletions docs/snippets/common/my-addon-storybook-registration.js.mdx

This file was deleted.

13 changes: 0 additions & 13 deletions docs/snippets/common/storybook-addon-change-panel.js.mdx

This file was deleted.

Loading

0 comments on commit e053703

Please sign in to comment.