-
-
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.
Merge pull request #2787 from storybooks/angular-inheritance-example
Angular inheritance example
- Loading branch information
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
examples/angular-cli/src/stories/inheritance/__snapshots__/inheritance.stories.storyshot
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,37 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots Inheritance base button 1`] = ` | ||
<storybook-dynamic-app-root | ||
cfr={[Function CodegenComponentFactoryResolver]} | ||
data={[Function Object]} | ||
target={[Function ViewContainerRef_]} | ||
> | ||
<storybook-base-button> | ||
|
||
|
||
<button> | ||
this is label | ||
</button> | ||
|
||
|
||
</storybook-base-button> | ||
</storybook-dynamic-app-root> | ||
`; | ||
|
||
exports[`Storyshots Inheritance icon button 1`] = ` | ||
<storybook-dynamic-app-root | ||
cfr={[Function CodegenComponentFactoryResolver]} | ||
data={[Function Object]} | ||
target={[Function ViewContainerRef_]} | ||
> | ||
<storybook-icon-button> | ||
|
||
|
||
<button> | ||
this is label - this is icon | ||
</button> | ||
|
||
|
||
</storybook-icon-button> | ||
</storybook-dynamic-app-root> | ||
`; |
11 changes: 11 additions & 0 deletions
11
examples/angular-cli/src/stories/inheritance/base-button.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,11 @@ | ||
import { Component, Input } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: `storybook-base-button`, | ||
template: ` | ||
<button>{{label}}</button> | ||
`, | ||
}) | ||
export class BaseButtonComponent { | ||
@Input() label: string; | ||
} |
12 changes: 12 additions & 0 deletions
12
examples/angular-cli/src/stories/inheritance/icon-button.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,12 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { BaseButtonComponent } from './base-button.component'; | ||
|
||
@Component({ | ||
selector: `storybook-icon-button`, | ||
template: ` | ||
<button>{{label}} - {{icon}}</button> | ||
`, | ||
}) | ||
export class IconButtonComponent extends BaseButtonComponent { | ||
@Input() icon: string; | ||
} |
18 changes: 18 additions & 0 deletions
18
examples/angular-cli/src/stories/inheritance/inheritance.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,18 @@ | ||
import { storiesOf } from '@storybook/angular'; | ||
import { IconButtonComponent } from './icon-button.component'; | ||
import { BaseButtonComponent } from './base-button.component'; | ||
|
||
storiesOf('Inheritance', module) | ||
.add('icon button', () => ({ | ||
component: IconButtonComponent, | ||
props: { | ||
icon: 'this is icon', | ||
label: 'this is label', | ||
}, | ||
})) | ||
.add('base button', () => ({ | ||
component: BaseButtonComponent, | ||
props: { | ||
label: 'this is label', | ||
}, | ||
})); |