mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 18:11:07 +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 = {
|
useInfoAsStoryDecorator.story = {
|
||||||
name: 'Use Info as story decorator',
|
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" />;
|
export const usingParamatersAcrossAllStories = () => <BaseButton label="Button" />;
|
||||||
|
@ -28,11 +28,23 @@ export default {
|
|||||||
|
|
||||||
export const all = () => <p>Story</p>;
|
export const all = () => <p>Story</p>;
|
||||||
all.story = {
|
all.story = {
|
||||||
|
decorators: [
|
||||||
|
s => (
|
||||||
|
<>
|
||||||
|
<p>Local Decorator</p>
|
||||||
|
{s()}
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deprecated = () => <p>Story</p>;
|
||||||
|
deprecated.story = {
|
||||||
parameters: {
|
parameters: {
|
||||||
decorators: [
|
decorators: [
|
||||||
s => (
|
s => (
|
||||||
<>
|
<>
|
||||||
<p>Local Decorator</p>
|
<p>Deprecated Local Decorator</p>
|
||||||
{s()}
|
{s()}
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
|
@ -349,8 +349,13 @@ export default function start(render, { decorateStory } = {}) {
|
|||||||
Object.keys(exports).forEach(key => {
|
Object.keys(exports).forEach(key => {
|
||||||
if (isExportStory(key, meta)) {
|
if (isExportStory(key, meta)) {
|
||||||
const storyFn = exports[key];
|
const storyFn = exports[key];
|
||||||
const { name, parameters } = storyFn.story || {};
|
const { name, parameters, decorators } = storyFn.story || {};
|
||||||
kind.add(name || key, storyFn, parameters);
|
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