mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +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;
|
||||
}
|
||||
const channel = addons.getChannel();
|
||||
const { props, template, hasCustomTemplate } = story;
|
||||
const { props, template, userDefinedTemplate } = story;
|
||||
|
||||
const {
|
||||
parameters: { component, argTypes },
|
||||
} = context;
|
||||
|
||||
if (component && !hasCustomTemplate) {
|
||||
if (component && !userDefinedTemplate) {
|
||||
const source = computesTemplateSourceFromComponent(component, props, argTypes);
|
||||
|
||||
// We might have a story with a Directive or Service defined as the component
|
||||
|
@ -42,15 +42,14 @@ const prepareMain = (
|
||||
let { template } = story;
|
||||
|
||||
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, '');
|
||||
}
|
||||
return {
|
||||
...story,
|
||||
...(template ? { template } : {}),
|
||||
hasCustomTemplate: !noTemplate,
|
||||
...(template ? { template, userDefinedTemplate } : {}),
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -28,5 +28,5 @@ export interface StoryFnAngularReturnType {
|
||||
moduleMetadata?: NgModuleMetadata;
|
||||
template?: string;
|
||||
styles?: string[];
|
||||
hasCustomTemplate?: boolean;
|
||||
userDefinedTemplate?: boolean;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user