-
Notifications
You must be signed in to change notification settings - Fork 995
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve typing on generated storybook components (#6226)
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com> Co-authored-by: Daniel Choudhury <dannychoudhury@gmail.com> Co-authored-by: Dominic Saadi <dominiceliassaadi@gmail.com>
- Loading branch information
1 parent
49edca7
commit 6f11bc7
Showing
31 changed files
with
365 additions
and
165 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 21 additions & 3 deletions
24
__fixtures__/test-project/web/src/components/Author/Author.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
// When you've added props to your component, | ||
// pass Storybook's `args` through this story to control it from the addons panel: | ||
// | ||
// ```tsx | ||
// import type { ComponentStory } from '@storybook/react' | ||
// | ||
// export const generated: ComponentStory<typeof Author> = (args) => { | ||
// return <Author {...args} /> | ||
// } | ||
// ``` | ||
// | ||
// See https://storybook.js.org/docs/react/writing-stories/args. | ||
|
||
import type { ComponentMeta } from '@storybook/react' | ||
|
||
import Author from './Author' | ||
|
||
const author = { | ||
email: 'story.user@email.com', | ||
fullName: 'Story User', | ||
} | ||
|
||
export const generated = (args) => { | ||
return <Author {...args} author={author} /> | ||
export const generated = () => { | ||
return <Author author={author} /> | ||
} | ||
|
||
export default { title: 'Components/Author' } | ||
export default { | ||
title: 'Components/Author', | ||
component: Author, | ||
} as ComponentMeta<typeof Author> |
18 changes: 10 additions & 8 deletions
18
__fixtures__/test-project/web/src/components/AuthorCell/AuthorCell.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
import type { ComponentStory } from '@storybook/react' | ||
|
||
import { Loading, Empty, Failure, Success } from './AuthorCell' | ||
import { standard } from './AuthorCell.mock' | ||
|
||
export const loading = (args) => { | ||
return Loading ? <Loading {...args} /> : null | ||
export const loading = () => { | ||
return Loading ? <Loading /> : <></> | ||
} | ||
|
||
export const empty = (args) => { | ||
return Empty ? <Empty {...args} /> : null | ||
export const empty = () => { | ||
return Empty ? <Empty /> : <></> | ||
} | ||
|
||
export const failure = (args) => { | ||
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : null | ||
export const failure: ComponentStory<typeof Failure> = (args) => { | ||
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : <></> | ||
} | ||
|
||
export const success = (args) => { | ||
return Success ? <Success {...standard()} {...args} /> : null | ||
export const success: ComponentStory<typeof Success> = (args) => { | ||
return Success ? <Success {...standard()} {...args} /> : <></> | ||
} | ||
|
||
export default { title: 'Cells/AuthorCell' } |
24 changes: 21 additions & 3 deletions
24
__fixtures__/test-project/web/src/components/BlogPost/BlogPost.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,25 @@ | ||
// When you've added props to your component, | ||
// pass Storybook's `args` through this story to control it from the addons panel: | ||
// | ||
// ```tsx | ||
// import type { ComponentStory } from '@storybook/react' | ||
// | ||
// export const generated: ComponentStory<typeof BlogPost> = (args) => { | ||
// return <BlogPost {...args} /> | ||
// } | ||
// ``` | ||
// | ||
// See https://storybook.js.org/docs/react/writing-stories/args. | ||
|
||
import type { ComponentMeta } from '@storybook/react' | ||
|
||
import BlogPost from './BlogPost' | ||
|
||
export const generated = (args) => { | ||
return <BlogPost {...args} /> | ||
export const generated = () => { | ||
return <BlogPost /> | ||
} | ||
|
||
export default { title: 'Components/BlogPost' } | ||
export default { | ||
title: 'Components/BlogPost', | ||
component: BlogPost, | ||
} as ComponentMeta<typeof BlogPost> |
18 changes: 10 additions & 8 deletions
18
__fixtures__/test-project/web/src/components/BlogPostCell/BlogPostCell.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
import type { ComponentStory } from '@storybook/react' | ||
|
||
import { Loading, Empty, Failure, Success } from './BlogPostCell' | ||
import { standard } from './BlogPostCell.mock' | ||
|
||
export const loading = (args) => { | ||
return Loading ? <Loading {...args} /> : null | ||
export const loading = () => { | ||
return Loading ? <Loading /> : <></> | ||
} | ||
|
||
export const empty = (args) => { | ||
return Empty ? <Empty {...args} /> : null | ||
export const empty = () => { | ||
return Empty ? <Empty /> : <></> | ||
} | ||
|
||
export const failure = (args) => { | ||
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : null | ||
export const failure: ComponentStory<typeof Failure> = (args) => { | ||
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : <></> | ||
} | ||
|
||
export const success = (args) => { | ||
return Success ? <Success {...standard()} {...args} /> : null | ||
export const success: ComponentStory<typeof Success> = (args) => { | ||
return Success ? <Success {...standard()} {...args} /> : <></> | ||
} | ||
|
||
export default { title: 'Cells/BlogPostCell' } |
18 changes: 10 additions & 8 deletions
18
__fixtures__/test-project/web/src/components/BlogPostsCell/BlogPostsCell.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
import type { ComponentStory } from '@storybook/react' | ||
|
||
import { Loading, Empty, Failure, Success } from './BlogPostsCell' | ||
import { standard } from './BlogPostsCell.mock' | ||
|
||
export const loading = (args) => { | ||
return Loading ? <Loading {...args} /> : null | ||
export const loading = () => { | ||
return Loading ? <Loading /> : <></> | ||
} | ||
|
||
export const empty = (args) => { | ||
return Empty ? <Empty {...args} /> : null | ||
export const empty = () => { | ||
return Empty ? <Empty /> : <></> | ||
} | ||
|
||
export const failure = (args) => { | ||
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : null | ||
export const failure: ComponentStory<typeof Failure> = (args) => { | ||
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : <></> | ||
} | ||
|
||
export const success = (args) => { | ||
return Success ? <Success {...standard()} {...args} /> : null | ||
export const success: ComponentStory<typeof Success> = (args) => { | ||
return Success ? <Success {...standard()} {...args} /> : <></> | ||
} | ||
|
||
export default { title: 'Cells/BlogPostsCell' } |
18 changes: 10 additions & 8 deletions
18
..._/test-project/web/src/components/WaterfallBlogPostCell/WaterfallBlogPostCell.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
import type { ComponentStory } from '@storybook/react' | ||
|
||
import { Loading, Empty, Failure, Success } from './WaterfallBlogPostCell' | ||
import { standard } from './WaterfallBlogPostCell.mock' | ||
|
||
export const loading = (args) => { | ||
return Loading ? <Loading {...args} /> : null | ||
export const loading = () => { | ||
return Loading ? <Loading /> : <></> | ||
} | ||
|
||
export const empty = (args) => { | ||
return Empty ? <Empty {...args} /> : null | ||
export const empty = () => { | ||
return Empty ? <Empty /> : <></> | ||
} | ||
|
||
export const failure = (args) => { | ||
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : null | ||
export const failure: ComponentStory<typeof Failure> = (args) => { | ||
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : <></> | ||
} | ||
|
||
export const success = (args) => { | ||
return Success ? <Success {...standard()} {...args} /> : null | ||
export const success: ComponentStory<typeof Success> = (args) => { | ||
return Success ? <Success {...standard()} {...args} /> : <></> | ||
} | ||
|
||
export default { title: 'Cells/WaterfallBlogPostCell' } |
9 changes: 7 additions & 2 deletions
9
__fixtures__/test-project/web/src/layouts/BlogLayout/BlogLayout.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import type { ComponentMeta, ComponentStory } from '@storybook/react' | ||
|
||
import BlogLayout from './BlogLayout' | ||
|
||
export const generated = (args) => { | ||
export const generated: ComponentStory<typeof BlogLayout> = (args) => { | ||
return <BlogLayout {...args} /> | ||
} | ||
|
||
export default { title: 'Layouts/BlogLayout' } | ||
export default { | ||
title: 'Layouts/BlogLayout', | ||
component: BlogLayout, | ||
} as ComponentMeta<typeof BlogLayout> |
11 changes: 8 additions & 3 deletions
11
__fixtures__/test-project/web/src/pages/AboutPage/AboutPage.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import type { ComponentMeta } from '@storybook/react' | ||
|
||
import AboutPage from './AboutPage' | ||
|
||
export const generated = (args) => { | ||
return <AboutPage {...args} /> | ||
export const generated = () => { | ||
return <AboutPage /> | ||
} | ||
|
||
export default { title: 'Pages/AboutPage' } | ||
export default { | ||
title: 'Pages/AboutPage', | ||
component: AboutPage, | ||
} as ComponentMeta<typeof AboutPage> |
9 changes: 7 additions & 2 deletions
9
__fixtures__/test-project/web/src/pages/BlogPostPage/BlogPostPage.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import type { ComponentMeta, ComponentStory } from '@storybook/react' | ||
|
||
import BlogPostPage from './BlogPostPage' | ||
|
||
export const generated = (args) => { | ||
export const generated: ComponentStory<typeof BlogPostPage> = (args) => { | ||
return <BlogPostPage id={42} {...args} /> | ||
} | ||
|
||
export default { title: 'Pages/BlogPostPage' } | ||
export default { | ||
title: 'Pages/BlogPostPage', | ||
component: BlogPostPage, | ||
} as ComponentMeta<typeof BlogPostPage> |
11 changes: 8 additions & 3 deletions
11
__fixtures__/test-project/web/src/pages/ContactPage/ContactPage.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import type { ComponentMeta } from '@storybook/react' | ||
|
||
import ContactPage from './ContactPage' | ||
|
||
export const generated = (args) => { | ||
return <ContactPage {...args} /> | ||
export const generated = () => { | ||
return <ContactPage /> | ||
} | ||
|
||
export default { title: 'Pages/ContactPage' } | ||
export default { | ||
title: 'Pages/ContactPage', | ||
component: ContactPage, | ||
} as ComponentMeta<typeof ContactPage> |
11 changes: 8 additions & 3 deletions
11
__fixtures__/test-project/web/src/pages/HomePage/HomePage.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import type { ComponentMeta } from '@storybook/react' | ||
|
||
import HomePage from './HomePage' | ||
|
||
export const generated = (args) => { | ||
return <HomePage {...args} /> | ||
export const generated = () => { | ||
return <HomePage /> | ||
} | ||
|
||
export default { title: 'Pages/HomePage' } | ||
export default { | ||
title: 'Pages/HomePage', | ||
component: HomePage, | ||
} as ComponentMeta<typeof HomePage> |
11 changes: 8 additions & 3 deletions
11
__fixtures__/test-project/web/src/pages/ProfilePage/ProfilePage.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import type { ComponentMeta } from '@storybook/react' | ||
|
||
import ProfilePage from './ProfilePage' | ||
|
||
export const generated = (args) => { | ||
return <ProfilePage {...args} /> | ||
export const generated = () => { | ||
return <ProfilePage /> | ||
} | ||
|
||
export default { title: 'Pages/ProfilePage' } | ||
export default { | ||
title: 'Pages/ProfilePage', | ||
component: ProfilePage, | ||
} as ComponentMeta<typeof ProfilePage> |
9 changes: 7 additions & 2 deletions
9
__fixtures__/test-project/web/src/pages/WaterfallPage/WaterfallPage.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import type { ComponentMeta, ComponentStory } from '@storybook/react' | ||
|
||
import WaterfallPage from './WaterfallPage' | ||
|
||
export const generated = (args) => { | ||
export const generated: ComponentStory<typeof WaterfallPage> = (args) => { | ||
return <WaterfallPage id={42} {...args} /> | ||
} | ||
|
||
export default { title: 'Pages/WaterfallPage' } | ||
export default { | ||
title: 'Pages/WaterfallPage', | ||
component: WaterfallPage, | ||
} as ComponentMeta<typeof WaterfallPage> |
Oops, something went wrong.