mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-10 00:12:22 +08:00
improve naming and returnstatement
This commit is contained in:
parent
84f9295819
commit
b1577905cb
@ -36,13 +36,13 @@ export const sourceDecorator = (storyFn: StoryFn<IStory>, context: StoryContext)
|
|||||||
return story;
|
return story;
|
||||||
}
|
}
|
||||||
const channel = addons.getChannel();
|
const channel = addons.getChannel();
|
||||||
const { props, template, hasCustomTemplate } = story;
|
const { props, template, userDefinedTemplate } = story;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
parameters: { component, argTypes },
|
parameters: { component, argTypes },
|
||||||
} = context;
|
} = context;
|
||||||
|
|
||||||
if (component && !hasCustomTemplate) {
|
if (component && !userDefinedTemplate) {
|
||||||
const source = computesTemplateSourceFromComponent(component, props, argTypes);
|
const source = computesTemplateSourceFromComponent(component, props, argTypes);
|
||||||
|
|
||||||
// We might have a story with a Directive or Service defined as the component
|
// We might have a story with a Directive or Service defined as the component
|
||||||
|
@ -42,15 +42,14 @@ const prepareMain = (
|
|||||||
let { template } = story;
|
let { template } = story;
|
||||||
|
|
||||||
const component = story.component ?? context.parameters.component;
|
const component = story.component ?? context.parameters.component;
|
||||||
const noTemplate = hasNoTemplate(template);
|
const userDefinedTemplate = !hasNoTemplate(template);
|
||||||
|
|
||||||
if (noTemplate && component) {
|
if (!userDefinedTemplate && component) {
|
||||||
template = computesTemplateFromComponent(component, story.props, '');
|
template = computesTemplateFromComponent(component, story.props, '');
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...story,
|
...story,
|
||||||
...(template ? { template } : {}),
|
...(template ? { template, userDefinedTemplate } : {}),
|
||||||
hasCustomTemplate: !noTemplate,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,5 +28,5 @@ export interface StoryFnAngularReturnType {
|
|||||||
moduleMetadata?: NgModuleMetadata;
|
moduleMetadata?: NgModuleMetadata;
|
||||||
template?: string;
|
template?: string;
|
||||||
styles?: string[];
|
styles?: string[];
|
||||||
hasCustomTemplate?: boolean;
|
userDefinedTemplate?: boolean;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user