Skip to content

Commit 4f98662

Browse files
committed
Update checklist according to latest proposal
1 parent a93d6cc commit 4f98662

File tree

4 files changed

+148
-77
lines changed

4 files changed

+148
-77
lines changed

code/core/src/manager-api/modules/stories.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ export interface SubAPI {
120120
* @returns {API_LeafEntry} The current story's data.
121121
*/
122122
getCurrentStoryData: () => API_LeafEntry;
123+
/**
124+
* Returns the current story index.
125+
*
126+
* @returns {API_PreparedStoryIndex | undefined} The current story index, or undefined if not yet
127+
* loaded.
128+
*/
129+
getIndex: () => API_PreparedStoryIndex | undefined;
123130
/**
124131
* Sets the prepared story index to the given value.
125132
*
@@ -343,6 +350,10 @@ export const init: ModuleFn<SubAPI, SubState> = ({
343350

344351
return api.getData(storyId, refId);
345352
},
353+
getIndex: () => {
354+
const { internal_index } = store.getState();
355+
return internal_index;
356+
},
346357
getParameters: (storyIdOrCombo, parameterName) => {
347358
const { storyId, refId } =
348359
typeof storyIdOrCombo === 'string'

code/core/src/manager/components/sidebar/ChecklistModule.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const meta = preview.meta({
2626
loaded: true,
2727
muted: false,
2828
accepted: ['controls'],
29-
done: ['add-component'],
29+
done: ['install-storybook', 'first-story', 'whats-new-storybook-10'],
3030
skipped: ['viewports'],
3131
});
3232
},

code/core/src/manager/settings/Checklist/Checklist.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const Default = meta.story({
3838
...checklistData,
3939
...checklistStore,
4040
accepted: ['controls'],
41-
done: ['add-component'],
41+
done: ['install-storybook', 'first-story', 'whats-new-storybook-10'],
4242
skipped: ['viewports'],
4343
},
4444
});

code/core/src/manager/settings/Checklist/checklistData.tsx

Lines changed: 135 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import React from 'react';
22

33
import { Link } from 'storybook/internal/components';
4+
import {
5+
STORY_ARGS_UPDATED,
6+
STORY_FINISHED,
7+
STORY_INDEX_INVALIDATED,
8+
UPDATE_GLOBALS,
9+
} from 'storybook/internal/core-events';
410
import type { API_IndexHash } from 'storybook/internal/types';
511

612
import { type API } from 'storybook/manager-api';
@@ -32,20 +38,28 @@ export interface ChecklistData {
3238
export const checklistData: ChecklistData = {
3339
sections: [
3440
{
35-
id: 'build',
36-
title: 'Build',
41+
id: 'basics',
42+
title: 'Storybook basics',
3743
items: [
3844
{
39-
id: 'whats-new-sb-9',
45+
id: 'install-storybook',
46+
label: 'Install Storybook',
47+
subscribe: ({ done }) => done(),
48+
},
49+
{
50+
id: 'whats-new-storybook-10',
4051
label: "See what's new",
4152
action: {
4253
label: 'Start',
43-
onClick: ({ api }) => api.navigate('/settings/whats-new'),
54+
onClick: ({ api, accept }) => {
55+
api.navigate('/settings/whats-new');
56+
accept();
57+
},
4458
},
4559
},
4660
{
47-
id: 'add-component',
48-
label: 'Add component',
61+
id: 'first-story',
62+
label: 'Create first story',
4963
content: (
5064
<>
5165
<p>
@@ -63,52 +77,133 @@ export const checklistData: ChecklistData = {
6377
</p>
6478
</>
6579
),
66-
// subscribe: ({ done }) => done(),
80+
subscribe: ({ api, done }) =>
81+
api.on(STORY_FINISHED, ({ status }) => status === 'success' && done()),
6782
},
6883
{
69-
id: 'add-5-10-components',
70-
after: ['add-component'],
71-
label: 'Add 5-10 total components',
84+
id: 'more-components',
85+
after: ['first-story'],
86+
label: 'Add 5 components',
7287
content: (
73-
<>
88+
<p>
7489
A story is an object that describes how to render a component. You can have multiple
7590
stories per component, and those stories can build upon one another. For example, we
7691
can add Secondary and Tertiary stories based on our Primary story from above.
92+
</p>
93+
),
94+
subscribe: ({ api, done }) => {
95+
const check = () => {
96+
const entries = api.getIndex()?.entries || {};
97+
const stories = Object.values(entries).filter(({ type }) => type === 'story');
98+
const components = new Set(stories.map(({ title }) => title));
99+
return components.size >= 5;
100+
};
101+
if (check()) {
102+
done();
103+
} else {
104+
return api.on(STORY_INDEX_INVALIDATED, () => check() && done());
105+
}
106+
},
107+
},
108+
{
109+
id: 'more-stories',
110+
after: ['first-story'],
111+
label: 'Add 20 stories',
112+
content: (
113+
<p>
114+
A story is an object that describes how to render a component. You can have multiple
115+
stories per component, and those stories can build upon one another. For example, we
116+
can add Secondary and Tertiary stories based on our Primary story from above.
117+
</p>
118+
),
119+
subscribe: ({ api, done }) => {
120+
const check = () => {
121+
const entries = api.getIndex()?.entries || {};
122+
const stories = Object.values(entries).filter(({ type }) => type === 'story');
123+
return stories.length >= 20;
124+
};
125+
if (check()) {
126+
done();
127+
} else {
128+
return api.on(STORY_INDEX_INVALIDATED, () => check() && done());
129+
}
130+
},
131+
},
132+
],
133+
},
134+
{
135+
id: 'development',
136+
title: 'Development',
137+
items: [
138+
{
139+
id: 'controls',
140+
after: ['first-story'],
141+
label: 'Controls',
142+
content: (
143+
<>
144+
Storybook Controls gives you a graphical UI to interact with a component's arguments
145+
dynamically without needing to code. Use the Controls panel to edit the inputs to your
146+
stories and see the results in real-time. It's a great way to explore your components
147+
and test different states.
77148
</>
78149
),
79-
subscribe: ({ done }) => done(),
150+
subscribe: ({ api, done }) => api.on(STORY_ARGS_UPDATED, done),
80151
},
81152
{
82-
id: 'check-improve-coverage',
83-
after: ['add-component'],
84-
label: 'Check + improve coverage',
153+
id: 'viewports',
154+
after: ['first-story'],
155+
label: 'Viewports',
85156
content: (
86157
<>
87158
<p>
88-
Test coverage is the practice of measuring whether existing tests fully cover your
89-
code. It marks which conditions, logic branches, functions and variables in your
90-
code are and are not being tested.
91-
</p>
92-
<p>
93-
Coverage tests examine the instrumented code against a set of industry-accepted best
94-
practices. They act as the last line of QA to improve the quality of your test
95-
suite.
159+
The viewport feature allows you to adjust the dimensions of the iframe your story is
160+
rendered in. It makes it easy to develop responsive UIs. The Viewport module enables
161+
you to change the viewport applied to a story by selecting from the list of
162+
predefined viewports in the toolbar. If needed, you can set a story to default to a
163+
specific viewport by using the globals option.
96164
</p>
165+
<Link
166+
href="https://storybook.js.org/docs/essentials/viewport#defining-the-viewport-for-a-story"
167+
target="_blank"
168+
withArrow
169+
>
170+
Learn more
171+
</Link>
97172
</>
98173
),
99-
subscribe: ({ done }) => setTimeout(done, 3000),
174+
subscribe: ({ api, done }) =>
175+
api.on(UPDATE_GLOBALS, ({ globals }) => globals?.viewport && done()),
176+
},
177+
{
178+
id: 'organize-stories',
179+
after: ['first-story'],
180+
label: 'Organize your stories',
100181
},
101182
],
102183
},
103184
{
104-
id: 'test',
105-
title: 'Test',
185+
id: 'testing',
186+
title: 'Testing',
106187
items: [
188+
{
189+
id: 'install-vitest',
190+
label: 'Install Vitest',
191+
subscribe: ({ done }) => done(),
192+
content: (
193+
<p>
194+
Storybook offers fast, powerful testing from the sidebar, with the Vitest addon. It
195+
transforms your stories into real Vitest tests, and then runs them in the background,
196+
via Vitest and Playwright. Results are displayed in your sidebar, and you can debug
197+
failures with all your favorite features and addons, in addition to the browser dev
198+
tools.
199+
</p>
200+
),
201+
},
107202
{
108203
id: 'run-tests',
109-
after: ['add-component'],
204+
after: ['first-story'],
110205
label: 'Run tests',
111-
subscribe: ({ done }) => done(),
206+
// subscribe: ({ done }) => done(),
112207
content: (
113208
<>
114209
<p>
@@ -129,7 +224,7 @@ export const checklistData: ChecklistData = {
129224
},
130225
{
131226
id: 'write-interactions',
132-
after: ['add-component'],
227+
after: ['first-story'],
133228
label: 'Write interactions',
134229
content: (
135230
<>
@@ -150,7 +245,7 @@ export const checklistData: ChecklistData = {
150245
},
151246
{
152247
id: 'accessibility-tests',
153-
after: ['add-component'],
248+
after: ['first-story'],
154249
label: 'Accessibility tests',
155250
subscribe: ({ done }) => done(),
156251
content: (
@@ -173,9 +268,9 @@ export const checklistData: ChecklistData = {
173268
},
174269
{
175270
id: 'visual-tests',
176-
after: ['add-component'],
271+
after: ['first-story'],
177272
label: 'Visual tests',
178-
subscribe: ({ done }) => done(),
273+
// subscribe: ({ done }) => done(),
179274
content: (
180275
<>
181276
<p>
@@ -195,51 +290,15 @@ export const checklistData: ChecklistData = {
195290
</>
196291
),
197292
},
198-
{
199-
id: 'viewports',
200-
after: ['add-component'],
201-
label: 'Viewports',
202-
content: (
203-
<>
204-
<p>
205-
The viewport feature allows you to adjust the dimensions of the iframe your story is
206-
rendered in. It makes it easy to develop responsive UIs. The Viewport module enables
207-
you to change the viewport applied to a story by selecting from the list of
208-
predefined viewports in the toolbar. If needed, you can set a story to default to a
209-
specific viewport by using the globals option.
210-
</p>
211-
<Link
212-
href="https://storybook.js.org/docs/essentials/viewport#defining-the-viewport-for-a-story"
213-
target="_blank"
214-
withArrow
215-
>
216-
Learn more
217-
</Link>
218-
</>
219-
),
220-
},
221293
],
222294
},
223295
{
224296
id: 'document',
225297
title: 'Document',
226298
items: [
227-
{
228-
id: 'controls',
229-
after: ['add-component'],
230-
label: 'Controls',
231-
content: (
232-
<>
233-
Storybook Controls gives you a graphical UI to interact with a component's arguments
234-
dynamically without needing to code. Use the Controls panel to edit the inputs to your
235-
stories and see the results in real-time. It's a great way to explore your components
236-
and test different states.
237-
</>
238-
),
239-
},
240299
{
241300
id: 'autodocs',
242-
after: ['add-component'],
301+
after: ['first-story'],
243302
label: 'Autodocs',
244303
content: (
245304
<>
@@ -251,14 +310,15 @@ export const checklistData: ChecklistData = {
251310
),
252311
},
253312
{
254-
id: 'share-story',
255-
after: ['add-component'],
256-
label: 'Share story',
313+
id: 'mdx',
314+
after: ['first-story'],
315+
label: 'Write MDX documentation',
257316
content: (
258317
<>
259-
Teams publish Storybook online to review and collaborate on works in progress. That
260-
allows developers, designers, PMs, and other stakeholders to check if the UI looks
261-
right without touching code or requiring a local dev environment.
318+
MDX files mix Markdown and Javascript/JSX to create rich interactive documentation.
319+
You can use Markdown&apos;s readable syntax (such as `# heading`) for your
320+
documentation, include stories defined in Component Story Format (CSF), and freely
321+
embed JSX component blocks at any point in the file. All at once.
262322
</>
263323
),
264324
},

0 commit comments

Comments
 (0)