-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Stories to cover argsToTemplate functionality
- Loading branch information
1 parent
7bec7b3
commit a1fdb68
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
.../frameworks/angular/template/stories/basics/component-with-template/template.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
code/frameworks/angular/template/stories/basics/component-with-template/template.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}; |