-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14780 from storybookjs/feat/react-component-story
React: Add ComponentStory convenience type
- Loading branch information
Showing
3 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ComponentProps, JSXElementConstructor } from 'react'; | ||
import type { Story, Meta } from './types-6-0'; | ||
|
||
export * from './types-6-0'; | ||
|
||
/** | ||
* For the common case where a component's stories are simple components that receives args as props: | ||
* | ||
* ```tsx | ||
* export default { ... } as ComponentMeta<typeof Button>; | ||
* ``` | ||
*/ | ||
export type ComponentMeta< | ||
T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> | ||
> = Meta<ComponentProps<T>>; | ||
|
||
/** | ||
* For the common case where a story is a simple component that receives args as props: | ||
* | ||
* ```tsx | ||
* const Template: ComponentStory<typeof Button> = (args) => <Button {...args} /> | ||
* ``` | ||
*/ | ||
export type ComponentStory< | ||
T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> | ||
> = Story<ComponentProps<T>>; |
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