improve naming and returnstatement

This commit is contained in:
Yngve Bakken-Nilsen 2021-08-03 19:29:39 +02:00
parent 84f9295819
commit b1577905cb
3 changed files with 6 additions and 7 deletions

View File

@ -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

View File

@ -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,
}; };
}; };

View File

@ -28,5 +28,5 @@ export interface StoryFnAngularReturnType {
moduleMetadata?: NgModuleMetadata; moduleMetadata?: NgModuleMetadata;
template?: string; template?: string;
styles?: string[]; styles?: string[];
hasCustomTemplate?: boolean; userDefinedTemplate?: boolean;
} }