Skip to content

Commit

Permalink
Support .storybook configuration directory
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Aug 28, 2023
1 parent 77fbb6a commit f4c265f
Show file tree
Hide file tree
Showing 68 changed files with 178 additions and 129 deletions.
11 changes: 11 additions & 0 deletions .changeset/pink-feet-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'sku': minor
---

Adds support for Storybook configuration via the `.storybook` directory

sku now supports the standard `.storybook` configuration directory, as documented in [Storybook's configuration documentation].
Please read [sku's storybook documentation][sku storybook docs] for more info.

[Storybook configuration documentation]: https://storybook.js.org/docs/react/configure/overview
[sku storybook docs]: https://seek-oss.github.io/sku/#/./docs/storybook
11 changes: 11 additions & 0 deletions .changeset/real-rabbits-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'sku': patch
---

Drop support for running `devServerMiddleware` alongside `sku storybook`

Now that sku supports Storybook configuration via the `.storybook` directory, this feature is unnecessary.
Storybook middleware can be configured by creating a `middleware.js` file in the `.storybook` directory.
See [the sku docs][sku storybook middleware] for more info.

[sku storybook middleware]: https://seek-oss.github.io/sku/#/./docs/storybook?id=devserver-middleware
56 changes: 37 additions & 19 deletions docs/docs/storybook.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,35 @@ export const Secondary = () => <Button variant="secondary">Secondary</Button>;

_**NOTE:** To access the Storybook API, you should import from `sku/@storybook/...`, since your project isn't depending on Storybook packages directly._

## Configuration

Storybook can be configured by creating specially-named files inside the `.storybook` folder of your app.
Take a look at the [Storybook configuration docs] for all the ways to customize your Storybook.

_**NOTE:** sku maintains control of the `main.js` configuration file as it is critical to ensuring compatibility between Storybook and your app.
If you have a valid use case for customizing this file, please reach out in [`#sku-support`]._

[Storybook configuration docs]: https://storybook.js.org/docs/react/configure/overview
[`#sku-support`]: https://seekchat.slack.com/channels/sku-support

### Addons

There are no storybook addons configured by default in sku but they can be added through the `storybookAddons` option in `sku.config.ts`.

For example, if you want to use `@storybook/addon-essentials`, first install the addon.

```bash
yarn add --dev @storybook/addon-essentials
```

Then add it to your `sku.config.ts`.

```ts
export default {
storybookAddons: ['@storybook/addon-essentials'],
} satisfies SkuConfig;
```

### Story Rendering

Story rendering can be customized globally by creating a `.storybook/preview.js` (or `.ts`, or `.tsx`) file.
Expand Down Expand Up @@ -53,7 +82,14 @@ See [the Storybook docs][storybook preview.js] for more info.

### DevServer Middleware

When running `sku storybook`, if you have configured [`devServerMiddleware`][devserver middleware] in your sku config, that middleware will be passed through to storybook and injected into its own middleware stack.
When running `sku storybook`, if you want to run your [`devServerMiddleware`][devserver middleware] at the same time, add a `middleware.js` file to the `.storybook` folder and export it:

```js
// .storybook/middleware.js
import devServerMiddleware from '../devServerMiddleware.js';

export default devServerMiddleware;
```

[devserver middleware]: ./docs/extra-features.md#devserver-middleware

Expand All @@ -68,24 +104,6 @@ export default {
} satisfies SkuConfig;
```

## Addons

There are no storybook addons configured by default in sku but they can be added through the `storybookAddons` option in `sku.config.ts`.

For example, if you want to use `@storybook/addon-essentials`, first install the addon.

```bash
yarn add --dev @storybook/addon-essentials
```

Then add it to your `sku.config.ts`.

```ts
export default {
storybookAddons: ['@storybook/addon-essentials'],
} satisfies SkuConfig;
```

## Build Storybook

To build your Storybook, first add the following npm script:
Expand Down
1 change: 1 addition & 0 deletions fixtures/assertion-removal/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/assertion-removal/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/assertion-removal/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/braid-design-system/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/braid-design-system/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/braid-design-system/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/custom-src-paths/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/custom-src-paths/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/custom-src-paths/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/library-build/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/library-build/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/library-build/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/library-file/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/library-file/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/library-file/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/lint-format/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/lint-format/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/lint-format/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/multiple-routes/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/multiple-routes/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/multiple-routes/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/public-path/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/static/
Expand Down
1 change: 1 addition & 0 deletions fixtures/public-path/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-storybook/
dist/static/
Expand Down
1 change: 1 addition & 0 deletions fixtures/public-path/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/static/
Expand Down
1 change: 1 addition & 0 deletions fixtures/react-css-modules/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/react-css-modules/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/react-css-modules/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/sku-test/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/sku-test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/sku-test/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/sku-with-https/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/sku-with-https/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.eslintrc
.prettierrc
.ssl
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/sku-with-https/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/source-maps/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/source-maps/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/source-maps/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
1 change: 1 addition & 0 deletions fixtures/ssr-hello-world/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-build/
dist-storybook/
Expand Down
1 change: 1 addition & 0 deletions fixtures/ssr-hello-world/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# managed by sku
.eslintrc
.prettierrc
.storybook/main.js
coverage/
dist-build/
dist-storybook/
Expand Down
1 change: 1 addition & 0 deletions fixtures/ssr-hello-world/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-build/
dist-storybook/
Expand Down
1 change: 1 addition & 0 deletions fixtures/storybook-config/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# managed by sku
*.less.d.ts
.storybook/main.js
coverage/
dist-storybook/
dist/
Expand Down
Loading

0 comments on commit f4c265f

Please sign in to comment.