This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export disabled argTypes from .storybook/preview.js (#149)
* Export disabled argTypes from .storybook/preview.js * Add DocsPage with code snippets
- Loading branch information
1 parent
e00749e
commit 1d72fbc
Showing
3 changed files
with
514 additions
and
476 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
Canvas, | ||
Component, | ||
Description, | ||
DocsContext, | ||
Heading, | ||
SourceState, | ||
Story, | ||
StoryProps, | ||
} from '@storybook/addon-docs'; | ||
import { components } from '@storybook/components'; | ||
|
||
function DocsPage(): React.ReactElement { | ||
const { id, title, storyById, componentStories } = | ||
React.useContext(DocsContext); | ||
const stories = componentStories(); | ||
const currentStory = storyById(id); | ||
const { component } = currentStory; | ||
const componentDisplayName = (component as Component)?.__docgenInfo | ||
?.displayName; | ||
|
||
return ( | ||
<> | ||
<Heading>{componentDisplayName || title}</Heading> | ||
<Description of={components} /> | ||
{stories.map((story, index) => ( | ||
<Canvas withSource={SourceState.OPEN} key={index}> | ||
<Story {...(story as StoryProps)} /> | ||
</Canvas> | ||
))} | ||
</> | ||
); | ||
} | ||
|
||
export default DocsPage; |
Oops, something went wrong.