Skip to content

Commit

Permalink
Merge pull request #2787 from storybooks/angular-inheritance-example
Browse files Browse the repository at this point in the history
Angular inheritance example
  • Loading branch information
igor-dv authored Jan 20, 2018
2 parents 34b98a8 + ef9d0b2 commit 8bc13f7
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
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>
`;
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;
}
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;
}
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',
},
}));

0 comments on commit 8bc13f7

Please sign in to comment.