Skip to content

Commit

Permalink
Add Stories to cover argsToTemplate functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Oct 11, 2023
1 parent 7bec7b3 commit a1fdb68
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { CommonModule } from '@angular/common';
import { Component, EventEmitter, Input, Output } from '@angular/core';

@Component({
selector: 'app-template',
imports: [CommonModule],
template: `<div (click)="event($event)">
Label: {{ label }}
<br />
Label2: {{ label2 }}
<br />
<button (click)="inc()">+</button>
</div>`,
styles: [],
standalone: true,
})
export class Template {
@Input() label = 'default label';

@Input() label2 = 'default label2';

@Output() changed = new EventEmitter<string>();

inc() {
this.changed.emit('Increase');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Meta, StoryObj, argsToTemplate } from '@storybook/angular';
import { Template } from './template.component';

const meta: Meta<Template> = {
component: Template,
};

export default meta;

type Story = StoryObj<Template>;

export const Default: Story = {
render: (args) => ({
props: args,
template: `<app-template ${argsToTemplate(args)}></app-template>`,
}),
};

export const SetOneInput: Story = {
...Default,
args: {
label: 'Label Example 1',
},
};

0 comments on commit a1fdb68

Please sign in to comment.