Skip to content

Commit

Permalink
removes the shell and json file references.
Browse files Browse the repository at this point in the history
Updates for the writing docs section
  • Loading branch information
jonniebigodes committed Aug 11, 2020
1 parent 44fd2e1 commit 714076b
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 115 deletions.
12 changes: 3 additions & 9 deletions docs/configure/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@ title: 'Environment variables'
You can use environment variables in Storybook to change its behaviour in different “modes”.
If you supply an environment variable prefixed with `STORYBOOK_`, it will be available in `process.env`:

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

<CodeSnippets
paths={[
'common/storybook-set-environment-variables.sh.mdx',
]}
/>

<!-- prettier-ignore-end -->
```shell
STORYBOOK_THEME=red STORYBOOK_DATA_KEY=12345 npm run storybook
```

Then we can access these environment variables anywhere inside our preview JavaScript code like below:

Expand Down
32 changes: 14 additions & 18 deletions docs/configure/images-and-assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ We recommend serving static files via Storybook to ensure that your components a

Configure a directory (or a list of directories) where your assets live when starting Storybook. Use the`-s` flag in your npm script like so:

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

<CodeSnippets
paths={[
'common/storybook-serve-static-assets-script.json.mdx',
]}
/>

<!-- prettier-ignore-end -->
```json
{
"scripts": {
"start-storybook": "start-storybook -s ./public -p 9001"
}
}
```

Here `./public` is your static directory. Now use it in a component or story like this.

Expand All @@ -50,15 +48,13 @@ Here `./public` is your static directory. Now use it in a component or story lik

You can also pass a list of directories separated by commas without spaces instead of a single directory.

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

<CodeSnippets
paths={[
'common/storybook-serve-static-assets-script-multifolder.json.mdx',
]}
/>

<!-- prettier-ignore-end -->
```json
{
"scripts": {
"start-storybook": "start-storybook -s ./public,./static -p 9001"
}
}
```

### Reference assets from a CDN

Expand Down
12 changes: 3 additions & 9 deletions docs/configure/theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@ Storybook includes two themes that look good out of the box: "normal" (a light t

Make sure you have installed [`@storybook/addons`](https://www.npmjs.com/package/@storybook/addons) and [`@storybook/theming`](https://www.npmjs.com/package/@storybook/theming) packages.

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

<CodeSnippets
paths={[
'common/storybook-install-theme-packages.sh.mdx',
]}
/>

<!-- prettier-ignore-end -->
```sh
yarn install --dev @storybook/addons @storybook/theming
```

As an example, you can tell Storybook to use the "dark" theme by modifying [`.storybook/manager.js`](./overview.md#configure-story-rendering):

Expand Down
12 changes: 3 additions & 9 deletions docs/configure/webpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,9 @@ You can import `.json` files and have them expanded to a JavaScript object:

If you want to know the exact details of the webpack config, the best way is to run:

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

<CodeSnippets
paths={[
'common/storybook-run-webpack-config.sh.mdx',
]}
/>

<!-- prettier-ignore-end -->
```shell
yarn storybook --debug-webpack
```

### Extending Storybook’s webpack config

Expand Down
12 changes: 3 additions & 9 deletions docs/get-started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,9 @@ The command above will make the following changes to your local environment:

Check that everything worked by running:

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

<CodeSnippets
paths={[
'common/storybook-execute.sh.mdx',
]}
/>

<!-- prettier-ignore-end -->
```shell
npx storybook
```

It will start Storybook locally and output the address. Depending on your system configuration, it will automatically open the address in a new browser tab and you'll be greeted by a welcome screen.

Expand Down
3 changes: 3 additions & 0 deletions docs/snippets/common/badge-story.mdx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

<!---Badge.stories.mdx --->

<!--- This is your Story template function, shown here in React -->

import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';

import { Badge } from './Badge';
import { Icon } from './Icon';

<Meta title="MDX/Badge" component={Badge} />

export const Template = (args) => <Badge {...args } />

# Badge
Expand Down
2 changes: 2 additions & 0 deletions docs/snippets/common/checkbox-story.mdx.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
```md
<!--- Checkbox.stories.mdx -->

<!--- This is your Story template function, shown here in React -->

import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
import { Checkbox } from './Checkbox';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
```md
<!--- MyComponent.stories.mdx -->

import { Props } from '@storybook/addon-docs/blocks';
import { MyComponent } from './MyComponent';

Expand Down
1 change: 1 addition & 0 deletions docs/snippets/common/component-story-mdx-argtypes.mdx.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
```md
<!--- MyComponent.stories.mdx -->

<Meta
title="MyComponent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
```md
<!-- MyComponent.stories.mdx --->

<Meta
title='MyComponent'
Expand Down
2 changes: 2 additions & 0 deletions docs/snippets/common/component-story-mdx-dedent.mdx.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
```md
<!--- MyComponent.stories.mdx -->

import { Source } from '@storybook/addon-docs/blocks';
import dedent from 'ts-dedent';

Expand Down
3 changes: 3 additions & 0 deletions docs/snippets/common/component-story-mdx-description.mdx.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
```md
<!--- Button.stories.mdx -->

import { Description } from '@storybook/addon-docs/blocks';
import dedent from 'ts-dedent';
import { Button } from './Button';

<Description of={Button} />

<Description markdown={dedent`
## Custom description

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
```md
<!-- MyComponent.stories.mdx --->

import { Story } from '@storybook/addon-docs/blocks';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
```md
<!-- Button.stories.mdx --->

<!--- This is your Story template function, shown here in React -->

import { Story } from '@storybook/addon-docs/blocks';
import { Button } from './Button';

Expand Down
4 changes: 4 additions & 0 deletions docs/snippets/common/mdx-canvas-multiple-stories.mdx.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
```md
<!-- MyComponent.stories.mdx --->

<!--- This is your Story template function, shown here in React -->

import { Canvas } from '@storybook/addon-docs/blocks';

export const Template = (args) => <Badge {...args } />;
Expand Down
2 changes: 2 additions & 0 deletions docs/snippets/common/my-component-with-story-content.mdx.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
```md
<!-- MyComponent.stories.mdx --->

import { Canvas } from '@storybook/addon-docs/blocks';
import { MyComponent } from './MyComponent';

Expand Down
7 changes: 0 additions & 7 deletions docs/snippets/common/storybook-build-documentation.json.mdx

This file was deleted.

3 changes: 0 additions & 3 deletions docs/snippets/common/storybook-execute.sh.mdx

This file was deleted.

3 changes: 0 additions & 3 deletions docs/snippets/common/storybook-install-theme-packages.sh.mdx

This file was deleted.

3 changes: 0 additions & 3 deletions docs/snippets/common/storybook-install.sh.mdx

This file was deleted.

7 changes: 0 additions & 7 deletions docs/snippets/common/storybook-preview-documentation.json.mdx

This file was deleted.

3 changes: 0 additions & 3 deletions docs/snippets/common/storybook-run-webpack-config.sh.mdx

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

32 changes: 14 additions & 18 deletions docs/writing-docs/build-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ Storybook allows you to create rich and extensive [documentation](./introduction

At any point during your development, you can preview the documentation you've written. Storybook allows you to generate a preview of the final documentation when you use the `--docs` flag. We recommend including it in your `package.json` as a new script:

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

<CodeSnippets
paths={[
'common/storybook-preview-documentation.json.mdx',
]}
/>

<!-- prettier-ignore-end -->
```json
{
"scripts": {
"storybook-docs": "start-storybook --docs",
}
}
```

Depending on your configuration, when you execute the `storybook-docs` script. Storybook will be put into documentation mode and will generate a different build.

Expand All @@ -34,15 +32,13 @@ There's some caveats to this build mode, as to the normal Storybook build:

You can also publish your documentation, the same you would [publish](../workflows/publish-storybook.md) your Storybook. You can use the `--docs` flag with `build-storybook` command. We recommend as well including it as a script in your `package.json` file:

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

<CodeSnippets
paths={[
'common/storybook-build-documentation.json.mdx',
]}
/>

<!-- prettier-ignore-end -->
```json
{
"scripts": {
"build-storybook-docs": "build-storybook --docs",
}
}
```

Based on the configuration you have, when the `build-storybook-docs` script is executed, Storybook once again will be put into documentation mode and will generate a different build and output the documentation into the `storybook-static` folder.

Expand Down

0 comments on commit 714076b

Please sign in to comment.