Skip to content

Commit

Permalink
Renamed ->
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Mar 1, 2018
1 parent 2842d8a commit 1ad8532
Show file tree
Hide file tree
Showing 22 changed files with 162 additions and 107 deletions.
6 changes: 3 additions & 3 deletions app/angular/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface IStoribookSection {
export interface IStoryContext {
kind: string;
name: string;
options: any;
parameters: any;
}

export type IGetStory = (
Expand All @@ -29,15 +29,15 @@ export type IGetStory = (
export interface IApi {
kind: string;
addDecorator: (decorator: any) => IApi;
addOptions: (options: any) => IApi;
addParameters: (parameters: any) => IApi;
add: (storyName: string, getStory: IGetStory, options?: any) => IApi;
}

declare module '@storybook/angular' {
export function storiesOf(kind: string, module: NodeModule): IApi;
export function setAddon(addon: any): void;
export function addDecorator(decorator: any): IApi;
export function addOptions(options: any): IApi;
export function addParameters(parameters: any): IApi;
export function configure(loaders: () => NodeRequire, module: NodeModule): void;
export function getStorybook(): IStoribookSection[];
}
9 changes: 8 additions & 1 deletion app/angular/src/client/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
export { storiesOf, setAddon, addDecorator, addOptions, configure, getStorybook } from './preview';
export {
storiesOf,
setAddon,
addDecorator,
addParameters,
configure,
getStorybook,
} from './preview';

export { moduleMetadata } from './preview/angular/decorators';
2 changes: 1 addition & 1 deletion app/angular/src/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const {
storiesOf,
setAddon,
addDecorator,
addOptions,
addParameters,
clearDecorators,
getStorybook,
} = clientApi;
Expand Down
9 changes: 8 additions & 1 deletion app/polymer/src/client/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
export { storiesOf, setAddon, addDecorator, addOptions, configure, getStorybook } from './preview';
export {
storiesOf,
setAddon,
addDecorator,
addParameters,
configure,
getStorybook,
} from './preview';
2 changes: 1 addition & 1 deletion app/polymer/src/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const {
storiesOf,
setAddon,
addDecorator,
addOptions,
addParameters,
clearDecorators,
getStorybook,
} = clientApi;
Expand Down
2 changes: 1 addition & 1 deletion app/react-native/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const preview = new Preview();
export const storiesOf = preview.storiesOf.bind(preview);
export const setAddon = preview.setAddon.bind(preview);
export const addDecorator = preview.addDecorator.bind(preview);
export const addOptions = preview.addOptions.bind(preview);
export const addParameters = preview.addParameters.bind(preview);
export const clearDecorators = preview.clearDecorators.bind(preview);
export const configure = preview.configure.bind(preview);
export const getStorybook = preview.getStorybook.bind(preview);
Expand Down
2 changes: 1 addition & 1 deletion app/react-native/src/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class Preview {
'storiesOf',
'setAddon',
'addDecorator',
'addOptions',
'addParameters',
'clearDecorators',
'getStorybook',
].forEach(method => {
Expand Down
2 changes: 1 addition & 1 deletion app/react/src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export {
storiesOf,
setAddon,
addDecorator,
addOptions,
addParameters,
configure,
getStorybook,
forceReRender,
Expand Down
2 changes: 1 addition & 1 deletion app/react/src/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const {
storiesOf,
setAddon,
addDecorator,
addOptions,
addParameters,
clearDecorators,
getStorybook,
} = clientApi;
Expand Down
9 changes: 8 additions & 1 deletion app/vue/src/client/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
export { storiesOf, setAddon, addDecorator, addOptions, configure, getStorybook } from './preview';
export {
storiesOf,
setAddon,
addDecorator,
addParameters,
configure,
getStorybook,
} from './preview';
2 changes: 1 addition & 1 deletion app/vue/src/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const {
storiesOf,
setAddon,
addDecorator,
addOptions,
addParameters,
clearDecorators,
getStorybook,
} = clientApi;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Storyshots Core|Parameters passed to story 1`] = `
<storybook-dynamic-app-root
cfr={[Function CodegenComponentFactoryResolver]}
data={[Function Object]}
target={[Function ViewContainerRef_]}
>
<storybook-button-component
_nghost-c8=""
>


<button
_ngcontent-c8=""
>
Parameters are {"globalParameter":"globalParameter","chapterParameter":"chapterParameter","storyParameter":"storyParameter","fileName":"/Users/tom/OSS/storybook/examples/angular-cli/src/stories/core.stories.ts"}
</button>


</storybook-button-component>
</storybook-dynamic-app-root>
`;
20 changes: 10 additions & 10 deletions examples/angular-cli/src/stories/core.stories.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { storiesOf, addOptions } from '@storybook/angular';
import { storiesOf, addParameters } from '@storybook/angular';
import { Button } from '@storybook/angular/demo';

const globalOption = 'globalOption';
const chapterOption = 'chapterOption';
const storyOption = 'storyOption';
const globalParameter = 'globalParameter';
const chapterParameter = 'chapterParameter';
const storyParameter = 'storyParameter';

addOptions({ globalOption });
addParameters({ globalParameter });

storiesOf('Core|Options', module)
.addOptions({ chapterOption })
storiesOf('Core|Parameters', module)
.addParameters({ chapterParameter })
.add(
'passed to story',
({ options }) => ({
({ parameters }) => ({
component: Button,
props: {
text: JSON.stringify(options),
text: `Parameters are ${JSON.stringify(parameters)}`,
onClick: () => 0,
},
}),
{ storyOption }
{ storyParameter }
);
28 changes: 16 additions & 12 deletions examples/crna-kitchen-sink/storybook/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Text } from 'react-native';

import { storiesOf, addOptions } from '@storybook/react-native';
import { storiesOf, addParameters } from '@storybook/react-native';
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';
import { withKnobs } from '@storybook/addon-knobs';
Expand Down Expand Up @@ -30,14 +30,18 @@ storiesOf('Knobs', module)
.addDecorator(withKnobs)
.add('with knobs', knobsWrapper);

const globalOption = 'globalOption';
const chapterOption = 'chapterOption';
const storyOption = 'storyOption';

addOptions({ globalOption });

storiesOf('Core|Options', module)
.addOptions({ chapterOption })
.add('passed to story', ({ options }) => <Text>Options are {JSON.stringify(options)}</Text>, {
storyOption,
});
const globalParameter = 'globalParameter';
const chapterParameter = 'chapterParameter';
const storyParameter = 'storyParameter';

addParameters({ globalParameter });

storiesOf('Core|Parameters', module)
.addParameters({ chapterParameter })
.add(
'passed to story',
({ parameters }) => <Text>Parameters are {JSON.stringify(parameters)}</Text>,
{
storyParameter,
}
);
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Storyshots core/options passed to story 1`] = `
exports[`Storyshots Core|Parameters passed to story 1`] = `
<div>
Value of
<code>
myOption
</code>
is '
<code>
value
</code>
'
Parameters are {"globalParameter":"globalParameter","chapterParameter":"chapterParameter","storyParameter":"storyParameter","fileName":"/Users/tom/OSS/storybook/examples/official-storybook/stories/core.stories.js"}
</div>
`;
24 changes: 14 additions & 10 deletions examples/official-storybook/stories/core.stories.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import React from 'react';
import { storiesOf, addOptions } from '@storybook/react';
import { storiesOf, addParameters } from '@storybook/react';

const globalOption = 'globalOption';
const chapterOption = 'chapterOption';
const storyOption = 'storyOption';
const globalParameter = 'globalParameter';
const chapterParameter = 'chapterParameter';
const storyParameter = 'storyParameter';

addOptions({ globalOption });
addParameters({ globalParameter });

storiesOf('Core|Options', module)
.addOptions({ chapterOption })
.add('passed to story', ({ options }) => <div>Options are {JSON.stringify(options)}</div>, {
storyOption,
});
storiesOf('Core|Parameters', module)
.addParameters({ chapterParameter })
.add(
'passed to story',
({ parameters }) => <div>Parameters are {JSON.stringify(parameters)}</div>,
{
storyParameter,
}
);
24 changes: 14 additions & 10 deletions examples/polymer-cli/src/stories/core.stories.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { storiesOf, addOptions } from '@storybook/polymer';
import { storiesOf, addParameters } from '@storybook/polymer';

const globalOption = 'globalOption';
const chapterOption = 'chapterOption';
const storyOption = 'storyOption';
const globalParameter = 'globalParameter';
const chapterParameter = 'chapterParameter';
const storyParameter = 'storyParameter';

addOptions({ globalOption });
addParameters({ globalParameter });

storiesOf('Core|Options', module)
.addOptions({ chapterOption })
.add('passed to story', ({ options }) => `<div>${JSON.stringify(options)}</div>`, {
storyOption,
});
storiesOf('Core|Parameters', module)
.addParameters({ chapterParameter })
.add(
'passed to story',
({ parameters }) => `<div>Parameters are ${JSON.stringify(parameters)}</div>`,
{
storyParameter,
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Storyshots Core|Parameters passed to story 1`] = `
<div>
Parameters are {"globalParameter":"globalParameter","chapterParameter":"chapterParameter","storyParameter":"storyParameter","fileName":"/Users/tom/OSS/storybook/examples/vue-kitchen-sink/src/stories/core.stories.js"}
</div>
`;
20 changes: 10 additions & 10 deletions examples/vue-kitchen-sink/src/stories/core.stories.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { storiesOf, addOptions } from '@storybook/vue';
import { storiesOf, addParameters } from '@storybook/vue';

const globalOption = 'globalOption';
const chapterOption = 'chapterOption';
const storyOption = 'storyOption';
const globalParameter = 'globalParameter';
const chapterParameter = 'chapterParameter';
const storyParameter = 'storyParameter';

addOptions({ globalOption });
addParameters({ globalParameter });

storiesOf('Core|Options', module)
.addOptions({ chapterOption })
storiesOf('Core|Parameters', module)
.addParameters({ chapterParameter })
.add(
'passed to story',
({ options }) => ({
template: `<div>${JSON.stringify(options)}</div>`,
({ parameters }) => ({
template: `<div>Parameters are ${JSON.stringify(parameters)}</div>`,
}),
{
storyOption,
storyParameter,
}
);
20 changes: 10 additions & 10 deletions lib/core/src/client/preview/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class ClientApi {
this._storyStore = storyStore;
this._addons = {};
this._globalDecorators = [];
this._globalOptions = {};
this._globalParameters = {};
this._decorateStory = decorateStory;
}

Expand All @@ -30,8 +30,8 @@ export default class ClientApi {
this._globalDecorators.push(decorator);
};

addOptions = options => {
this._globalOptions = options;
addParameters = parameters => {
this._globalParameters = parameters;
};

clearDecorators = () => {
Expand All @@ -57,7 +57,7 @@ export default class ClientApi {
}

const localDecorators = [];
let localOptions = {};
let localParameters = {};
const api = {
kind,
};
Expand All @@ -71,7 +71,7 @@ export default class ClientApi {
};
});

api.add = (storyName, getStory, options) => {
api.add = (storyName, getStory, parameters) => {
if (typeof storyName !== 'string') {
throw new Error(`Invalid or missing storyName provided for a "${kind}" story.`);
}
Expand All @@ -89,9 +89,9 @@ export default class ClientApi {

// Add the fully decorated getStory function.
this._storyStore.addStory(kind, storyName, this._decorateStory(getStory, decorators), {
...this._globalOptions,
...localOptions,
...options,
...this._globalParameters,
...localParameters,
...parameters,
fileName,
});
return api;
Expand All @@ -102,8 +102,8 @@ export default class ClientApi {
return api;
};

api.addOptions = options => {
localOptions = { ...localOptions, ...options };
api.addParameters = parameters => {
localParameters = { ...localParameters, ...parameters };
return api;
};

Expand Down

0 comments on commit 1ad8532

Please sign in to comment.