@storybook/codemod 0.0.0-pr-23609-sha-f47ef339

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +262 -0
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.js +1 -0
  4. package/dist/transforms/add-component-parameters.d.ts +22 -0
  5. package/dist/transforms/add-component-parameters.js +1 -0
  6. package/dist/transforms/csf-2-to-3.d.ts +8 -0
  7. package/dist/transforms/csf-2-to-3.js +3 -0
  8. package/dist/transforms/csf-hoist-story-annotations.d.ts +26 -0
  9. package/dist/transforms/csf-hoist-story-annotations.js +1 -0
  10. package/dist/transforms/mdx-to-csf.d.ts +7 -0
  11. package/dist/transforms/mdx-to-csf.js +61 -0
  12. package/dist/transforms/move-builtin-addons.d.ts +3 -0
  13. package/dist/transforms/move-builtin-addons.js +1 -0
  14. package/dist/transforms/storiesof-to-csf.d.ts +24 -0
  15. package/dist/transforms/storiesof-to-csf.js +1 -0
  16. package/dist/transforms/update-addon-info.d.ts +27 -0
  17. package/dist/transforms/update-addon-info.js +1 -0
  18. package/dist/transforms/update-organisation-name.d.ts +25 -0
  19. package/dist/transforms/update-organisation-name.js +1 -0
  20. package/dist/transforms/upgrade-deprecated-types.d.ts +10 -0
  21. package/dist/transforms/upgrade-deprecated-types.js +2 -0
  22. package/dist/transforms/upgrade-hierarchy-separators.d.ts +3 -0
  23. package/dist/transforms/upgrade-hierarchy-separators.js +1 -0
  24. package/jest.config.js +9 -0
  25. package/package.json +102 -0
  26. package/project.json +6 -0
  27. package/src/index.ts +103 -0
  28. package/src/lib/utils.test.js +9 -0
  29. package/src/lib/utils.ts +29 -0
  30. package/src/transforms/__testfixtures__/add-component-parameters/add-component-parameters.input.js +44 -0
  31. package/src/transforms/__testfixtures__/add-component-parameters/add-component-parameters.output.snapshot +68 -0
  32. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/basic.input.js +25 -0
  33. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/basic.output.snapshot +27 -0
  34. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/overrides.input.js +25 -0
  35. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/overrides.output.snapshot +28 -0
  36. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/variable.input.js +13 -0
  37. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/variable.output.snapshot +17 -0
  38. package/src/transforms/__testfixtures__/mdx-to-csf/basic.input.mdx +18 -0
  39. package/src/transforms/__testfixtures__/mdx-to-csf/basic.output.snapshot +40 -0
  40. package/src/transforms/__testfixtures__/mdx-to-csf/component-id.input.mdx +6 -0
  41. package/src/transforms/__testfixtures__/mdx-to-csf/component-id.output.snapshot +17 -0
  42. package/src/transforms/__testfixtures__/mdx-to-csf/decorators.input.mdx +8 -0
  43. package/src/transforms/__testfixtures__/mdx-to-csf/decorators.output.snapshot +18 -0
  44. package/src/transforms/__testfixtures__/mdx-to-csf/exclude-stories.input.mdx +19 -0
  45. package/src/transforms/__testfixtures__/mdx-to-csf/exclude-stories.output.snapshot +39 -0
  46. package/src/transforms/__testfixtures__/mdx-to-csf/parameters.input.mdx +14 -0
  47. package/src/transforms/__testfixtures__/mdx-to-csf/parameters.output.snapshot +23 -0
  48. package/src/transforms/__testfixtures__/mdx-to-csf/plaintext.input.mdx +3 -0
  49. package/src/transforms/__testfixtures__/mdx-to-csf/plaintext.output.snapshot +11 -0
  50. package/src/transforms/__testfixtures__/mdx-to-csf/story-function.input.mdx +10 -0
  51. package/src/transforms/__testfixtures__/mdx-to-csf/story-function.output.snapshot +18 -0
  52. package/src/transforms/__testfixtures__/mdx-to-csf/story-parameters.input.mdx +18 -0
  53. package/src/transforms/__testfixtures__/mdx-to-csf/story-parameters.output.snapshot +32 -0
  54. package/src/transforms/__testfixtures__/mdx-to-csf/story-refs.input.mdx +22 -0
  55. package/src/transforms/__testfixtures__/mdx-to-csf/story-refs.output.snapshot +34 -0
  56. package/src/transforms/__testfixtures__/move-builtin-addons/default.input.js +2 -0
  57. package/src/transforms/__testfixtures__/move-builtin-addons/default.output.snapshot +8 -0
  58. package/src/transforms/__testfixtures__/move-builtin-addons/with-no-change.input.js +3 -0
  59. package/src/transforms/__testfixtures__/move-builtin-addons/with-no-change.output.snapshot +7 -0
  60. package/src/transforms/__testfixtures__/storiesof-to-csf/basic.input.js +18 -0
  61. package/src/transforms/__testfixtures__/storiesof-to-csf/basic.output.snapshot +45 -0
  62. package/src/transforms/__testfixtures__/storiesof-to-csf/collision.input.js +11 -0
  63. package/src/transforms/__testfixtures__/storiesof-to-csf/collision.output.snapshot +38 -0
  64. package/src/transforms/__testfixtures__/storiesof-to-csf/const.input.js +1 -0
  65. package/src/transforms/__testfixtures__/storiesof-to-csf/const.output.snapshot +13 -0
  66. package/src/transforms/__testfixtures__/storiesof-to-csf/decorators.input.js +9 -0
  67. package/src/transforms/__testfixtures__/storiesof-to-csf/decorators.output.snapshot +18 -0
  68. package/src/transforms/__testfixtures__/storiesof-to-csf/default.input.js +7 -0
  69. package/src/transforms/__testfixtures__/storiesof-to-csf/default.output.snapshot +17 -0
  70. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.input.js +1 -0
  71. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.output.js +5 -0
  72. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.output.snapshot +9 -0
  73. package/src/transforms/__testfixtures__/storiesof-to-csf/export-destructuring.input.js +11 -0
  74. package/src/transforms/__testfixtures__/storiesof-to-csf/export-destructuring.output.snapshot +23 -0
  75. package/src/transforms/__testfixtures__/storiesof-to-csf/export-function.input.js +12 -0
  76. package/src/transforms/__testfixtures__/storiesof-to-csf/export-function.output.snapshot +23 -0
  77. package/src/transforms/__testfixtures__/storiesof-to-csf/export-names.input.js +14 -0
  78. package/src/transforms/__testfixtures__/storiesof-to-csf/export-names.output.snapshot +26 -0
  79. package/src/transforms/__testfixtures__/storiesof-to-csf/exports.input.js +2 -0
  80. package/src/transforms/__testfixtures__/storiesof-to-csf/exports.output.snapshot +16 -0
  81. package/src/transforms/__testfixtures__/storiesof-to-csf/module.input.js +12 -0
  82. package/src/transforms/__testfixtures__/storiesof-to-csf/module.output.snapshot +16 -0
  83. package/src/transforms/__testfixtures__/storiesof-to-csf/multi.input.js +14 -0
  84. package/src/transforms/__testfixtures__/storiesof-to-csf/multi.output.snapshot +39 -0
  85. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters-as-var.input.js +8 -0
  86. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters-as-var.output.snapshot +20 -0
  87. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters.input.js +10 -0
  88. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters.output.snapshot +23 -0
  89. package/src/transforms/__testfixtures__/storiesof-to-csf/storiesof-var.input.js +11 -0
  90. package/src/transforms/__testfixtures__/storiesof-to-csf/storiesof-var.output.snapshot +23 -0
  91. package/src/transforms/__testfixtures__/storiesof-to-csf/story-decorators.input.js +11 -0
  92. package/src/transforms/__testfixtures__/storiesof-to-csf/story-decorators.output.snapshot +29 -0
  93. package/src/transforms/__testfixtures__/storiesof-to-csf/story-parameters.input.js +14 -0
  94. package/src/transforms/__testfixtures__/storiesof-to-csf/story-parameters.output.snapshot +32 -0
  95. package/src/transforms/__testfixtures__/update-addon-info/update-addon-info.input.js +184 -0
  96. package/src/transforms/__testfixtures__/update-addon-info/update-addon-info.output.snapshot +184 -0
  97. package/src/transforms/__testfixtures__/update-organisation-name/update-organisation-name.input.js +19 -0
  98. package/src/transforms/__testfixtures__/update-organisation-name/update-organisation-name.output.snapshot +23 -0
  99. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/csf.input.js +3 -0
  100. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/csf.output.snapshot +7 -0
  101. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/dynamic-storiesof.input.js +5 -0
  102. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/dynamic-storiesof.output.snapshot +9 -0
  103. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/storiesof.input.js +8 -0
  104. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/storiesof.output.snapshot +12 -0
  105. package/src/transforms/__tests__/csf-2-to-3.test.ts +439 -0
  106. package/src/transforms/__tests__/mdx-to-csf.test.ts +628 -0
  107. package/src/transforms/__tests__/transforms.tests.js +32 -0
  108. package/src/transforms/__tests__/upgrade-deprecated-types.test.ts +170 -0
  109. package/src/transforms/add-component-parameters.js +62 -0
  110. package/src/transforms/csf-2-to-3.ts +336 -0
  111. package/src/transforms/csf-hoist-story-annotations.js +97 -0
  112. package/src/transforms/mdx-to-csf.ts +340 -0
  113. package/src/transforms/move-builtin-addons.js +32 -0
  114. package/src/transforms/storiesof-to-csf.js +277 -0
  115. package/src/transforms/update-addon-info.js +114 -0
  116. package/src/transforms/update-organisation-name.js +71 -0
  117. package/src/transforms/upgrade-deprecated-types.ts +142 -0
  118. package/src/transforms/upgrade-hierarchy-separators.js +39 -0
  119. package/tsconfig.json +10 -0
@@ -0,0 +1,23 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`storiesof-to-csf transforms correctly using "export-destructuring.input.js" data 1`] = `
4
+ "/* eslint-disable import/no-extraneous-dependencies */
5
+ import React from 'react';
6
+ import ComponentRow from './ComponentRow';
7
+ import * as SpecRowStories from './SpecRow.stories';
8
+
9
+ export const { actions } = SpecRowStories;
10
+
11
+ export default {
12
+ title: 'ComponentRow',
13
+ excludeStories: ['actions'],
14
+ };
15
+
16
+ export const Pending = () => (
17
+ <ComponentRow snapshots={snapshots.pending} buildNumber={2} {...actions} />
18
+ );
19
+
20
+ Pending.story = {
21
+ name: 'pending',
22
+ };"
23
+ `;
@@ -0,0 +1,12 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import React from 'react';
3
+ import { storiesOf } from '@storybook/react';
4
+ import ComponentItem from './ComponentItem';
5
+
6
+ export function someHelper() {
7
+ return 5;
8
+ }
9
+
10
+ storiesOf('ComponentItem', module)
11
+ .addDecorator((storyFn) => <div style={{ margin: '1rem' }}>{storyFn()}</div>)
12
+ .add('loading', () => <ComponentItem loading />);
@@ -0,0 +1,23 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`storiesof-to-csf transforms correctly using "export-function.input.js" data 1`] = `
4
+ "/* eslint-disable import/no-extraneous-dependencies */
5
+ import React from 'react';
6
+ import ComponentItem from './ComponentItem';
7
+
8
+ export function someHelper() {
9
+ return 5;
10
+ }
11
+
12
+ export default {
13
+ title: 'ComponentItem',
14
+ decorators: [(storyFn) => <div style={{ margin: '1rem' }}>{storyFn()}</div>],
15
+ excludeStories: ['someHelper'],
16
+ };
17
+
18
+ export const Loading = () => <ComponentItem loading />;
19
+
20
+ Loading.story = {
21
+ name: 'loading',
22
+ };"
23
+ `;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import React from 'react';
3
+ import { storiesOf } from '@storybook/react';
4
+ import FlexCenter from './FlexCenter';
5
+ import { specs, urls } from './LiveView.stories';
6
+ import { ignoredRegions } from './IgnoredRegions.stories';
7
+
8
+ export { specs, urls, ignoredRegions };
9
+
10
+ storiesOf('FlexCenter', module).add('2:1', () => (
11
+ <FlexCenter width={200} height={100} style={{ background: 'papayawhip' }}>
12
+ <div style={{ padding: 30, background: 'hotpink' }}>2:1</div>
13
+ </FlexCenter>
14
+ ));
@@ -0,0 +1,26 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`storiesof-to-csf transforms correctly using "export-names.input.js" data 1`] = `
4
+ "/* eslint-disable import/no-extraneous-dependencies */
5
+ import React from 'react';
6
+ import FlexCenter from './FlexCenter';
7
+ import { specs, urls } from './LiveView.stories';
8
+ import { ignoredRegions } from './IgnoredRegions.stories';
9
+
10
+ export { specs, urls, ignoredRegions };
11
+
12
+ export default {
13
+ title: 'FlexCenter',
14
+ excludeStories: ['specs', 'urls', 'ignoredRegions'],
15
+ };
16
+
17
+ export const _21 = () => (
18
+ <FlexCenter width={200} height={100} style={{ background: 'papayawhip' }}>
19
+ <div style={{ padding: 30, background: 'hotpink' }}>2:1</div>
20
+ </FlexCenter>
21
+ );
22
+
23
+ _21.story = {
24
+ name: '2:1',
25
+ };"
26
+ `;
@@ -0,0 +1,2 @@
1
+ export const foo = 1;
2
+ storiesOf('bar', module).add('baz', () => <button />);
@@ -0,0 +1,16 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`storiesof-to-csf transforms correctly using "exports.input.js" data 1`] = `
4
+ "export const foo = 1;
5
+
6
+ export default {
7
+ title: 'bar',
8
+ excludeStories: ['foo'],
9
+ };
10
+
11
+ export const Baz = () => <button />;
12
+
13
+ Baz.story = {
14
+ name: 'baz',
15
+ };"
16
+ `;
@@ -0,0 +1,12 @@
1
+ /* eslint-disable */
2
+ import React from 'react';
3
+ import Button from './Button';
4
+ import { storiesOf } from '@storybook/react';
5
+
6
+ export default {
7
+ title: 'foo',
8
+ };
9
+
10
+ const bar = 1;
11
+
12
+ storiesOf('foo', module).add('bar', () => <Button />);
@@ -0,0 +1,16 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`storiesof-to-csf transforms correctly using "module.input.js" data 1`] = `
4
+ "/* eslint-disable */
5
+ import React from 'react';
6
+ import Button from './Button';
7
+ import { storiesOf } from '@storybook/react';
8
+
9
+ export default {
10
+ title: 'foo',
11
+ };
12
+
13
+ const bar = 1;
14
+
15
+ storiesOf('foo', module).add('bar', () => <Button />);"
16
+ `;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable */
2
+ import React from 'react';
3
+ import Button from './Button';
4
+
5
+ // If we have multiple storiesOf calls, export multiple defaults. It's not valid
6
+ // JS but will still save the user time in converting.
7
+
8
+ storiesOf('Button1', module)
9
+ .add('story1', () => <Button label="Button1.1" />)
10
+ .add('story2', () => <Button label="Button1.2" />);
11
+
12
+ storiesOf('Button2', module)
13
+ .add('story1', () => <Button label="Button2.1" />)
14
+ .add('story2', () => <Button label="Button2.2" />);
@@ -0,0 +1,39 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`storiesof-to-csf transforms correctly using "multi.input.js" data 1`] = `
4
+ "/* eslint-disable */
5
+ import React from 'react';
6
+ import Button from './Button';
7
+
8
+ export default {
9
+ title: 'Button1',
10
+ };
11
+
12
+ export const Story1 = () => <Button label=\\"Button1.1\\" />;
13
+
14
+ Story1.story = {
15
+ name: 'story1',
16
+ };
17
+
18
+ export const Story2 = () => <Button label=\\"Button1.2\\" />;
19
+
20
+ Story2.story = {
21
+ name: 'story2',
22
+ };
23
+
24
+ export default {
25
+ title: 'Button2',
26
+ };
27
+
28
+ export const _Story1 = () => <Button label=\\"Button2.1\\" />;
29
+
30
+ _Story1.story = {
31
+ name: 'story1',
32
+ };
33
+
34
+ export const _Story2 = () => <Button label=\\"Button2.2\\" />;
35
+
36
+ _Story2.story = {
37
+ name: 'story2',
38
+ };"
39
+ `;
@@ -0,0 +1,8 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import React from 'react';
3
+ import { storiesOf } from '@storybook/react';
4
+ import Canvas from './Canvas';
5
+
6
+ const CHROMATIC_DELAY = { chromatic: { delay: 500 } };
7
+
8
+ storiesOf('Canvas', module).add('loading', () => <Canvas loading />, CHROMATIC_DELAY);
@@ -0,0 +1,20 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`storiesof-to-csf transforms correctly using "parameters-as-var.input.js" data 1`] = `
4
+ "/* eslint-disable import/no-extraneous-dependencies */
5
+ import React from 'react';
6
+ import Canvas from './Canvas';
7
+
8
+ const CHROMATIC_DELAY = { chromatic: { delay: 500 } };
9
+
10
+ export default {
11
+ title: 'Canvas',
12
+ };
13
+
14
+ export const Loading = () => <Canvas loading />;
15
+
16
+ Loading.story = {
17
+ name: 'loading',
18
+ parameters: CHROMATIC_DELAY,
19
+ };"
20
+ `;
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+ import React from 'react';
3
+ import Button from './Button';
4
+
5
+ import { storiesOf } from '@storybook/react';
6
+
7
+ storiesOf('Button', module)
8
+ .addParameters({ component: Button, foo: 1 })
9
+ .addParameters({ bar: 2 })
10
+ .add('with kind parameters', () => <Button label="The Button" />);
@@ -0,0 +1,23 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`storiesof-to-csf transforms correctly using "parameters.input.js" data 1`] = `
4
+ "/* eslint-disable */
5
+ import React from 'react';
6
+ import Button from './Button';
7
+
8
+ export default {
9
+ title: 'Button',
10
+
11
+ parameters: {
12
+ component: Button,
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,11 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import React from 'react';
3
+ import { storiesOf } from '@storybook/react';
4
+ import Hero from './Hero';
5
+
6
+ const chapter = storiesOf('Webapp screens/Marketing/LandingScreen/Hero', module).add(
7
+ 'default',
8
+ () => <Hero />
9
+ );
10
+
11
+ chapter.add('loading', () => <Hero loading />);
@@ -0,0 +1,23 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`storiesof-to-csf transforms correctly using "storiesof-var.input.js" data 1`] = `
4
+ "/* eslint-disable import/no-extraneous-dependencies */
5
+ import React from 'react';
6
+ import Hero from './Hero';
7
+
8
+ export default {
9
+ title: 'Webapp screens/Marketing/LandingScreen/Hero',
10
+ };
11
+
12
+ export const Default = () => <Hero />;
13
+
14
+ Default.story = {
15
+ name: 'default',
16
+ };
17
+
18
+ export const Loading = () => <Hero loading />;
19
+
20
+ Loading.story = {
21
+ name: 'loading',
22
+ };"
23
+ `;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import Button from './Button';
3
+
4
+ storiesOf('Some.Button', module)
5
+ .add('with story params and decorators', () => <Button label="The Button" />, {
6
+ bar: 1,
7
+ decorators: [withKnobs, (storyFn) => <div className="foo">{storyFn}</div>],
8
+ })
9
+ .add('with story decorators', () => <Button label="The Button" />, {
10
+ decorators: [withKnobs],
11
+ });
@@ -0,0 +1,29 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`storiesof-to-csf transforms correctly using "story-decorators.input.js" data 1`] = `
4
+ "import React from 'react';
5
+ import Button from './Button';
6
+
7
+ export default {
8
+ title: 'Some.Button',
9
+ };
10
+
11
+ export const WithStoryParamsAndDecorators = () => <Button label=\\"The Button\\" />;
12
+
13
+ WithStoryParamsAndDecorators.story = {
14
+ name: 'with story params and decorators',
15
+
16
+ parameters: {
17
+ bar: 1,
18
+ },
19
+
20
+ decorators: [withKnobs, (storyFn) => <div className=\\"foo\\">{storyFn}</div>],
21
+ };
22
+
23
+ export const WithStoryDecorators = () => <Button label=\\"The Button\\" />;
24
+
25
+ WithStoryDecorators.story = {
26
+ name: 'with story decorators',
27
+ decorators: [withKnobs],
28
+ };"
29
+ `;
@@ -0,0 +1,14 @@
1
+ /* eslint-disable */
2
+ import React from 'react';
3
+ import Button from './Button';
4
+
5
+ import { storiesOf } from '@storybook/react';
6
+
7
+ storiesOf('Button', module)
8
+ .add('with story parameters', () => <Button label="The Button" />, {
9
+ header: false,
10
+ inline: true,
11
+ })
12
+ .add('foo', () => <Button label="Foo" />, {
13
+ bar: 1,
14
+ });
@@ -0,0 +1,32 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`storiesof-to-csf transforms correctly using "story-parameters.input.js" data 1`] = `
4
+ "/* eslint-disable */
5
+ import React from 'react';
6
+ import Button from './Button';
7
+
8
+ export default {
9
+ title: 'Button',
10
+ };
11
+
12
+ export const WithStoryParameters = () => <Button label=\\"The Button\\" />;
13
+
14
+ WithStoryParameters.story = {
15
+ name: 'with story parameters',
16
+
17
+ parameters: {
18
+ header: false,
19
+ inline: true,
20
+ },
21
+ };
22
+
23
+ export const Foo = () => <Button label=\\"Foo\\" />;
24
+
25
+ Foo.story = {
26
+ name: 'foo',
27
+
28
+ parameters: {
29
+ bar: 1,
30
+ },
31
+ };"
32
+ `;
@@ -0,0 +1,184 @@
1
+ /* eslint-disable */
2
+ import React from 'react';
3
+ import Button from './Button';
4
+
5
+ import { storiesOf } from '@storybook/react';
6
+ import { action } from '@storybook/addon-actions';
7
+
8
+ storiesOf('Button').addWithInfo(
9
+ 'simple usage',
10
+ 'This is the basic usage with the button with providing a label to show the text.',
11
+ () => (
12
+ <div>
13
+ <Button label="The Button" onClick={action('onClick')} />
14
+ <br />
15
+ <p>Click the "?" mark at top-right to view the info.</p>
16
+ </div>
17
+ )
18
+ );
19
+
20
+ storiesOf('Button').addWithInfo(
21
+ 'simple usage (inline info)',
22
+ `
23
+ This is the basic usage with the button with providing a label to show the text.
24
+ `,
25
+ () => <Button label="The Button" onClick={action('onClick')} />,
26
+ { inline: true }
27
+ );
28
+
29
+ storiesOf('Button').addWithInfo(
30
+ 'simple usage (disable source)',
31
+ `
32
+ This is the basic usage with the button with providing a label to show the text.
33
+ `,
34
+ () => <Button label="The Button" onClick={action('onClick')} />,
35
+ { source: false, inline: true }
36
+ );
37
+
38
+ storiesOf('Button').addWithInfo(
39
+ 'simple usage (no header)',
40
+ `
41
+ This is the basic usage with the button with providing a label to show the text.
42
+ `,
43
+ () => <Button label="The Button" onClick={action('onClick')} />,
44
+ { header: false, inline: true }
45
+ );
46
+
47
+ storiesOf('Button').addWithInfo(
48
+ 'simple usage (no prop tables)',
49
+ `
50
+ This is the basic usage with the button with providing a label to show the text.
51
+ `,
52
+ () => <Button label="The Button" onClick={action('onClick')} />,
53
+ { propTables: false, inline: true }
54
+ );
55
+
56
+ storiesOf('Button').addWithInfo(
57
+ 'simple usage (custom propTables)',
58
+ `
59
+ This is the basic usage with the button with providing a label to show the text.
60
+ Since, the story source code is wrapped inside a div, info addon can't figure out propTypes on it's own.
61
+ So, we need to give relevant React component classes manually using \`propTypes\` option as shown below:
62
+ ~~~js
63
+ storiesOf('Button')
64
+ .addWithInfo(
65
+ 'simple usage (custom propTables)',
66
+ <info>,
67
+ <storyFn>,
68
+ { inline: true, propTables: [Button]}
69
+ );
70
+ ~~~
71
+ `,
72
+ () => (
73
+ <div>
74
+ <Button label="The Button" onClick={action('onClick')} />
75
+ <br />
76
+ </div>
77
+ ),
78
+ { inline: true, propTables: [Button] }
79
+ );
80
+
81
+ storiesOf('Button').addWithInfo(
82
+ 'simple usage (JSX description)',
83
+ <div>
84
+ <h2>This is a JSX info section</h2>
85
+ <p>
86
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ornare massa rutrum metus
87
+ commodo, a mattis velit dignissim. Fusce vestibulum turpis sed massa egestas pharetra. Sed at
88
+ libero nulla.
89
+ </p>
90
+ <p>
91
+ <a href="https://github.com/storybookjs/react-storybook-addon-info">This is a link</a>
92
+ </p>
93
+ <p>
94
+ <img src="https://storybook.js.org/images/placeholders/350x150.png" />
95
+ </p>
96
+ </div>,
97
+ () => (
98
+ <div>
99
+ <Button label="The Button" onClick={action('onClick')} />
100
+ <br />
101
+ <p>Click the "?" mark at top-right to view the info.</p>
102
+ </div>
103
+ )
104
+ );
105
+
106
+ storiesOf('Button').addWithInfo(
107
+ 'simple usage (inline JSX description)',
108
+ <div>
109
+ <h2>This is a JSX info section</h2>
110
+ <p>
111
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ornare massa rutrum metus
112
+ commodo, a mattis velit dignissim. Fusce vestibulum turpis sed massa egestas pharetra. Sed at
113
+ libero nulla.
114
+ </p>
115
+ <p>
116
+ <a href="https://github.com/storybookjs/react-storybook-addon-info">This is a link</a>
117
+ </p>
118
+ <p>
119
+ <img src="https://storybook.js.org/images/placeholders/350x150.png" />
120
+ </p>
121
+ </div>,
122
+ () => <Button label="The Button" onClick={action('onClick')} />,
123
+ { inline: true }
124
+ );
125
+
126
+ storiesOf('Button').addWithInfo(
127
+ 'simple usage (maxPropsInLine === 1)',
128
+ `
129
+ This is the basic usage with the button with providing a label to show the text.
130
+ `,
131
+ () => <Button label="The Button" onClick={action('onClick')} />,
132
+ { inline: true, maxPropsIntoLine: 1 }
133
+ );
134
+
135
+ storiesOf('Button').addWithInfo(
136
+ 'simple usage (maxPropObjectKeys === 5)',
137
+ `
138
+ This is the basic usage with the button with providing a label to show the text.
139
+ `,
140
+ () => <Button label="The Button" object={{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6 }} />,
141
+ { inline: true, maxPropObjectKeys: 5 }
142
+ );
143
+
144
+ storiesOf('Button').addWithInfo(
145
+ 'simple usage (maxPropArrayLength === 8)',
146
+ `
147
+ This is the basic usage with the button with providing a label to show the text.
148
+ `,
149
+ () => <Button label="The Button" array={[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]} />,
150
+ { inline: true, maxPropArrayLength: 8 }
151
+ );
152
+
153
+ storiesOf('Button').addWithInfo(
154
+ 'simple usage (maxPropStringLength === 10)',
155
+ `
156
+ This is the basic usage with the button with providing a label to show the text.
157
+ `,
158
+ () => <Button label="The Button" string="1 2 3 4 5 6 7 8" />,
159
+ { inline: true, maxPropStringLength: 5 }
160
+ );
161
+
162
+ storiesOf('Button').addWithInfo(
163
+ 'with custom styles',
164
+ `
165
+ This is an example of how to customize the styles of the info components.
166
+ For the full styles available, see \`./src/components/Story.js\`
167
+ `,
168
+ () => <Button label="The Button" onClick={action('onClick')} />,
169
+ {
170
+ inline: true,
171
+ styles: (stylesheet) => {
172
+ stylesheet.infoPage = {
173
+ backgroundColor: '#ccc',
174
+ };
175
+ return stylesheet;
176
+ },
177
+ }
178
+ );
179
+
180
+ storiesOf('shared/ProgressBar', module)
181
+ .addDecorator(withKnobs)
182
+ .addWithInfo('default style', () => (
183
+ <ProgressBar progress={number('progress', 25)} delay={number('delay', 500)} />
184
+ ));