Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Codemod: Convert module format to MDX (#7418)
Codemod: Convert module format to MDX
- Loading branch information
Showing
31 changed files
with
424 additions
and
5 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
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
20 changes: 20 additions & 0 deletions
20
lib/codemod/src/transforms/__testfixtures__/convert-module-to-mdx/basic.input.js
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,20 @@ | ||
import React from 'react'; | ||
import Button from './Button'; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
export default { | ||
title: 'Button', | ||
}; | ||
|
||
export const story1 = () => <Button label="Story 1" />; | ||
|
||
export const story2 = () => <Button label="Story 2" onClick={action('click')} />; | ||
story2.story = { name: 'second story' }; | ||
|
||
export const story3 = () => ( | ||
<div> | ||
<Button label="The Button" onClick={action('onClick')} /> | ||
<br /> | ||
</div> | ||
); | ||
story3.story = { name: 'complex story' }; |
15 changes: 15 additions & 0 deletions
15
lib/codemod/src/transforms/__testfixtures__/convert-module-to-mdx/basic.output.js
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,15 @@ | ||
import React from 'react'; | ||
import Button from './Button'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { Meta, Story } from '@storybook/addon-docs/blocks'; | ||
|
||
<Meta title='Button' /> | ||
|
||
<Story name='story1'><Button label='Story 1' /></Story> | ||
|
||
<Story name='second story'><Button label='Story 2' onClick={action('click')} /></Story> | ||
|
||
<Story name='complex story'><div> | ||
<Button label='The Button' onClick={action('onClick')} /> | ||
<br /> | ||
</div></Story> |
10 changes: 10 additions & 0 deletions
10
lib/codemod/src/transforms/__testfixtures__/convert-module-to-mdx/decorators.input.js
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 React from 'react'; | ||
import Button from './Button'; | ||
|
||
export default { | ||
title: 'Some.Button', | ||
decorators: [withKnobs, storyFn => <div className="foo">{storyFn}</div>], | ||
}; | ||
|
||
export const story1 = () => <Button label="The Button" />; | ||
story1.story = { name: 'with decorator' }; |
9 changes: 9 additions & 0 deletions
9
lib/codemod/src/transforms/__testfixtures__/convert-module-to-mdx/decorators.output.js
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,9 @@ | ||
import React from 'react'; | ||
import Button from './Button'; | ||
import { Meta, Story } from '@storybook/addon-docs/blocks'; | ||
|
||
<Meta | ||
title='Some.Button' | ||
decorators={[withKnobs, storyFn => <div className='foo'>{storyFn}</div>]} /> | ||
|
||
<Story name='with decorator'><Button label='The Button' /></Story> |
23 changes: 23 additions & 0 deletions
23
lib/codemod/src/transforms/__testfixtures__/convert-module-to-mdx/exclude-stories.input.js
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,23 @@ | ||
import React from 'react'; | ||
import Button from './Button'; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
export default { | ||
title: 'Button', | ||
excludeStories: /.*Data$/, | ||
}; | ||
|
||
export const rowData = { col1: 'a', col2: 2 }; | ||
|
||
export const story1 = () => <Button label="Story 1" />; | ||
|
||
export const story2 = () => <Button label="Story 2" onClick={action('click')} />; | ||
story2.story = { name: 'second story' }; | ||
|
||
export const story3 = () => ( | ||
<div> | ||
<Button label="The Button" onClick={action('onClick')} /> | ||
<br /> | ||
</div> | ||
); | ||
story3.story = { name: 'complex story' }; |
19 changes: 19 additions & 0 deletions
19
lib/codemod/src/transforms/__testfixtures__/convert-module-to-mdx/exclude-stories.output.js
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,19 @@ | ||
import React from 'react'; | ||
import Button from './Button'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { Meta, Story } from '@storybook/addon-docs/blocks'; | ||
|
||
<Meta title='Button' /> | ||
|
||
export const rowData = { | ||
col1: 'a', | ||
col2: 2, | ||
}; | ||
<Story name='story1'><Button label='Story 1' /></Story> | ||
|
||
<Story name='second story'><Button label='Story 2' onClick={action('click')} /></Story> | ||
|
||
<Story name='complex story'><div> | ||
<Button label='The Button' onClick={action('onClick')} /> | ||
<br /> | ||
</div></Story> |
17 changes: 17 additions & 0 deletions
17
lib/codemod/src/transforms/__testfixtures__/convert-module-to-mdx/parameters.input.js
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,17 @@ | ||
import React from 'react'; | ||
import Button from './Button'; | ||
|
||
import { storiesOf } from '@storybook/react'; | ||
|
||
export default { | ||
title: 'Button', | ||
|
||
parameters: { | ||
component: Button, | ||
foo: 1, | ||
bar: 2, | ||
}, | ||
}; | ||
|
||
export const story1 = () => <Button label="The Button" />; | ||
story1.story = { name: 'with kind parameters' }; |
14 changes: 14 additions & 0 deletions
14
lib/codemod/src/transforms/__testfixtures__/convert-module-to-mdx/parameters.output.js
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,14 @@ | ||
import React from 'react'; | ||
import Button from './Button'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { Meta, Story } from '@storybook/addon-docs/blocks'; | ||
|
||
<Meta | ||
title='Button' | ||
parameters={{ | ||
component: Button, | ||
foo: 1, | ||
bar: 2, | ||
}} /> | ||
|
||
<Story name='with kind parameters'><Button label='The Button' /></Story> |
24 changes: 24 additions & 0 deletions
24
lib/codemod/src/transforms/__testfixtures__/convert-module-to-mdx/story-parameters.input.js
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 React from 'react'; | ||
import Button from './Button'; | ||
|
||
import { storiesOf } from '@storybook/react'; | ||
|
||
export default { | ||
title: 'Button', | ||
}; | ||
|
||
export const story1 = () => <Button label="The Button" />; | ||
story1.story = { | ||
name: 'with story parameters', | ||
parameters: { | ||
header: false, | ||
inline: true, | ||
}, | ||
}; | ||
|
||
export const foo = () => <Button label="Foo" />; | ||
foo.story = { | ||
parameters: { | ||
bar: 1, | ||
}, | ||
}; |
19 changes: 19 additions & 0 deletions
19
lib/codemod/src/transforms/__testfixtures__/convert-module-to-mdx/story-parameters.output.js
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,19 @@ | ||
import React from 'react'; | ||
import Button from './Button'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { Meta, Story } from '@storybook/addon-docs/blocks'; | ||
|
||
<Meta title='Button' /> | ||
|
||
<Story | ||
name='with story parameters' | ||
parameters={{ | ||
header: false, | ||
inline: true, | ||
}}><Button label='The Button' /></Story> | ||
|
||
<Story | ||
name='foo' | ||
parameters={{ | ||
bar: 1, | ||
}}><Button label='Foo' /></Story> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
lib/codemod/src/transforms/__tests__/convert-module-to-mdx.test.js
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,7 @@ | ||
import { defineTest } from 'jscodeshift/dist/testUtils'; | ||
|
||
const testNames = ['basic', 'decorators', 'parameters', 'story-parameters', 'exclude-stories']; | ||
|
||
testNames.forEach(testName => { | ||
defineTest(__dirname, `convert-module-to-mdx`, null, `convert-module-to-mdx/${testName}`); | ||
}); |
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
Oops, something went wrong.
c33c4c2
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.
Successfully aliased the URL https://monorepo-inzwg4lib.now.sh to the following aliases: