Skip to content

Commit

Permalink
Allow local decorators via params
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Coleman committed Mar 1, 2019
1 parent 9f87b71 commit 1e0016c
Show file tree
Hide file tree
Showing 2 changed files with 45 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()}
</>
),
],
};
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

0 comments on commit 1e0016c

Please sign in to comment.