-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 #9531 from atanasster/mdx-compiler-multiple-children
Addon-docs: Fix MDX stories with multiple children
- Loading branch information
Showing
6 changed files
with
118 additions
and
27 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
10 changes: 10 additions & 0 deletions
10
addons/docs/src/mdx/__testfixtures__/story-multiple-children.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,10 @@ | ||
import { Story, Meta } from '@storybook/addon-docs/blocks'; | ||
|
||
<Meta title="Multiple" /> | ||
|
||
# Multiple children | ||
|
||
<Story name="multiple children"> | ||
<p>Hello Child #1</p> | ||
<p>Hello Child #2</p> | ||
</Story> |
64 changes: 64 additions & 0 deletions
64
addons/docs/src/mdx/__testfixtures__/story-multiple-children.output.snapshot
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,64 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`docs-mdx-compiler-plugin story-multiple-children.mdx 1`] = ` | ||
"/* @jsx mdx */ | ||
import { assertIsFn, AddContext } from '@storybook/addon-docs/blocks'; | ||
|
||
import { Story, Meta } from '@storybook/addon-docs/blocks'; | ||
|
||
const makeShortcode = (name) => | ||
function MDXDefaultShortcode(props) { | ||
console.warn( | ||
'Component ' + | ||
name + | ||
' was not imported, exported, or provided by MDXProvider as global scope' | ||
); | ||
return <div {...props} />; | ||
}; | ||
|
||
const layoutProps = {}; | ||
const MDXLayout = 'wrapper'; | ||
function MDXContent({ components, ...props }) { | ||
return ( | ||
<MDXLayout {...layoutProps} {...props} components={components} mdxType=\\"MDXLayout\\"> | ||
<Meta title=\\"Multiple\\" mdxType=\\"Meta\\" /> | ||
<h1>{\`Multiple children\`}</h1> | ||
<Story name=\\"multiple children\\" mdxType=\\"Story\\"> | ||
<p>Hello Child #1</p> | ||
<p>Hello Child #2</p> | ||
</Story> | ||
</MDXLayout> | ||
); | ||
} | ||
|
||
MDXContent.isMDXComponent = true; | ||
|
||
export const multipleChildren = () => ( | ||
<> | ||
<p>Hello Child #1</p> | ||
<p>Hello Child #2</p> | ||
</> | ||
); | ||
multipleChildren.story = {}; | ||
multipleChildren.story.name = 'multiple children'; | ||
multipleChildren.story.parameters = { | ||
storySource: { source: '<p>Hello Child #1</p>\\\\n<p>Hello Child #2</p>' }, | ||
}; | ||
|
||
const componentMeta = { title: 'Multiple', includeStories: ['multipleChildren'] }; | ||
|
||
const mdxStoryNameToKey = { 'multiple children': 'multipleChildren' }; | ||
|
||
componentMeta.parameters = componentMeta.parameters || {}; | ||
componentMeta.parameters.docs = { | ||
...(componentMeta.parameters.docs || {}), | ||
page: () => ( | ||
<AddContext mdxStoryNameToKey={mdxStoryNameToKey} mdxComponentMeta={componentMeta}> | ||
<MDXContent /> | ||
</AddContext> | ||
), | ||
}; | ||
|
||
export default componentMeta; | ||
" | ||
`; |
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 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