Skip to content

Commit ddc3f3d

Browse files
authored
Updated Storybook Template files to for CSF 3 (#8788)
[Notion Task](https://www.notion.so/redwoodjs/generators-to-CSF-3-444966a53e5a462eab5d4c3f093ebbb3?pvs=4) ## Feature description Updated storybook stories for CSF 3 - Updated stories for cells, components, layouts, and pages Tested TypeScript - [x] cells - [x] components - [x] layouts - [x] pages Tested JavaScript - [x] cells - [x] components - [x] layouts - [x] pages
1 parent 0850c19 commit ddc3f3d

27 files changed

Lines changed: 527 additions & 350 deletions

File tree

__fixtures__/test-project/web/src/components/Author/Author.stories.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
// When you've added props to your component,
2-
// pass Storybook's `args` through this story to control it from the addons panel:
1+
// Pass props to your component by passing an `args` object to your story
32
//
4-
// ```tsx
5-
// import type { ComponentStory } from '@storybook/react'
6-
//
7-
// export const generated: ComponentStory<typeof Author> = (args) => {
8-
// return <Author {...args} />
3+
// ```jsx
4+
// export const Primary: Story = {
5+
// args: {
6+
// propName: propValue
7+
// }
98
// }
109
// ```
1110
//
1211
// See https://storybook.js.org/docs/react/writing-stories/args.
1312

14-
import type { ComponentMeta } from '@storybook/react'
13+
import type { Meta, StoryObj } from '@storybook/react'
1514

1615
import Author from './Author'
1716

17+
const meta: Meta<typeof Author> = {
18+
component: Author,
19+
}
20+
21+
export default meta
22+
23+
type Story = StoryObj<typeof Author>
24+
1825
const author = {
1926
email: 'story.user@email.com',
2027
fullName: 'Story User',
2128
}
2229

23-
export const generated = () => {
24-
return <Author author={author} />
30+
export const Primary: Story = {
31+
render: () => {
32+
return <Author author={author} />
33+
}
2534
}
26-
27-
export default {
28-
title: 'Components/Author',
29-
component: Author,
30-
} as ComponentMeta<typeof Author>
Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1-
import type { ComponentStory } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22

33
import { Loading, Empty, Failure, Success } from './AuthorCell'
44
import { standard } from './AuthorCell.mock'
55

6-
export const loading = () => {
7-
return Loading ? <Loading /> : <></>
6+
const meta: Meta = {
7+
title: 'Cells/AuthorCell',
88
}
99

10-
export const empty = () => {
11-
return Empty ? <Empty /> : <></>
10+
export default meta
11+
12+
export const loading: StoryObj<typeof Loading> = {
13+
render: () => {
14+
return Loading ? <Loading /> : <></>;
15+
},
1216
}
1317

14-
export const failure: ComponentStory<typeof Failure> = (args) => {
15-
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : <></>
18+
export const empty: StoryObj<typeof Empty> = {
19+
render: () => {
20+
return Empty ? <Empty /> : <></>;
21+
},
1622
}
1723

18-
export const success: ComponentStory<typeof Success> = (args) => {
19-
return Success ? <Success {...standard()} {...args} /> : <></>
24+
export const failure: StoryObj<typeof Failure> = {
25+
render: (args) => {
26+
return Failure ? <Failure error={new Error("Oh no")} {...args} /> : <></>;
27+
},
2028
}
2129

22-
export default { title: 'Cells/AuthorCell' }
30+
export const success: StoryObj<typeof Success> = {
31+
render: (args) => {
32+
return Success ? <Success {...standard()} {...args} /> : <></>;
33+
},
34+
}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
// When you've added props to your component,
2-
// pass Storybook's `args` through this story to control it from the addons panel:
1+
// Pass props to your component by passing an `args` object to your story
32
//
4-
// ```tsx
5-
// import type { ComponentStory } from '@storybook/react'
6-
//
7-
// export const generated: ComponentStory<typeof BlogPost> = (args) => {
8-
// return <BlogPost {...args} />
3+
// ```jsx
4+
// export const Primary: Story = {
5+
// args: {
6+
// propName: propValue
7+
// }
98
// }
109
// ```
1110
//
1211
// See https://storybook.js.org/docs/react/writing-stories/args.
1312

14-
import type { ComponentMeta } from '@storybook/react'
13+
import type { Meta, StoryObj } from '@storybook/react'
1514

1615
import BlogPost from './BlogPost'
1716

18-
export const generated = () => {
19-
return <BlogPost />
17+
const meta: Meta<typeof BlogPost> = {
18+
component: BlogPost,
2019
}
2120

22-
export default {
23-
title: 'Components/BlogPost',
24-
component: BlogPost,
25-
} as ComponentMeta<typeof BlogPost>
21+
export default meta
22+
23+
type Story = StoryObj<typeof BlogPost>
24+
25+
export const Primary: Story = {}
Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1-
import type { ComponentStory } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22

33
import { Loading, Empty, Failure, Success } from './BlogPostCell'
44
import { standard } from './BlogPostCell.mock'
55

6-
export const loading = () => {
7-
return Loading ? <Loading /> : <></>
6+
const meta: Meta = {
7+
title: 'Cells/BlogPostCell',
88
}
99

10-
export const empty = () => {
11-
return Empty ? <Empty /> : <></>
10+
export default meta
11+
12+
export const loading: StoryObj<typeof Loading> = {
13+
render: () => {
14+
return Loading ? <Loading /> : <></>;
15+
},
1216
}
1317

14-
export const failure: ComponentStory<typeof Failure> = (args) => {
15-
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : <></>
18+
export const empty: StoryObj<typeof Empty> = {
19+
render: () => {
20+
return Empty ? <Empty /> : <></>;
21+
},
1622
}
1723

18-
export const success: ComponentStory<typeof Success> = (args) => {
19-
return Success ? <Success {...standard()} {...args} /> : <></>
24+
export const failure: StoryObj<typeof Failure> = {
25+
render: (args) => {
26+
return Failure ? <Failure error={new Error("Oh no")} {...args} /> : <></>;
27+
},
2028
}
2129

22-
export default { title: 'Cells/BlogPostCell' }
30+
export const success: StoryObj<typeof Success> = {
31+
render: (args) => {
32+
return Success ? <Success {...standard()} {...args} /> : <></>;
33+
},
34+
}
Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1-
import type { ComponentStory } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22

33
import { Loading, Empty, Failure, Success } from './BlogPostsCell'
44
import { standard } from './BlogPostsCell.mock'
55

6-
export const loading = () => {
7-
return Loading ? <Loading /> : <></>
6+
const meta: Meta = {
7+
title: 'Cells/BlogPostsCell',
88
}
99

10-
export const empty = () => {
11-
return Empty ? <Empty /> : <></>
10+
export default meta
11+
12+
export const loading: StoryObj<typeof Loading> = {
13+
render: () => {
14+
return Loading ? <Loading /> : <></>;
15+
},
1216
}
1317

14-
export const failure: ComponentStory<typeof Failure> = (args) => {
15-
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : <></>
18+
export const empty: StoryObj<typeof Empty> = {
19+
render: () => {
20+
return Empty ? <Empty /> : <></>;
21+
},
1622
}
1723

18-
export const success: ComponentStory<typeof Success> = (args) => {
19-
return Success ? <Success {...standard()} {...args} /> : <></>
24+
export const failure: StoryObj<typeof Failure> = {
25+
render: (args) => {
26+
return Failure ? <Failure error={new Error("Oh no")} {...args} /> : <></>;
27+
},
2028
}
2129

22-
export default { title: 'Cells/BlogPostsCell' }
30+
export const success: StoryObj<typeof Success> = {
31+
render: (args) => {
32+
return Success ? <Success {...standard()} {...args} /> : <></>;
33+
},
34+
}
Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1-
import type { ComponentStory } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22

33
import { Loading, Empty, Failure, Success } from './WaterfallBlogPostCell'
44
import { standard } from './WaterfallBlogPostCell.mock'
55

6-
export const loading = () => {
7-
return Loading ? <Loading /> : <></>
6+
const meta: Meta = {
7+
title: 'Cells/WaterfallBlogPostCell',
88
}
99

10-
export const empty = () => {
11-
return Empty ? <Empty /> : <></>
10+
export default meta
11+
12+
export const loading: StoryObj<typeof Loading> = {
13+
render: () => {
14+
return Loading ? <Loading /> : <></>;
15+
},
1216
}
1317

14-
export const failure: ComponentStory<typeof Failure> = (args) => {
15-
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : <></>
18+
export const empty: StoryObj<typeof Empty> = {
19+
render: () => {
20+
return Empty ? <Empty /> : <></>;
21+
},
1622
}
1723

18-
export const success: ComponentStory<typeof Success> = (args) => {
19-
return Success ? <Success {...standard()} {...args} /> : <></>
24+
export const failure: StoryObj<typeof Failure> = {
25+
render: (args) => {
26+
return Failure ? <Failure error={new Error("Oh no")} {...args} /> : <></>;
27+
},
2028
}
2129

22-
export default { title: 'Cells/WaterfallBlogPostCell' }
30+
export const success: StoryObj<typeof Success> = {
31+
render: (args) => {
32+
return Success ? <Success {...standard()} {...args} /> : <></>;
33+
},
34+
}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import type { ComponentMeta, ComponentStory } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22

33
import BlogLayout from './BlogLayout'
44

5-
export const generated: ComponentStory<typeof BlogLayout> = (args) => {
6-
return <BlogLayout {...args} />
5+
const meta: Meta<typeof BlogLayout> = {
6+
component: BlogLayout,
77
}
88

9-
export default {
10-
title: 'Layouts/BlogLayout',
11-
component: BlogLayout,
12-
} as ComponentMeta<typeof BlogLayout>
9+
export default meta
10+
11+
type Story = StoryObj<typeof BlogLayout>
12+
13+
export const Primary: Story = {}
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import type { ComponentMeta } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22

33
import AboutPage from './AboutPage'
44

5-
export const generated = () => {
6-
return <AboutPage />
7-
}
8-
9-
export default {
10-
title: 'Pages/AboutPage',
5+
const meta: Meta<typeof AboutPage> = {
116
component: AboutPage,
12-
} as ComponentMeta<typeof AboutPage>
7+
};
8+
9+
export default meta
10+
11+
type Story = StoryObj<typeof AboutPage>
12+
13+
export const Primary: Story = {}
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
import type { ComponentMeta, ComponentStory } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22

33
import BlogPostPage from './BlogPostPage'
44

5-
export const generated: ComponentStory<typeof BlogPostPage> = (args) => {
6-
return <BlogPostPage id={42} {...args} />
5+
const meta: Meta<typeof BlogPostPage> = {
6+
component: BlogPostPage,
77
}
88

9-
export default {
10-
title: 'Pages/BlogPostPage',
11-
component: BlogPostPage,
12-
} as ComponentMeta<typeof BlogPostPage>
9+
export default meta
10+
11+
type Story = StoryObj<typeof BlogPostPage>
12+
13+
export const Primary: Story = {
14+
render: (args) => {
15+
return <BlogPostPage id={42} {...args} />
16+
}
17+
}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import type { ComponentMeta } from '@storybook/react'
1+
import type { Meta, StoryObj } from '@storybook/react'
22

33
import ContactUsPage from './ContactUsPage'
44

5-
export const generated = () => {
6-
return <ContactUsPage />
5+
const meta: Meta<typeof ContactUsPage> = {
6+
component: ContactUsPage,
77
}
88

9-
export default {
10-
title: 'Pages/ContactUsPage',
11-
component: ContactUsPage,
12-
} as ComponentMeta<typeof ContactUsPage>
9+
export default meta
10+
11+
type Story = StoryObj<typeof ContactUsPage>
12+
13+
export const Primary: Story = {}

0 commit comments

Comments
 (0)