mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
Module format load: Move story decorators out of parameters
This commit is contained in:
parent
d3e99613ae
commit
1f921612ad
@ -140,9 +140,7 @@ export const useInfoAsStoryDecorator = () => <BaseButton label="Button" />;
|
||||
|
||||
useInfoAsStoryDecorator.story = {
|
||||
name: 'Use Info as story decorator',
|
||||
parameters: {
|
||||
decorators: [withInfo('Info can take options via the global or local decorator as well.')],
|
||||
},
|
||||
decorators: [withInfo('Info can take options via the global or local decorator as well.')],
|
||||
};
|
||||
|
||||
export const usingParamatersAcrossAllStories = () => <BaseButton label="Button" />;
|
||||
|
@ -28,11 +28,23 @@ export default {
|
||||
|
||||
export const all = () => <p>Story</p>;
|
||||
all.story = {
|
||||
decorators: [
|
||||
s => (
|
||||
<>
|
||||
<p>Local Decorator</p>
|
||||
{s()}
|
||||
</>
|
||||
),
|
||||
],
|
||||
};
|
||||
|
||||
export const deprecated = () => <p>Story</p>;
|
||||
deprecated.story = {
|
||||
parameters: {
|
||||
decorators: [
|
||||
s => (
|
||||
<>
|
||||
<p>Local Decorator</p>
|
||||
<p>Deprecated Local Decorator</p>
|
||||
{s()}
|
||||
</>
|
||||
),
|
||||
|
@ -349,8 +349,13 @@ export default function start(render, { decorateStory } = {}) {
|
||||
Object.keys(exports).forEach(key => {
|
||||
if (isExportStory(key, meta)) {
|
||||
const storyFn = exports[key];
|
||||
const { name, parameters } = storyFn.story || {};
|
||||
kind.add(name || key, storyFn, parameters);
|
||||
const { name, parameters, decorators } = storyFn.story || {};
|
||||
if (parameters && parameters.decorators) {
|
||||
deprecate(() => {},
|
||||
`${kindName} => ${name || key}: story.parameters.decorators is deprecated; use story.decorators instead.`)();
|
||||
}
|
||||
const decoratorParams = decorators ? { decorators } : null;
|
||||
kind.add(name || key, storyFn, { ...parameters, ...decoratorParams });
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user