From b275f47eebd40bcde8f9e79a1983412283158134 Mon Sep 17 00:00:00 2001 From: Florent gravin Date: Mon, 14 Feb 2022 22:32:59 +0100 Subject: [PATCH] fix(storybook): make clickable optionnal and manage ngContent --- .../src/lib/badge/badge.component.stories.ts | 20 ++++++++++++++----- .../widgets/src/lib/badge/badge.component.ts | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libs/ui/widgets/src/lib/badge/badge.component.stories.ts b/libs/ui/widgets/src/lib/badge/badge.component.stories.ts index a7a9808d8a..ecf9a8b7d4 100644 --- a/libs/ui/widgets/src/lib/badge/badge.component.stories.ts +++ b/libs/ui/widgets/src/lib/badge/badge.component.stories.ts @@ -1,19 +1,28 @@ -import { Meta, moduleMetadata, Story } from '@storybook/angular' +import { + componentWrapperDecorator, + Meta, + moduleMetadata, + Story, +} from '@storybook/angular' import { BadgeComponent } from './badge.component' export default { title: 'Widgets/BadgeComponent', component: BadgeComponent, decorators: [ + componentWrapperDecorator(BadgeComponent), moduleMetadata({ imports: [], }), ], } as Meta -type BadgeComponentWithContent = { content: string } - -const Template: Story = (args: BadgeComponent) => ({ +interface BadgeComponentContent extends Partial { + content: string +} +const Template: Story = ( + args: BadgeComponentContent +) => ({ component: BadgeComponent, props: args, template: '{{content}}', @@ -21,5 +30,6 @@ const Template: Story = (args: BadgeComponent) => ({ export const Primary = Template.bind({}) Primary.args = { - content: 'My badge!', + clickable: true, + content: 'My custom badge', } diff --git a/libs/ui/widgets/src/lib/badge/badge.component.ts b/libs/ui/widgets/src/lib/badge/badge.component.ts index 88f4053e36..8d78ac1b34 100644 --- a/libs/ui/widgets/src/lib/badge/badge.component.ts +++ b/libs/ui/widgets/src/lib/badge/badge.component.ts @@ -7,5 +7,5 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core' changeDetection: ChangeDetectionStrategy.OnPush, }) export class BadgeComponent { - @Input() clickable = false + @Input() clickable? = false }