Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Export disabled argTypes from .storybook/preview.js (#149)
Browse files Browse the repository at this point in the history
* Export disabled argTypes from .storybook/preview.js

* Add DocsPage with code snippets
  • Loading branch information
juliewongbandue authored Jul 27, 2022
1 parent e00749e commit 1d72fbc
Show file tree
Hide file tree
Showing 3 changed files with 514 additions and 476 deletions.
37 changes: 37 additions & 0 deletions .storybook/DocsPage.tsx
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;
Loading

0 comments on commit 1d72fbc

Please sign in to comment.