Rename to makeDecorator

This commit is contained in:
Tom Coleman 2018-05-15 13:18:20 +10:00
parent b8f8acb398
commit 199098ccb0
3 changed files with 8 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import addons, { makeTransitionalDecorator } from '@storybook/addons';
import addons, { makeDecorator } from '@storybook/addons';
import marked from 'marked';
function renderMarkdown(text, options) {
@ -6,7 +6,7 @@ function renderMarkdown(text, options) {
return marked(text);
}
export const withNotes = makeTransitionalDecorator({
export const withNotes = makeDecorator({
name: 'withNotes',
parameterName: 'notes',
wrapper: (getStory, context, { options, parameters }) => {

View File

@ -2,7 +2,7 @@
import global from 'global';
export mockChannel from './storybook-channel-mock';
export { makeTransitionalDecorator } from './transitional-decorator';
export { makeDecorator } from './make-decorator';
export class AddonStore {
constructor() {

View File

@ -6,8 +6,11 @@ import deprecate from 'util-deprecate';
// And in the new, "parameterized" style:
// .addDecorator(decorator)
// .add('story', () => <Story />, { name: { parameters } });
//
// *And* in the older, but not deprecated, "pass options to decorator" style:
// .addDecorator(decorator(options))
export const makeTransitionalDecorator = ({ name, parameterName, wrapper }) => {
export const makeDecorator = ({ name, parameterName, wrapper }) => {
const decorator = options => (getStory, context) => {
const parameters = context.parameters && context.parameters[parameterName];
@ -25,7 +28,7 @@ export const makeTransitionalDecorator = ({ name, parameterName, wrapper }) => {
return (...innerArgs) => {
// Used as [.]addDecorator(decorator(options))
if (typeof innerArgs.length > 1) {
if (innerArgs.length > 1) {
return decorator(...args)(...innerArgs);
}