Skip to content
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

Addon-docs: Convert repo stories to new module format #7175

Merged
merged 23 commits into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
710b88f
Convert cra-kitchen-sink to module format
shilman Jun 23, 2019
b07acdc
Convert cra-react15 to module format
shilman Jun 23, 2019
f7adf9a
Convert html-kitchen-sink to module format
shilman Jun 23, 2019
5773cae
Convert marko-cli to module format
shilman Jun 23, 2019
98d6475
Convert mithril-kitchen-sink to module format
shilman Jun 23, 2019
ae915f7
FIX snapshots && IMPROVE the DX of `integrityTestTemplate`
ndelangen Jun 24, 2019
ba4211a
Update module format to use storyFn.story annotations
shilman Jun 27, 2019
5cc0503
Merge branch 'next' into 7101-convert-stories-to-module-format
shilman Jun 27, 2019
701e67d
Codemod: Use camelcase vars to codemod story names with whitespace
shilman Jun 27, 2019
c97c2df
Codemod: handle stories called "default"
shilman Jun 27, 2019
9eb043a
Cra-kitchen-sink: Update to use module format
shilman Jun 27, 2019
63d729a
Ember-cli: Update stories to module format
shilman Jun 27, 2019
e5b4bcd
Html-kitchen-sink: update stories to module format
shilman Jun 27, 2019
d9c67d7
Official-storybook: update stories to module format
shilman Jun 27, 2019
07c2df0
Polymer-cli: update stories to module format
shilman Jun 27, 2019
7f7eecf
Preact-kitchen-snik: update stories to module format
shilman Jun 27, 2019
89b9505
Rax: Add load API & framework param to storiesOf
shilman Jun 27, 2019
0af4aac
Rax-kitchen-sink: update stories to module format
shilman Jun 27, 2019
9677427
Riot-kitchen-sink: update stories to module format
shilman Jun 27, 2019
afd1d7c
Svelte-kitchen-sink: update stories to module format
shilman Jun 27, 2019
b1fdbc2
Vue-kitchen-sink: update stories to module format
shilman Jun 27, 2019
cb054ce
Convert examples to module format: update snapshots
shilman Jun 28, 2019
eece7bc
Fix linting error
shilman Jun 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ function integrityTest(integrityOptions, stories2snapsConverter) {
const possibleStoriesFiles = stories2snapsConverter.getPossibleStoriesFiles(fileName);
return !possibleStoriesFiles.some(fs.existsSync);
});
expect(abandonedStoryshots.length).toBe(0);

expect(abandonedStoryshots).toEqual([]);
});
});
}
Expand Down
1 change: 1 addition & 0 deletions app/rax/src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export {
getStorybook,
forceReRender,
raw,
load,
} from './preview';
7 changes: 5 additions & 2 deletions app/rax/src/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { start } from '@storybook/core/client';
import './globals';
import render from './render';

const { clientApi, configApi, forceReRender } = start(render);
const { load: coreLoad, clientApi, configApi, forceReRender } = start(render);

export const {
storiesOf,
setAddon,
addDecorator,
addParameters,
Expand All @@ -15,5 +14,9 @@ export const {
raw,
} = clientApi;

const framework = 'rax';
export const storiesOf = (...args) => clientApi.storiesOf(...args).addParameters({ framework });
export const load = (...args) => coreLoad(...args, framework);

export const { configure } = configApi;
export { forceReRender };
13 changes: 2 additions & 11 deletions examples/cra-kitchen-sink/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { configure, addParameters, addDecorator } from '@storybook/react';
import { load, addParameters, addDecorator } from '@storybook/react';
import { create } from '@storybook/theming';
import { withA11y } from '@storybook/addon-a11y';

Expand All @@ -22,13 +22,4 @@ addParameters({
},
});

function loadStories() {
// order of imports will determine the order of the stories unless a storySort is passed to the options object
require('../src/stories/welcome');

// automatically import all story js files that end with *.stories.js
const req = require.context('../src/stories', true, /\.stories\.js$/);
req.keys().forEach(filename => req(filename));
}

configure(loadStories, module);
load(require.context('../src/stories', true, /\.stories\.js$/), module);
11 changes: 9 additions & 2 deletions examples/cra-kitchen-sink/src/stories/App.stories.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
// FIXME: svgr issue @igor-dv

import React from 'react';
import { storiesOf } from '@storybook/react';

import App from '../App';

storiesOf('App', module).add('full app', () => <App />);
export default {
title: 'App',
};

export const fullApp = () => <App />;

fullApp.story = {
name: 'full app',
};
7 changes: 5 additions & 2 deletions examples/cra-kitchen-sink/src/stories/Lifecycle.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import LifecycleLogger from '../components/LifecycleLogger';

storiesOf('Lifecycle', module).add('logging', () => <LifecycleLogger />);
export default {
title: 'Lifecycle',
};

export const logging = () => <LifecycleLogger />;
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import React from 'react';
import { storiesOf, forceReRender } from '@storybook/react';
import { forceReRender } from '@storybook/react';

let Component;

storiesOf('CRA', module).add('Dynamic import', () => {
export default {
title: 'CRA',
};

export const story1 = () => {
if (!Component) {
import('@storybook/react/demo').then(({ Button }) => {
Component = Button;
Expand All @@ -14,4 +18,6 @@ storiesOf('CRA', module).add('Dynamic import', () => {
}

return <Component>Hello Button</Component>;
});
};

story1.story = { name: 'Dynamic import' };
10 changes: 7 additions & 3 deletions examples/cra-kitchen-sink/src/stories/force-rerender.stories.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import React from 'react';
import { storiesOf, forceReRender } from '@storybook/react';
import { forceReRender } from '@storybook/react';

let count = 0;
const increment = () => {
count += 1;
forceReRender();
};

storiesOf('Force ReRender', module).add('button', () => (
export default {
title: 'Force ReRender',
};

export const button = () => (
<button type="button" onClick={increment}>
Click me to increment: {count}
</button>
));
);
95 changes: 55 additions & 40 deletions examples/cra-kitchen-sink/src/stories/index.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable react/destructuring-assignment */
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { withInfo } from '@storybook/addon-info';
import { Button } from '@storybook/react/demo';
Expand All @@ -23,46 +23,61 @@ const InfoButton = () => (
</span>
);

storiesOf('Button', module)
.addParameters({
export default {
title: 'Button',

parameters: {
component: Button,
})
.add('with text', () => <Button onClick={action('clicked', { depth: 1 })}>Hello Button</Button>, {
},
};

export const story1 = () => <Button onClick={action('clicked', { depth: 1 })}>Hello Button</Button>;
story1.story = {
name: 'with text',
parameters: {
options: { selectedPanel: 'storybook/actions/panel' },
},
};

export const story2 = () => (
<Button onClick={action('clicked')}>
<span role="img" aria-label="yolo">
😀 😎 👍 💯
</span>
</Button>
);
story2.story = {
name: 'with some emoji',
parameters: {
options: { selectedPanel: 'storybook/actions/panel' },
})
.add(
'with some emoji',
() => (
<Button onClick={action('clicked')}>
<span role="img" aria-label="yolo">
😀 😎 👍 💯
</span>
</Button>
),
{
options: { selectedPanel: 'storybook/actions/panel' },
}
)
.add('with notes', () => <Button>Check my notes in the notes panel</Button>, {
},
};

export const story3 = () => <Button>Check my notes in the notes panel</Button>;
story3.story = {
name: 'with notes',
parameters: {
notes: 'A very simple button',
options: { selectedPanel: 'storybook/notes/panel' },
})
.add(
'with new info',
context => (
<Container>
<span>
click the <InfoButton /> label in top right for info about "{context.name}"
</span>
</Container>
),
{
notes: 'Composition: Info(Notes())',
options: { selectedPanel: 'storybook/info/panel' },
decorators: [
withInfo(
'Use the [info addon](https://github.com/storybookjs/storybook/tree/master/addons/info) with its new painless API.'
),
],
}
);
},
};

export const story4 = context => (
<Container>
<span>
click the <InfoButton /> label in top right for info about "{context.name}"
</span>
</Container>
);
story4.story = {
name: 'with new info',
parameters: {
notes: 'Composition: Info(Notes())',
options: { selectedPanel: 'storybook/info/panel' },
decorators: [
withInfo(
'Use the [info addon](https://github.com/storybookjs/storybook/tree/master/addons/info) with its new painless API.'
),
],
},
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import centered from '@storybook/addon-centered/react';
import { Button } from '@storybook/react/demo';

storiesOf('Some really long story kind description', module)
.addDecorator(centered)
.add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>);
export default {
title: 'Some really long story kind description',
decorators: [centered],
};

export const story1 = () => <Button onClick={action('clicked')}>Hello Button</Button>;
story1.story = { name: 'with text' };
14 changes: 9 additions & 5 deletions examples/cra-kitchen-sink/src/stories/welcome.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React from 'react';
import { Welcome } from '@storybook/react/demo';
import { storiesOf } from '@storybook/react';
import { linkTo } from '@storybook/addon-links';

storiesOf('Welcome', module)
.addParameters({
export default {
title: 'Welcome',

parameters: {
component: Welcome,
})
.add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);
},
};

export const story1 = () => <Welcome showApp={linkTo('Button')} />;
story1.title = 'to Storybook';
8 changes: 2 additions & 6 deletions examples/cra-react15/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { configure, addParameters } from '@storybook/react';
import { load, addParameters } from '@storybook/react';
import { create } from '@storybook/theming/create';

function loadStories() {
require('../src/stories');
}

addParameters({
options: {
theme: create({ colorPrimary: 'hotpink', colorSecondary: 'orangered' }),
},
});

configure(loadStories, module);
load(require.context('../src/stories', true, /\.stories\.js$/), module);
22 changes: 22 additions & 0 deletions examples/cra-react15/src/stories/button.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { action } from '@storybook/addon-actions';
import { Button } from '@storybook/react/demo';

export default {
title: 'Button',
parameters: {
component: Button,
},
};

export const story1 = () => <Button onClick={action('clicked')}>Hello Button</Button>;
story1.story = { name: 'with text' };

export const story2 = () => (
<Button onClick={action('clicked')}>
<span role="img" aria-label="so cool">
😀 😎 👍 💯
</span>
</Button>
);
story2.story = { name: 'with some emoji' };
26 changes: 0 additions & 26 deletions examples/cra-react15/src/stories/index.js

This file was deleted.

13 changes: 13 additions & 0 deletions examples/cra-react15/src/stories/welcome.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { linkTo } from '@storybook/addon-links';
import { Welcome } from '@storybook/react/demo';

export default {
title: 'Welcome',
parameters: {
component: Welcome,
},
};

export const story1 = () => <Welcome showApp={linkTo('Button')} />;
story1.story = { name: 'to Storybook' };
11 changes: 2 additions & 9 deletions examples/ember-cli/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { configure, addParameters, addDecorator } from '@storybook/ember';
import { load, addParameters, addDecorator } from '@storybook/ember';
import { withA11y } from '@storybook/addon-a11y';

addDecorator(withA11y);
Expand All @@ -9,11 +9,4 @@ addParameters({
},
});

function loadStories() {
require('../stories/index.stories');

const req = require.context('../stories', true, /\.stories\.js$/);
req.keys().forEach(filename => req(filename));
}

configure(loadStories, module);
load(require.context('../stories', true, /\.stories\.js$/), module);
Loading