Skip to content

Commit

Permalink
Merge pull request #18378 from storybookjs/chore_docs_minor_fixes_sni…
Browse files Browse the repository at this point in the history
…ppets

Chore: (Docs) Minor updates to docs and snippets
  • Loading branch information
jonniebigodes committed Jun 1, 2022
2 parents 02ca9da + 2a3ef9a commit 5bacf4d
Show file tree
Hide file tree
Showing 27 changed files with 171 additions and 74 deletions.
19 changes: 14 additions & 5 deletions docs/addons/writing-addons.md
Expand Up @@ -50,13 +50,22 @@ Once you've gone through the prompts, your `package.json` should look like:

### Build system

We'll need to add the necessary dependencies and make some adjustments. Run the following commands:
We'll need to add the necessary dependencies and make some adjustments. Run the following command to install the required depedencies:

```shell
# Installs React and Babel CLI
yarn add react react-dom @babel/cli
<!-- prettier-ignore-start -->

# Adds Storybook:
<CodeSnippets
paths={[
'common/storybook-write-addon-install-dependencies.yarn.js.mdx',
'common/storybook-write-addon-install-dependencies.npm.js.mdx',
]}
/>

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

Initialize a local Storybook instance to allow you to test your addon.

```shell
npx sb init
```

Expand Down
34 changes: 26 additions & 8 deletions docs/builders/webpack.md
Expand Up @@ -40,16 +40,34 @@ You can import `.json` files and have them expanded to a JavaScript object:

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

If you want to know the exact details of the Webpack config, the best way is to run either of the following:
If you want to know the exact details of the Webpack config, the best way is to run either of the following commands:

```shell
For development mode:

## Development mode
yarn start-storybook --debug-webpack
<!-- prettier-ignore-start -->

<CodeSnippets
paths={[
'common/storybook-debug-webpack-dev.yarn.js.mdx',
'common/storybook-debug-webpack-dev.npm.js.mdx',
]}
/>

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

For production mode:

## Production mode
yarn build-storybook --debug-webpack
```

<!-- prettier-ignore-start -->

<CodeSnippets
paths={[
'common/storybook-debug-webpack-prod.yarn.js.mdx',
'common/storybook-debug-webpack-prod.npm.js.mdx',
]}
/>

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

### Code splitting

Expand Down Expand Up @@ -199,5 +217,5 @@ When working with TypeScript projects, the default Webpack configuration may fai
#### Learn more about builders

- [Vite builder](./vite.md) for bundling with Vite
- [Webpack builder](./webpack.md) for bundling with Webpack
- Webpack builder for bundling with Webpack
- [Builder API](./builder-api.md) for building a Storybook builder
20 changes: 11 additions & 9 deletions docs/contribute/code.md
Expand Up @@ -6,13 +6,16 @@ Contribute a new feature or bug fix to [Storybook's monorepo](https://github.com

## Initial setup

First [fork](https://docs.github.com/en/github/getting-started-with-github/quickstart/fork-a-repo) the Storybook repository then clone and build your fork locally. Run the following commands:
Start by [forking](https://docs.github.com/en/github/getting-started-with-github/quickstart/fork-a-repo) the Storybook monorepo and cloning it locally.

```shell
git clone https://github.com/your-username/storybook.git
cd storybook
yarn
yarn bootstrap --core
```

Navigate to the `storybook` directory and install the required dependencies with the following commands:

```shell
yarn && yarn bootstrap --core
```

## Run tests & examples
Expand All @@ -28,8 +31,7 @@ yarn test
Once the tests finish, check if the examples are working with the following commands:

```shell
cd examples/cra-ts-essentials
yarn storybook
cd examples/cra-ts-essentials && yarn storybook
```

<div class="aside">
Expand Down Expand Up @@ -106,7 +108,7 @@ Storybook's monorepo is set up to rely on end-to-end testing with [Cypress](http

Before submitting your contribution, run the test suite one last time with:

```sh
```shell
yarn test
```

Expand All @@ -133,15 +135,15 @@ We encourage bug reports to include reproductions. In the same way that it's pos

To do so, run the following command in the root of the monorepo:

```sh
```shell
npx sb@next link https://github.com/your-username/your-project.git
```

This command creates a project `../storybook-repros/your-project`, and automatically links it to your local Storybook code. After connecting it, you should be able to run Storybook and develop as mentioned [above](#start-developing).

If you already have a reproduction on your local machine, you can similarly link it to your monorepo dev setup with the `--local` flag:

```sh
```shell
npx sb@next link --local /path/to/local-repro-directory
```

Expand Down
8 changes: 6 additions & 2 deletions docs/contribute/new-snippets.md
Expand Up @@ -89,11 +89,15 @@ Go through the rest of the documentation and repeat the process.

Before submitting your contribution, we advise you to check your work against the Storybook website. Doing this prevents last-minute issues with the documentation and is also an excellent way for the maintainers to merge faster once you submit the pull request. However, failing to do so will lead one of the maintainers to notify you that your contribution has an issue.

Start by forking [frontpage repo](https://github.com/storybookjs/frontpage). Then, clone and install the dependencies with the following commands:
Start by forking [frontpage repo](https://github.com/storybookjs/frontpage) and cloning it locally.

```shell
git clone https://github.com/your-username/frontpage.git
cd frontpage
```

Navigate to the `frontpage` directory and install the required dependencies with the following command:

```shell
yarn
```

Expand Down
15 changes: 9 additions & 6 deletions docs/essentials/interactions.md
Expand Up @@ -18,13 +18,16 @@ The interactions are written using a Storybook-instrumented version of [Testing

Since Interactions is still experimental, it doesn't yet ship with Storybook by default. As such, you'll have to install it. You may also want to add our wrappers for Testing Library and Jest.

```shell
# With npm
npm install @storybook/addon-interactions @storybook/jest @storybook/testing-library --save-dev
<!-- prettier-ignore-start -->

# With yarn
yarn add --dev @storybook/addon-interactions @storybook/jest @storybook/testing-library
```
<CodeSnippets
paths={[
'common/storybook-addon-interactions-addon-full-install.yarn.js.mdx',
'common/storybook-addon-interactions-addon-full-install.npm.js.mdx',
]}
/>

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

Next, update [`.storybook/main.js`](../configure/overview.md#configure-story-rendering) to the following:

Expand Down
29 changes: 17 additions & 12 deletions docs/essentials/introduction.md
Expand Up @@ -18,13 +18,16 @@ If you ran `sb init` to include Storybook in your project, the Essentials addon

If you're upgrading from a previous Storybook version, you'll need to run the following command in your terminal:

```shell
#With npm
npm install -D @storybook/addon-essentials
<!-- prettier-ignore-start -->

#With yarn
yarn add -D @storybook/addon-essentials
```
<CodeSnippets
paths={[
'common/storybook-addon-essentials-install.yarn.js.mdx',
'common/storybook-addon-essentials-install.npm.js.mdx',
]}
/>

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

Update your Storybook configuration (in [`.storybook/main.js`](../configure/overview.md#configure-story-rendering)) to include the Essentials addon.

Expand All @@ -44,14 +47,16 @@ Essentials is "zero-config”. It comes with a recommended configuration out of

If you need to reconfigure any of the [individual Essentials addons](https://storybook.js.org/addons/tag/essentials), install them manually by following the installation instructions, register them in your Storybook configuration file (i.e., [`.storybook/main.js`](../configure/overview.md#configure-story-rendering)) and adjust the configuration to suit your needs. For example:

```shell
#With npm
npm install -D @storybook/addon-actions
<!-- prettier-ignore-start -->

<CodeSnippets
paths={[
'common/storybook-addon-actions-install.yarn.js.mdx',
'common/storybook-addon-actions-install.npm.js.mdx',
]}
/>

#With yarn
yarn add -D @storybook/addon-actions
```
<!-- prettier-ignore-end -->

<!-- prettier-ignore-start -->

Expand Down
18 changes: 11 additions & 7 deletions docs/sharing/publish-storybook.md
Expand Up @@ -21,7 +21,8 @@ First, we'll need to build Storybook as a static web application. The functional
paths={[
'angular/custom-build-script-production.script-for-builder.js.mdx',
'angular/build-storybook-production-mode.with-builder.js.mdx',
'common/build-storybook-production-mode.js.mdx',
'common/build-storybook-production-mode.yarn.js.mdx',
'common/build-storybook-production-mode.npm.js.mdx',
]}
/>

Expand Down Expand Up @@ -49,13 +50,16 @@ To get started, sign up with your GitHub, GitLab, Bitbucket, or email and genera

Next, install the [Chromatic CLI](https://www.npmjs.com/package/chromatic) package from npm:

```shell
# With npm
npm install --save-dev chromatic
<!-- prettier-ignore-start -->

# With yarn
yarn add --dev chromatic
```
<CodeSnippets
paths={[
'common/chromatic-install.yarn.js.mdx',
'common/chromatic-install.npm.js.mdx',
]}
/>

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

Run the following command after the package finishes installing. Make sure that you replace `your-project-token` with your own project token.

Expand Down
7 changes: 0 additions & 7 deletions docs/snippets/common/build-storybook-production-mode.js.mdx

This file was deleted.

@@ -0,0 +1,3 @@
```shell
npm run build-storybook
```
@@ -0,0 +1,3 @@
```shell
yarn build-storybook
```
3 changes: 3 additions & 0 deletions docs/snippets/common/chromatic-install.npm.js.mdx
@@ -0,0 +1,3 @@
```shell
npm install chromatic --save-dev
```
3 changes: 3 additions & 0 deletions docs/snippets/common/chromatic-install.yarn.js.mdx
@@ -0,0 +1,3 @@
```shell
yarn add --dev chromatic
```
@@ -0,0 +1,3 @@
```shell
npm install @storybook/addon-actions --save-dev
```
@@ -0,0 +1,3 @@
```shell
yarn add --dev @storybook/addon-actions
```
@@ -0,0 +1,3 @@
```shell
npm install @storybook/addon-actions --save-dev
```
@@ -0,0 +1,3 @@
```shell
yarn add --dev @storybook/addon-essentials
```
@@ -0,0 +1,3 @@
```shell
npm install @storybook/addon-storyshots --save-dev
```
@@ -0,0 +1,3 @@
```shell
yarn add --dev @storybook/addon-storyshots
```
3 changes: 3 additions & 0 deletions docs/snippets/common/storybook-debug-webpack-dev.npm.js.mdx
@@ -0,0 +1,3 @@
```shell
npm run storybook -- --debug-webpack
```
3 changes: 3 additions & 0 deletions docs/snippets/common/storybook-debug-webpack-dev.yarn.js.mdx
@@ -0,0 +1,3 @@
```shell
yarn storybook --debug-webpack
```
3 changes: 3 additions & 0 deletions docs/snippets/common/storybook-debug-webpack-prod.npm.js.mdx
@@ -0,0 +1,3 @@
```shell
npm run build-storybook -- --debug-webpack
```
3 changes: 3 additions & 0 deletions docs/snippets/common/storybook-debug-webpack-prod.yarn.js.mdx
@@ -0,0 +1,3 @@
```shell
yarn build-storybook --debug-webpack
```
@@ -0,0 +1,3 @@
```shell
npm install react react-dom @babel/cli
```
@@ -0,0 +1,3 @@
```shell
yarn add react react-dom @babel/cli
```
15 changes: 9 additions & 6 deletions docs/writing-stories/play-function.md
Expand Up @@ -10,13 +10,16 @@ We recommend installing Storybook's [`addon-interactions`](https://storybook.js.

Run the following command to install the addon and the required dependencies.

```shell
# With npm
npm install @storybook/addon-interactions @storybook/testing-library --save-dev
<!-- prettier-ignore-start -->

# With yarn
yarn add --dev @storybook/addon-interactions @storybook/testing-library
```
<CodeSnippets
paths={[
'common/storybook-addon-interactions-addon-full-install.yarn.js.mdx',
'common/storybook-addon-interactions-addon-full-install.npm.js.mdx',
]}
/>

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

Update your Storybook configuration (in `.storybook/main.js`) to include the interactions addon.

Expand Down
15 changes: 9 additions & 6 deletions docs/writing-tests/snapshot-testing.md
Expand Up @@ -14,13 +14,16 @@ Storybook is a helpful tool for snapshot testing because every story is essentia

Run the following command to install Storyshots:

```shell
# With npm
npm install @storybook/addon-storyshots --save-dev
<!-- prettier-ignore-start -->

# With yarn
yarn add --dev @storybook/addon-storyshots
```
<CodeSnippets
paths={[
'common/storybook-addon-storyshots-install.yarn.js.mdx',
'common/storybook-addon-storyshots-install.npm.js.mdx',
]}
/>

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

Add a test file to your environment with the following contents to configure Storyshots:

Expand Down

0 comments on commit 5bacf4d

Please sign in to comment.