-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(accordion): refactor storybook #420
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
74faf7b
Add missing prop type
jzempel 9d06982
Add initial MDX demo
jzempel be92f60
Remove styleguidist hints
jzempel d9c5efe
Fill out refactored accordion demo story
jzempel 1440ecf
Correct URL
jzempel d93c4e3
Template story alignment
jzempel 948abe5
Refactor .template story
jzempel 63e011d
Newline cleanup
jzempel 01ba62f
Package consistency
jzempel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,6 @@ | ||
import { Meta, Description } from '@storybook/addon-docs'; | ||
import README from '../README.md'; | ||
|
||
<Meta title="Packages/{{capitalize component}}/README" /> | ||
|
||
<Description>{README}</Description> |
44 changes: 44 additions & 0 deletions
44
packages/.template/demo/stories/{{capitalize component}}Story.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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright Zendesk, Inc. | ||
* | ||
* Use of this source code is governed under the Apache License, Version 2.0 | ||
* found at http://www.apache.org/licenses/LICENSE-2.0. | ||
*/ | ||
|
||
import React, { HTMLAttributes, HTMLProps } from 'react'; | ||
import { Story } from '@storybook/react'; | ||
import { | ||
I{{capitalize component}}ContainerProps, | ||
IUse{{capitalize component}}Props, | ||
IUse{{capitalize component}}ReturnValue, | ||
{{capitalize component}}Container, | ||
use{{capitalize component}} | ||
} from '@zendeskgarden/container-{{lowercase component}}'; | ||
|
||
const Container = ({ label, text }: I{{capitalize component}}ContainerProps & { text: string }) => ( | ||
<{{capitalize component}}Container> | ||
{({ get{{capitalize component}}Props }: IUse{{capitalize component}}ReturnValue) => <div {...get{{capitalize component}}Props({ label })}>{text}</div>} | ||
</{{capitalize component}}Container> | ||
); | ||
|
||
const Hook = ({ label, ...props }: IUse{{capitalize component}}Props & HTMLProps<HTMLAttributes<HTMLDivElement>>) => { | ||
const { get{{capitalize component}}Props } = use{{capitalize component}}({ label }); | ||
|
||
return <div {...get{{capitalize component}}Props()} {...props} />; | ||
}; | ||
|
||
interface IArgs extends I{{capitalize component}}ContainerProps { | ||
as: 'hook' | 'container'; | ||
text: string; | ||
} | ||
|
||
export const {{capitalize component}}Story: Story<IArgs> = ({ as, text, ...props }) => { | ||
switch (as) { | ||
case 'container': | ||
return <Container text={text} {...props} />; | ||
|
||
case 'hook': | ||
default: | ||
return <Hook {...props}>{text}</Hook>; | ||
} | ||
}; |
24 changes: 24 additions & 0 deletions
24
packages/.template/demo/{{lowercase component}}.stories.mdx
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,24 @@ | ||
import { Meta, ArgsTable, Canvas, Story } from '@storybook/addon-docs'; | ||
import { {{capitalize component}}Container } from '@zendeskgarden/container-{{lowercase component}}'; | ||
import { {{capitalize component}}Story } from './stories/{{capitalize component}}Story'; | ||
|
||
<Meta title="Packages/{{capitalize component}}" component={ {{capitalize component}}Container } /> | ||
|
||
# API | ||
|
||
<ArgsTable /> | ||
|
||
# Demo | ||
|
||
export const args = { as: 'hook', text: 'Hello world', label: 'test' }; | ||
|
||
export const argTypes = { | ||
as: { options: ['container', 'hook'], control: 'radio', table: { category: 'Story' } }, | ||
text: { table: { category: 'Story' } } | ||
}; | ||
|
||
<Canvas> | ||
<Story name="{{capitalize component}}" args={args} argTypes={argTypes}> | ||
{args => <{{capitalize component}}Story {...args} />} | ||
</Story> | ||
</Canvas> |
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
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
import { Meta, Description } from '@storybook/addon-docs'; | ||
import README from '../README.md'; | ||
|
||
<Meta title="Packages/Accordion/README" /> | ||
|
||
<Description>{README}</Description> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tags are leftover from styleguidist usage and prevent proper codeblock display in storybook.