Add inheritance example

This commit is contained in:
igor 2018-01-19 19:30:51 +02:00
parent 2da1faf419
commit a9c93105e3
4 changed files with 42 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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',
},
}));