Skip to content

Commit 42e4fc9

Browse files
docs: update storybook guide for v10
1 parent 462f88b commit 42e4fc9

2 files changed

Lines changed: 24 additions & 37 deletions

File tree

src/pages/guides/ecosystem/storybook.md

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,23 @@ tocHeading: 2
1212
1313
## Setup
1414

15-
We recommend using the [Storybook CLI](https://storybook.js.org/docs/get-started/install) to setup a project from scratch:
15+
> _This guide assumes Storybook v10+_
16+
17+
We recommend using the [Storybook CLI](https://storybook.js.org/docs/get-started/install) to setup a project from scratch using the Web Components template:
1618

1719
<!-- prettier-ignore-start -->
1820

19-
<app-ctc-block variant="shell" paste-contents="npx storybook@latest init">
21+
<app-ctc-block variant="shell" paste-contents="npm create storybook@latest -- --type web_components">
2022

2123
```shell
22-
npx storybook@latest init
24+
# npm requires a -- between arguments
25+
$ npm create storybook@latest -- --type web_components
2326
```
2427

2528
</app-ctc-block>
2629

2730
<!-- prettier-ignore-end -->
2831

29-
As part of the prompts, we suggest the following answers to project type (**web_components**) and builder (**Vite**):
30-
31-
```shell
32-
✔ Do you want to manually choose a Storybook project type to install? … yes
33-
? Please choose a project type from the following list: › - Use arrow-keys. Return to submit.
34-
↑ webpack_react
35-
nextjs
36-
vue3
37-
angular
38-
ember
39-
❯ web_components
40-
html
41-
qwik
42-
preact
43-
↓ svelte
44-
45-
We were not able to detect the right builder for your project. Please select one: › - Use arrow-keys. Return to submit.
46-
❯ Vite
47-
Webpack 5
48-
```
49-
5032
> See our Vitest docs for additional configuration examples to support [Import Attributes](/guides/ecosystem/vitest/#import-attributes) and [Greenwood resource plugins](/guides/ecosystem/vitest/#resource-plugins) usage in your components. For that guide, you'll be updating a _vite.config.js_ file instead.
5133
5234
## Usage
@@ -81,15 +63,18 @@ You should now be good to start writing your first story! 📚
8163
<app-ctc-block variant="snippet" heading="src/components/footer/footer.stories.js">
8264

8365
```js
84-
import "./footer.js";
66+
import { html } from 'lit';
67+
import './footer.js';
8568

86-
export default {
87-
title: "Components/Footer",
69+
const meta = {
70+
title: 'Components/Footer',
8871
};
8972

90-
const Template = () => "<app-footer></app-footer>";
73+
export default meta;
9174

92-
export const Primary = Template.bind({});
75+
export const Primary = () => {
76+
return html`<app-footer></app-footer>`;
77+
};
9378
```
9479

9580
</app-ctc-block>
@@ -151,7 +136,9 @@ You'll want to create a CommonJS version with the following name, depending on w
151136

152137
If you are using any of Greenwood's Content as Data [Client APIs](/docs/content-as-data/data-client/), you'll want to configure Storybook to mock the HTTP calls Greenwood's data client makes, and provide the desired response needed based on the API being called.
153138

154-
This can be accomplished with the [**storybook-addon-fetch-mock**](https://storybook.js.org/addons/storybook-addon-fetch-mock) addon and configuring it with the right `matcher.url` and `matcher.response`
139+
This can be accomplished with the [**storybook-addon-fetch-mock**](https://storybook.js.org/addons/storybook-addon-fetch-mock) addon and configuring it with the right `matcher.url` and `matcher.response`.
140+
141+
> Be aware of this [open issue](https://github.com/JohnAlbin/storybook-addon-fetch-mock/issues/32) with **storybook-addon-fetch-mock**.
155142
156143
1. First, install the **storybook-addon-fetch-mock** addon
157144

src/pages/guides/ecosystem/vitest.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ First, install Vite and Vitest:
3636

3737
<!-- prettier-ignore-end -->
3838

39-
Next, let's create a _vitest.config.js_ file and configure the location of our test cases:
39+
Next, let's create a _vite.config.js_ file and configure the location of our test cases:
4040

4141
<!-- prettier-ignore-start -->
4242

@@ -113,11 +113,11 @@ Then install Playwright:
113113

114114
<!-- prettier-ignore-end -->
115115

116-
Then in our _vitest.config.js_ file, let's add configuration for Playwright:
116+
Then in our _vite.config.js_ file, let's add configuration for Playwright:
117117

118118
<!-- prettier-ignore-start -->
119119

120-
<app-ctc-block variant="snippet" heading="vitest.config.js">
120+
<app-ctc-block variant="snippet" heading="vite.config.js">
121121

122122
```js
123123
import { defineConfig } from 'vitest/config';
@@ -225,13 +225,13 @@ You should now be good to start writing your first test! ⚡
225225

226226
## Import Attributes
227227

228-
As [Vite does not support Import Attributes](https://github.com/vitejs/vite/issues/14674), you will need to update your _vitest.config.js_ file and write a [custom plugin](https://vitejs.dev/guide/api-plugin) to work around this.
228+
As [Vite does not support Import Attributes](https://github.com/vitejs/vite/issues/14674), you will need to update your _vite.config.js_ file and write a [custom plugin](https://vitejs.dev/guide/api-plugin) to work around this.
229229

230230
In this example we are handling for CSS Module scripts:
231231

232232
<!-- prettier-ignore-start -->
233233

234-
<app-ctc-block variant="snippet" heading="vitest.config.js">
234+
<app-ctc-block variant="snippet" heading="vite.config.js">
235235

236236
```js
237237
import { defineConfig } from 'vitest/config';
@@ -302,13 +302,13 @@ Phew, should be all set now.
302302
303303
## Resource Plugins
304304
305-
If you're using one of Greenwood's [resource plugins](/docs/plugins/), you'll want to update the _vitest.config.js_ file with a plugin that can leverage Greenwood's plugins to automatically handle custom transformations.
305+
If you're using one of Greenwood's [resource plugins](/docs/plugins/), you'll want to update the _vite.config.js_ file with a plugin that can leverage Greenwood's plugins to automatically handle custom transformations.
306306
307307
For example, if you're using Greenwood's [Raw Plugin](https://github.com/ProjectEvergreen/greenwood/tree/master/packages/plugin-import-raw), you'll need to create a wrapping Vite plugin to handle this transformation.
308308
309309
<!-- prettier-ignore-start -->
310310
311-
<app-ctc-block variant="snippet" heading="vitest.config.js">
311+
<app-ctc-block variant="snippet" heading="vite.config.js">
312312
313313
```js
314314
import { defineConfig } from "vitest/config";

0 commit comments

Comments
 (0)