Skip to content

Commit

Permalink
Merge pull request #5806 from storybooks/5781-document-decorator-changes
Browse files Browse the repository at this point in the history
Allow local decorators via params
  • Loading branch information
shilman authored Mar 1, 2019
2 parents 9f87b71 + cc8a4af commit cc54a7c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
39 changes: 39 additions & 0 deletions examples/official-storybook/stories/core/decorators.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';

// We would need to add this in config.js idomatically however that would make this file a bit confusing
import { addDecorator } from '@storybook/react';

addDecorator((s, { kind }) =>
kind === 'Core|Decorators' ? (
<>
<p>Global Decorator</p>
{s()}
</>
) : (
s()
)
);

export default {
title: 'Core|Decorators',
decorators: [
s => (
<>
<p>Kind Decorator</p>
{s()}
</>
),
],
};

export const all = () => <p>Story</p>;
all.parameters = {
decorators: [
s => (
<>
<p>Local Decorator</p>
{s()}
</>
),
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -5077,6 +5077,23 @@ exports[`Storyshots Basics|ScrollArea vertical 1`] = `
</div>
`;

exports[`Storyshots Core|Decorators all 1`] = `
Array [
<p>
Global Decorator
</p>,
<p>
Kind Decorator
</p>,
<p>
Local Decorator
</p>,
<p>
Story
</p>,
]
`;

exports[`Storyshots Core|Events Force re-render 1`] = `
.emotion-0 {
border: 0;
Expand Down
7 changes: 6 additions & 1 deletion lib/client-api/src/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,12 @@ export default class ClientApi {
},
{
applyDecorators: this._decorateStory,
getDecorators: () => [...localDecorators, ..._globalDecorators, withSubscriptionTracking],
getDecorators: () => [
...(allParam.decorators || []),
...localDecorators,
..._globalDecorators,
withSubscriptionTracking,
],
}
);
return api;
Expand Down

1 comment on commit cc54a7c

@vercel
Copy link

@vercel vercel bot commented on cc54a7c Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are pushing commits at a very fast pace (accross the whole organization).
Due to that, we cannot deploy the commit cc54a7c.

You can try again later or upgrade your plan.

Please sign in to comment.