@storybook/codemod 7.0.0-alpha.7 → 7.0.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. package/README.md +0 -36
  2. package/dist/index.d.ts +261 -0
  3. package/dist/index.js +1 -0
  4. package/dist/index.mjs +1 -0
  5. package/jest.config.js +7 -0
  6. package/package.json +32 -29
  7. package/src/index.js +77 -0
  8. package/src/lib/utils.test.js +9 -0
  9. package/{dist/esm/lib/utils.js → src/lib/utils.ts} +10 -11
  10. package/src/transforms/__testfixtures__/add-component-parameters/add-component-parameters.input.js +44 -0
  11. package/src/transforms/__testfixtures__/add-component-parameters/add-component-parameters.output.snapshot +68 -0
  12. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/basic.input.js +25 -0
  13. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/basic.output.snapshot +27 -0
  14. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/overrides.input.js +25 -0
  15. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/overrides.output.snapshot +28 -0
  16. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/variable.input.js +13 -0
  17. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/variable.output.snapshot +17 -0
  18. package/src/transforms/__testfixtures__/csf-to-mdx/basic.input.js +20 -0
  19. package/src/transforms/__testfixtures__/csf-to-mdx/basic.output.snapshot +18 -0
  20. package/src/transforms/__testfixtures__/csf-to-mdx/component-id.input.js +9 -0
  21. package/src/transforms/__testfixtures__/csf-to-mdx/component-id.output.snapshot +10 -0
  22. package/src/transforms/__testfixtures__/csf-to-mdx/decorators.input.js +13 -0
  23. package/src/transforms/__testfixtures__/csf-to-mdx/decorators.output.snapshot +12 -0
  24. package/src/transforms/__testfixtures__/csf-to-mdx/exclude-stories.input.js +23 -0
  25. package/src/transforms/__testfixtures__/csf-to-mdx/exclude-stories.output.snapshot +22 -0
  26. package/src/transforms/__testfixtures__/csf-to-mdx/parameters.input.js +16 -0
  27. package/src/transforms/__testfixtures__/csf-to-mdx/parameters.output.snapshot +17 -0
  28. package/src/transforms/__testfixtures__/csf-to-mdx/story-function.input.js +19 -0
  29. package/src/transforms/__testfixtures__/csf-to-mdx/story-function.output.snapshot +18 -0
  30. package/src/transforms/__testfixtures__/csf-to-mdx/story-parameters.input.js +24 -0
  31. package/src/transforms/__testfixtures__/csf-to-mdx/story-parameters.output.snapshot +22 -0
  32. package/src/transforms/__testfixtures__/mdx-to-csf/basic.input.js +18 -0
  33. package/src/transforms/__testfixtures__/mdx-to-csf/basic.output.snapshot +40 -0
  34. package/src/transforms/__testfixtures__/mdx-to-csf/component-id.input.js +6 -0
  35. package/src/transforms/__testfixtures__/mdx-to-csf/component-id.output.snapshot +17 -0
  36. package/src/transforms/__testfixtures__/mdx-to-csf/decorators.input.js +8 -0
  37. package/src/transforms/__testfixtures__/mdx-to-csf/decorators.output.snapshot +18 -0
  38. package/src/transforms/__testfixtures__/mdx-to-csf/exclude-stories.input.js +19 -0
  39. package/src/transforms/__testfixtures__/mdx-to-csf/exclude-stories.output.snapshot +39 -0
  40. package/src/transforms/__testfixtures__/mdx-to-csf/parameters.input.js +14 -0
  41. package/src/transforms/__testfixtures__/mdx-to-csf/parameters.output.snapshot +23 -0
  42. package/src/transforms/__testfixtures__/mdx-to-csf/plaintext.input.js +3 -0
  43. package/src/transforms/__testfixtures__/mdx-to-csf/plaintext.output.snapshot +11 -0
  44. package/src/transforms/__testfixtures__/mdx-to-csf/story-function.input.js +10 -0
  45. package/src/transforms/__testfixtures__/mdx-to-csf/story-function.output.snapshot +18 -0
  46. package/src/transforms/__testfixtures__/mdx-to-csf/story-parameters.input.js +18 -0
  47. package/src/transforms/__testfixtures__/mdx-to-csf/story-parameters.output.snapshot +32 -0
  48. package/src/transforms/__testfixtures__/mdx-to-csf/story-refs.input.js +22 -0
  49. package/src/transforms/__testfixtures__/mdx-to-csf/story-refs.output.snapshot +34 -0
  50. package/src/transforms/__testfixtures__/move-builtin-addons/default.input.js +2 -0
  51. package/src/transforms/__testfixtures__/move-builtin-addons/default.output.snapshot +8 -0
  52. package/src/transforms/__testfixtures__/move-builtin-addons/with-no-change.input.js +3 -0
  53. package/src/transforms/__testfixtures__/move-builtin-addons/with-no-change.output.snapshot +7 -0
  54. package/src/transforms/__testfixtures__/storiesof-to-csf/basic.input.js +18 -0
  55. package/src/transforms/__testfixtures__/storiesof-to-csf/basic.output.snapshot +45 -0
  56. package/src/transforms/__testfixtures__/storiesof-to-csf/collision.input.js +11 -0
  57. package/src/transforms/__testfixtures__/storiesof-to-csf/collision.output.snapshot +38 -0
  58. package/src/transforms/__testfixtures__/storiesof-to-csf/const.input.js +1 -0
  59. package/src/transforms/__testfixtures__/storiesof-to-csf/const.output.snapshot +13 -0
  60. package/src/transforms/__testfixtures__/storiesof-to-csf/decorators.input.js +9 -0
  61. package/src/transforms/__testfixtures__/storiesof-to-csf/decorators.output.snapshot +18 -0
  62. package/src/transforms/__testfixtures__/storiesof-to-csf/default.input.js +7 -0
  63. package/src/transforms/__testfixtures__/storiesof-to-csf/default.output.snapshot +17 -0
  64. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.input.js +1 -0
  65. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.output.js +5 -0
  66. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.output.snapshot +9 -0
  67. package/src/transforms/__testfixtures__/storiesof-to-csf/export-destructuring.input.js +11 -0
  68. package/src/transforms/__testfixtures__/storiesof-to-csf/export-destructuring.output.snapshot +23 -0
  69. package/src/transforms/__testfixtures__/storiesof-to-csf/export-function.input.js +12 -0
  70. package/src/transforms/__testfixtures__/storiesof-to-csf/export-function.output.snapshot +23 -0
  71. package/src/transforms/__testfixtures__/storiesof-to-csf/export-names.input.js +14 -0
  72. package/src/transforms/__testfixtures__/storiesof-to-csf/export-names.output.snapshot +26 -0
  73. package/src/transforms/__testfixtures__/storiesof-to-csf/exports.input.js +2 -0
  74. package/src/transforms/__testfixtures__/storiesof-to-csf/exports.output.snapshot +16 -0
  75. package/src/transforms/__testfixtures__/storiesof-to-csf/module.input.js +12 -0
  76. package/src/transforms/__testfixtures__/storiesof-to-csf/module.output.snapshot +16 -0
  77. package/src/transforms/__testfixtures__/storiesof-to-csf/multi.input.js +14 -0
  78. package/src/transforms/__testfixtures__/storiesof-to-csf/multi.output.snapshot +39 -0
  79. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters-as-var.input.js +8 -0
  80. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters-as-var.output.snapshot +20 -0
  81. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters.input.js +10 -0
  82. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters.output.snapshot +23 -0
  83. package/src/transforms/__testfixtures__/storiesof-to-csf/storiesof-var.input.js +11 -0
  84. package/src/transforms/__testfixtures__/storiesof-to-csf/storiesof-var.output.snapshot +23 -0
  85. package/src/transforms/__testfixtures__/storiesof-to-csf/story-decorators.input.js +11 -0
  86. package/src/transforms/__testfixtures__/storiesof-to-csf/story-decorators.output.snapshot +29 -0
  87. package/src/transforms/__testfixtures__/storiesof-to-csf/story-parameters.input.js +14 -0
  88. package/src/transforms/__testfixtures__/storiesof-to-csf/story-parameters.output.snapshot +32 -0
  89. package/src/transforms/__testfixtures__/update-addon-info/update-addon-info.input.js +198 -0
  90. package/src/transforms/__testfixtures__/update-addon-info/update-addon-info.output.snapshot +198 -0
  91. package/src/transforms/__testfixtures__/update-organisation-name/update-organisation-name.input.js +19 -0
  92. package/src/transforms/__testfixtures__/update-organisation-name/update-organisation-name.output.snapshot +23 -0
  93. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/csf.input.js +3 -0
  94. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/csf.output.snapshot +7 -0
  95. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/dynamic-storiesof.input.js +5 -0
  96. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/dynamic-storiesof.output.snapshot +9 -0
  97. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/storiesof.input.js +8 -0
  98. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/storiesof.output.snapshot +12 -0
  99. package/src/transforms/__tests__/csf-2-to-3.test.ts +250 -0
  100. package/src/transforms/__tests__/transforms.tests.js +32 -0
  101. package/{dist/esm → src}/transforms/add-component-parameters.js +26 -21
  102. package/src/transforms/csf-2-to-3.ts +184 -0
  103. package/src/transforms/csf-hoist-story-annotations.js +97 -0
  104. package/src/transforms/csf-to-mdx.js +190 -0
  105. package/src/transforms/move-builtin-addons.js +32 -0
  106. package/src/transforms/storiesof-to-csf.js +277 -0
  107. package/{dist/esm → src}/transforms/update-addon-info.js +44 -24
  108. package/{dist/esm → src}/transforms/update-organisation-name.js +21 -24
  109. package/src/transforms/upgrade-hierarchy-separators.js +39 -0
  110. package/tsconfig.json +7 -0
  111. package/LICENSE +0 -21
  112. package/dist/cjs/index.js +0 -142
  113. package/dist/cjs/lib/utils.js +0 -45
  114. package/dist/cjs/transforms/add-component-parameters.js +0 -64
  115. package/dist/cjs/transforms/csf-2-to-3.js +0 -180
  116. package/dist/cjs/transforms/csf-hoist-story-annotations.js +0 -93
  117. package/dist/cjs/transforms/csf-to-mdx.js +0 -196
  118. package/dist/cjs/transforms/mdx-to-csf.js +0 -153
  119. package/dist/cjs/transforms/move-builtin-addons.js +0 -57
  120. package/dist/cjs/transforms/storiesof-to-csf.js +0 -300
  121. package/dist/cjs/transforms/update-addon-info.js +0 -101
  122. package/dist/cjs/transforms/update-organisation-name.js +0 -83
  123. package/dist/cjs/transforms/upgrade-hierarchy-separators.js +0 -42
  124. package/dist/esm/index.js +0 -99
  125. package/dist/esm/transforms/csf-2-to-3.js +0 -163
  126. package/dist/esm/transforms/csf-hoist-story-annotations.js +0 -86
  127. package/dist/esm/transforms/csf-to-mdx.js +0 -188
  128. package/dist/esm/transforms/mdx-to-csf.js +0 -139
  129. package/dist/esm/transforms/move-builtin-addons.js +0 -50
  130. package/dist/esm/transforms/storiesof-to-csf.js +0 -287
  131. package/dist/esm/transforms/upgrade-hierarchy-separators.js +0 -35
  132. package/dist/types/lib/utils.d.ts +0 -2
  133. package/dist/types/transforms/csf-2-to-3.d.ts +0 -6
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import Button from './Button';
3
+ import { action } from '@storybook/addon-actions';
4
+
5
+ export default {
6
+ title: 'Button',
7
+ };
8
+
9
+ export const story1 = () => <Button label="Story 1" />;
10
+
11
+ export const story2 = () => <Button label="Story 2" onClick={action('click')} />;
12
+ story2.story = { name: 'second story' };
13
+
14
+ export const story3 = () => (
15
+ <div>
16
+ <Button label="The Button" onClick={action('onClick')} />
17
+ <br />
18
+ </div>
19
+ );
20
+ const baz = 17;
21
+ story3.story = {
22
+ name: 'complex story',
23
+ parameters: { foo: { bar: baz } },
24
+ decorators: [(storyFn) => <bar>{storyFn}</bar>],
25
+ };
@@ -0,0 +1,27 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`csf-hoist-story-annotations transforms correctly using "basic.input.js" data 1`] = `
4
+ "import React from 'react';
5
+ import Button from './Button';
6
+ import { action } from '@storybook/addon-actions';
7
+
8
+ export default {
9
+ title: 'Button',
10
+ };
11
+
12
+ export const story1 = () => <Button label=\\"Story 1\\" />;
13
+
14
+ export const story2 = () => <Button label=\\"Story 2\\" onClick={action('click')} />;
15
+ story2.storyName = 'second story';
16
+
17
+ export const story3 = () => (
18
+ <div>
19
+ <Button label=\\"The Button\\" onClick={action('onClick')} />
20
+ <br />
21
+ </div>
22
+ );
23
+ const baz = 17;
24
+ story3.storyName = 'complex story';
25
+ story3.parameters = { foo: { bar: baz } };
26
+ story3.decorators = [(storyFn) => <bar>{storyFn}</bar>];"
27
+ `;
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import Button from './Button';
3
+ import { action } from '@storybook/addon-actions';
4
+
5
+ export default {
6
+ title: 'Button',
7
+ };
8
+
9
+ export const story1 = () => <Button label="Story 1" />;
10
+
11
+ export const story2 = () => <Button label="Story 2" onClick={action('click')} />;
12
+ story2.story = { name: 'second story' };
13
+ story2.story.parameters = { foo: 'bar' };
14
+
15
+ export const story3 = () => (
16
+ <div>
17
+ <Button label="The Button" onClick={action('onClick')} />
18
+ <br />
19
+ </div>
20
+ );
21
+ const baz = 17;
22
+ story3.story = {};
23
+ story3.story.name = 'complex story';
24
+ story3.story.parameters = { foo: { bar: baz } };
25
+ story3.story.decorators = [(storyFn) => <bar>{storyFn}</bar>];
@@ -0,0 +1,28 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`csf-hoist-story-annotations transforms correctly using "overrides.input.js" data 1`] = `
4
+ "import React from 'react';
5
+ import Button from './Button';
6
+ import { action } from '@storybook/addon-actions';
7
+
8
+ export default {
9
+ title: 'Button',
10
+ };
11
+
12
+ export const story1 = () => <Button label=\\"Story 1\\" />;
13
+
14
+ export const story2 = () => <Button label=\\"Story 2\\" onClick={action('click')} />;
15
+ story2.storyName = 'second story';
16
+ story2.parameters = { foo: 'bar' };
17
+
18
+ export const story3 = () => (
19
+ <div>
20
+ <Button label=\\"The Button\\" onClick={action('onClick')} />
21
+ <br />
22
+ </div>
23
+ );
24
+ const baz = 17;
25
+ story3.storyName = 'complex story';
26
+ story3.parameters = { foo: { bar: baz } };
27
+ story3.decorators = [(storyFn) => <bar>{storyFn}</bar>];"
28
+ `;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import Button from './Button';
3
+
4
+ const foo = {
5
+ title: 'Button',
6
+ };
7
+
8
+ export default foo;
9
+
10
+ const bar = () => <Button label="Story 1" />;
11
+ bar.story = { name: 'bar bar' };
12
+
13
+ export const story1 = bar;
@@ -0,0 +1,17 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`csf-hoist-story-annotations transforms correctly using "variable.input.js" data 1`] = `
4
+ "import React from 'react';
5
+ import Button from './Button';
6
+
7
+ const foo = {
8
+ title: 'Button',
9
+ };
10
+
11
+ export default foo;
12
+
13
+ const bar = () => <Button label=\\"Story 1\\" />;
14
+ bar.story = { name: 'bar bar' };
15
+
16
+ export const story1 = bar;"
17
+ `;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import Button from './Button';
3
+ import { action } from '@storybook/addon-actions';
4
+
5
+ export default {
6
+ title: 'Button',
7
+ };
8
+
9
+ export const story1 = () => <Button label="Story 1" />;
10
+
11
+ export const story2 = () => <Button label="Story 2" onClick={action('click')} />;
12
+ story2.story = { name: 'second story' };
13
+
14
+ export const story3 = () => (
15
+ <div>
16
+ <Button label="The Button" onClick={action('onClick')} />
17
+ <br />
18
+ </div>
19
+ );
20
+ story3.story = { name: 'complex story' };
@@ -0,0 +1,18 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`csf-to-mdx transforms correctly using "basic.input.js" data 1`] = `
4
+ "import Button from './Button';
5
+ import { action } from '@storybook/addon-actions';
6
+ import { Meta, Story } from '@storybook/addon-docs';
7
+
8
+ <Meta title='Button' />
9
+
10
+ <Story name='story1'><Button label='Story 1' /></Story>
11
+
12
+ <Story name='second story'><Button label='Story 2' onClick={action('click')} /></Story>
13
+
14
+ <Story name='complex story'><div>
15
+ <Button label='The Button' onClick={action('onClick')} />
16
+ <br />
17
+ </div></Story>"
18
+ `;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import Button from './Button';
3
+
4
+ export default {
5
+ title: 'Button',
6
+ id: 'button-id',
7
+ };
8
+
9
+ export const someStory = () => <Button label="Story 1" />;
@@ -0,0 +1,10 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`csf-to-mdx transforms correctly using "component-id.input.js" data 1`] = `
4
+ "import Button from './Button';
5
+ import { Meta, Story } from '@storybook/addon-docs';
6
+
7
+ <Meta title='Button' id='button-id' />
8
+
9
+ <Story name='someStory'><Button label='Story 1' /></Story>"
10
+ `;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import Button from './Button';
3
+
4
+ export default {
5
+ title: 'Some.Button',
6
+ decorators: [withKnobs, storyFn => <div className="foo">{storyFn}</div>],
7
+ };
8
+
9
+ export const story1 = () => <Button label="The Button" />;
10
+ story1.story = {
11
+ name: 'with decorator',
12
+ decorators: [withKnobs],
13
+ };
@@ -0,0 +1,12 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`csf-to-mdx transforms correctly using "decorators.input.js" data 1`] = `
4
+ "import Button from './Button';
5
+ import { Meta, Story } from '@storybook/addon-docs';
6
+
7
+ <Meta
8
+ title='Some.Button'
9
+ decorators={[withKnobs, storyFn => <div className='foo'>{storyFn}</div>]} />
10
+
11
+ <Story name='with decorator' decorators={[withKnobs]}><Button label='The Button' /></Story>"
12
+ `;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import Button from './Button';
3
+ import { action } from '@storybook/addon-actions';
4
+
5
+ export default {
6
+ title: 'Button',
7
+ excludeStories: /.*Data$/,
8
+ };
9
+
10
+ export const rowData = { col1: 'a', col2: 2 };
11
+
12
+ export const story1 = () => <Button label="Story 1" />;
13
+
14
+ export const story2 = () => <Button label="Story 2" onClick={action('click')} />;
15
+ story2.story = { name: 'second story' };
16
+
17
+ export const story3 = () => (
18
+ <div>
19
+ <Button label="The Button" onClick={action('onClick')} />
20
+ <br />
21
+ </div>
22
+ );
23
+ story3.story = { name: 'complex story' };
@@ -0,0 +1,22 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`csf-to-mdx transforms correctly using "exclude-stories.input.js" data 1`] = `
4
+ "import Button from './Button';
5
+ import { action } from '@storybook/addon-actions';
6
+ import { Meta, Story } from '@storybook/addon-docs';
7
+
8
+ <Meta title='Button' />
9
+
10
+ export const rowData = {
11
+ col1: 'a',
12
+ col2: 2,
13
+ };
14
+ <Story name='story1'><Button label='Story 1' /></Story>
15
+
16
+ <Story name='second story'><Button label='Story 2' onClick={action('click')} /></Story>
17
+
18
+ <Story name='complex story'><div>
19
+ <Button label='The Button' onClick={action('onClick')} />
20
+ <br />
21
+ </div></Story>"
22
+ `;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import Button from './Button';
3
+
4
+ import { storiesOf } from '@storybook/react';
5
+
6
+ export default {
7
+ title: 'Button',
8
+ component: Button,
9
+ parameters: {
10
+ foo: 1,
11
+ bar: 2,
12
+ },
13
+ };
14
+
15
+ export const story1 = () => <Button label="The Button" />;
16
+ story1.story = { name: 'with kind parameters' };
@@ -0,0 +1,17 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`csf-to-mdx transforms correctly using "parameters.input.js" data 1`] = `
4
+ "import Button from './Button';
5
+ import { storiesOf } from '@storybook/react';
6
+ import { Meta, Story } from '@storybook/addon-docs';
7
+
8
+ <Meta
9
+ title='Button'
10
+ component={Button}
11
+ parameters={{
12
+ foo: 1,
13
+ bar: 2,
14
+ }} />
15
+
16
+ <Story name='with kind parameters'><Button label='The Button' /></Story>"
17
+ `;
@@ -0,0 +1,19 @@
1
+ import global from 'global';
2
+
3
+ const { document } = global;
4
+
5
+ export default {
6
+ title: 'Function',
7
+ };
8
+
9
+ export const functionStory = () => {
10
+ const btn = document.createElement('button');
11
+ btn.innerHTML = 'Hello Button';
12
+ btn.addEventListener('click', action('Click'));
13
+ return btn;
14
+ };
15
+
16
+ functionStory.story = {
17
+ name: 'function',
18
+ height: '100px',
19
+ };
@@ -0,0 +1,18 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`csf-to-mdx transforms correctly using "story-function.input.js" data 1`] = `
4
+ "import global from 'global';
5
+ import { Meta, Story } from '@storybook/addon-docs';
6
+
7
+ const {
8
+ document,
9
+ } = global;
10
+ <Meta title='Function' />
11
+
12
+ <Story name='function' height='100px'>{() => {
13
+ const btn = document.createElement('button');
14
+ btn.innerHTML = 'Hello Button';
15
+ btn.addEventListener('click', action('Click'));
16
+ return btn;
17
+ }}</Story>"
18
+ `;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import Button from './Button';
3
+
4
+ import { storiesOf } from '@storybook/react';
5
+
6
+ export default {
7
+ title: 'Button',
8
+ };
9
+
10
+ export const story1 = () => <Button label="The Button" />;
11
+ story1.story = {
12
+ name: 'with story parameters',
13
+ parameters: {
14
+ header: false,
15
+ inline: true,
16
+ },
17
+ };
18
+
19
+ export const foo = () => <Button label="Foo" />;
20
+ foo.story = {
21
+ parameters: {
22
+ bar: 1,
23
+ },
24
+ };
@@ -0,0 +1,22 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`csf-to-mdx transforms correctly using "story-parameters.input.js" data 1`] = `
4
+ "import Button from './Button';
5
+ import { storiesOf } from '@storybook/react';
6
+ import { Meta, Story } from '@storybook/addon-docs';
7
+
8
+ <Meta title='Button' />
9
+
10
+ <Story
11
+ name='with story parameters'
12
+ parameters={{
13
+ header: false,
14
+ inline: true,
15
+ }}><Button label='The Button' /></Story>
16
+
17
+ <Story
18
+ name='foo'
19
+ parameters={{
20
+ bar: 1,
21
+ }}><Button label='Foo' /></Story>"
22
+ `;
@@ -0,0 +1,18 @@
1
+ import Button from './Button';
2
+ import { action } from '@storybook/addon-actions';
3
+ import { Meta, Story } from '@storybook/addon-docs';
4
+
5
+ <Meta title='Button' />
6
+
7
+ <Story name='story1'><Button label='Story 1' /></Story>
8
+
9
+ <Story name='second story'><Button label='Story 2' onClick={action('click')} /></Story>
10
+
11
+ <Story name='complex story'><div>
12
+ <Button label='The Button' onClick={action('onClick')} />
13
+ <br />
14
+ </div></Story>
15
+
16
+ <Story name='w/punctuation'>
17
+ <Button label='w/punctuation'/>
18
+ </Story>
@@ -0,0 +1,40 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`mdx-to-csf transforms correctly using "basic.input.js" data 1`] = `
4
+ "import React from 'react';
5
+ import Button from './Button';
6
+ import { action } from '@storybook/addon-actions';
7
+
8
+ export default {
9
+ title: 'Button',
10
+ };
11
+
12
+ export const Story1 = () => <Button label=\\"Story 1\\" />;
13
+
14
+ Story1.story = {
15
+ name: 'story1',
16
+ };
17
+
18
+ export const SecondStory = () => <Button label=\\"Story 2\\" onClick={action('click')} />;
19
+
20
+ SecondStory.story = {
21
+ name: 'second story',
22
+ };
23
+
24
+ export const ComplexStory = () => (
25
+ <div>
26
+ <Button label=\\"The Button\\" onClick={action('onClick')} />
27
+ <br />
28
+ </div>
29
+ );
30
+
31
+ ComplexStory.story = {
32
+ name: 'complex story',
33
+ };
34
+
35
+ export const WPunctuation = () => <Button label=\\"w/punctuation\\" />;
36
+
37
+ WPunctuation.story = {
38
+ name: 'w/punctuation',
39
+ };"
40
+ `;
@@ -0,0 +1,6 @@
1
+ import Button from './Button';
2
+ import { Meta, Story } from '@storybook/addon-docs';
3
+
4
+ <Meta title='Button' id="button-id" />
5
+
6
+ <Story name='story1'><Button label='Story 1' /></Story>
@@ -0,0 +1,17 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`mdx-to-csf transforms correctly using "component-id.input.js" data 1`] = `
4
+ "import React from 'react';
5
+ import Button from './Button';
6
+
7
+ export default {
8
+ title: 'Button',
9
+ id: 'button-id',
10
+ };
11
+
12
+ export const Story1 = () => <Button label=\\"Story 1\\" />;
13
+
14
+ Story1.story = {
15
+ name: 'story1',
16
+ };"
17
+ `;
@@ -0,0 +1,8 @@
1
+ import Button from './Button';
2
+ import { Meta, Story } from '@storybook/addon-docs';
3
+
4
+ <Meta
5
+ title='Some.Button'
6
+ decorators={[withKnobs, storyFn => <div className='foo'>{storyFn}</div>]} />
7
+
8
+ <Story name='with decorator' decorators={[withKnobs]}><Button label='The Button' /></Story>
@@ -0,0 +1,18 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`mdx-to-csf transforms correctly using "decorators.input.js" data 1`] = `
4
+ "import React from 'react';
5
+ import Button from './Button';
6
+
7
+ export default {
8
+ title: 'Some.Button',
9
+ decorators: [withKnobs, (storyFn) => <div className=\\"foo\\">{storyFn}</div>],
10
+ };
11
+
12
+ export const WithDecorator = () => <Button label=\\"The Button\\" />;
13
+
14
+ WithDecorator.story = {
15
+ name: 'with decorator',
16
+ decorators: [withKnobs],
17
+ };"
18
+ `;
@@ -0,0 +1,19 @@
1
+ import Button from './Button';
2
+ import { action } from '@storybook/addon-actions';
3
+ import { Meta, Story } from '@storybook/addon-docs';
4
+
5
+ <Meta title='Button' />
6
+
7
+ export const rowData = {
8
+ col1: 'a',
9
+ col2: 2,
10
+ };
11
+
12
+ <Story name='story1'><Button label='Story 1' /></Story>
13
+
14
+ <Story name='second story'><Button label='Story 2' onClick={action('click')} /></Story>
15
+
16
+ <Story name='complex story'><div>
17
+ <Button label='The Button' onClick={action('onClick')} />
18
+ <br />
19
+ </div></Story>
@@ -0,0 +1,39 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`mdx-to-csf transforms correctly using "exclude-stories.input.js" data 1`] = `
4
+ "import React from 'react';
5
+ import Button from './Button';
6
+ import { action } from '@storybook/addon-actions';
7
+ export const rowData = {
8
+ col1: 'a',
9
+ col2: 2,
10
+ };
11
+
12
+ export default {
13
+ title: 'Button',
14
+ includeStories: ['Story1', 'SecondStory', 'ComplexStory'],
15
+ };
16
+
17
+ export const Story1 = () => <Button label=\\"Story 1\\" />;
18
+
19
+ Story1.story = {
20
+ name: 'story1',
21
+ };
22
+
23
+ export const SecondStory = () => <Button label=\\"Story 2\\" onClick={action('click')} />;
24
+
25
+ SecondStory.story = {
26
+ name: 'second story',
27
+ };
28
+
29
+ export const ComplexStory = () => (
30
+ <div>
31
+ <Button label=\\"The Button\\" onClick={action('onClick')} />
32
+ <br />
33
+ </div>
34
+ );
35
+
36
+ ComplexStory.story = {
37
+ name: 'complex story',
38
+ };"
39
+ `;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import Button from './Button';
3
+ import { storiesOf } from '@storybook/react';
4
+ import { Meta, Story } from '@storybook/addon-docs';
5
+
6
+ <Meta
7
+ title='Button'
8
+ component={Button}
9
+ parameters={{
10
+ foo: 1,
11
+ bar: 2,
12
+ }} />
13
+
14
+ <Story name='with kind parameters'><Button label='The Button' /></Story>
@@ -0,0 +1,23 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`mdx-to-csf transforms correctly using "parameters.input.js" data 1`] = `
4
+ "import React from 'react';
5
+ import Button from './Button';
6
+ import { storiesOf } from '@storybook/react';
7
+
8
+ export default {
9
+ title: 'Button',
10
+ component: Button,
11
+
12
+ parameters: {
13
+ foo: 1,
14
+ bar: 2,
15
+ },
16
+ };
17
+
18
+ export const WithKindParameters = () => <Button label=\\"The Button\\" />;
19
+
20
+ WithKindParameters.story = {
21
+ name: 'with kind parameters',
22
+ };"
23
+ `;
@@ -0,0 +1,3 @@
1
+ import { Story, Meta } from '@storybook/addon-docs';
2
+
3
+ <Story name="plaintext">Plain text</Story>;
@@ -0,0 +1,11 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`mdx-to-csf transforms correctly using "plaintext.input.js" data 1`] = `
4
+ "import React from 'react';
5
+ export default {};
6
+ export const Plaintext = () => 'Plain text';
7
+
8
+ Plaintext.story = {
9
+ name: 'plaintext',
10
+ };"
11
+ `;
@@ -0,0 +1,10 @@
1
+ import { Story, Meta } from '@storybook/addon-docs';
2
+
3
+ <Story name="function" height="100px">
4
+ {() => {
5
+ const btn = document.createElement('button');
6
+ btn.innerHTML = 'Hello Button';
7
+ btn.addEventListener('click', action('Click'));
8
+ return btn;
9
+ }}
10
+ </Story>;