本文整理匯總了TypeScript中@storybook/angular.moduleMetadata函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript moduleMetadata函數的具體用法?TypeScript moduleMetadata怎麽用?TypeScript moduleMetadata使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了moduleMetadata函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: storiesOf
storiesOf('Addon|Background', module)
.addDecorator(
withBackgrounds([
{ name: 'twitter', value: '#00aced', default: true },
{ name: 'facebook', value: '#3b5998' },
])
)
.add('background component', () => ({
component: AppComponent,
props: {},
}));
storiesOf('Addon|Background', module)
.addDecorator(
moduleMetadata({
declarations: [Button],
})
)
.addDecorator(
withBackgrounds([
{ name: 'twitter', value: '#00aced', default: true },
{ name: 'facebook', value: '#3b5998' },
])
)
.add('background template', () => ({
template: `<storybook-button-component [text]="text" (onClick)="onClick($event)"></storybook-button-component>`,
props: {
text: 'Hello Button',
onClick: (event: Event) => {
console.log('some bindings work');
console.log(event);
示例2: storiesOf
import { storiesOf, moduleMetadata } from '@storybook/angular';
import { withKnobs, text } from '@storybook/addon-knobs';
import { DummyService } from './moduleMetadata/dummy.service';
import { ServiceComponent } from './moduleMetadata/service.component';
storiesOf('Custom|Providers', module)
.addDecorator(
moduleMetadata({
imports: [],
schemas: [],
declarations: [],
providers: [DummyService],
})
)
.add('Simple', () => ({
component: ServiceComponent,
props: {
name: 'Static name',
},
}))
.add(
'With knobs',
() => {
const name = text('name', 'Dynamic knob');
return {
component: ServiceComponent,
props: {
name,
},
示例3: constructor
@Component({
selector: 'storybook-comp-with-store',
template: '<div>{{this.getSotreState()}}</div>',
})
class WithStoreComponent {
private store: Store<any>;
constructor(store: Store<any>) {
this.store = store;
}
getSotreState() {
return this.store === undefined ? 'Store is NOT injected' : 'Store is injected';
}
}
storiesOf('ngrx|Store', module)
.addDecorator(
moduleMetadata({
imports: [StoreModule.forRoot({})],
declarations: [WithStoreComponent],
})
)
.add('With component', () => ({
component: WithStoreComponent,
}))
.add('With template', () => ({
template: `<storybook-comp-with-store></storybook-comp-with-store>`,
}));
示例4: storiesOf
import { storiesOf, moduleMetadata } from '@storybook/angular';
import { TokenComponent, ITEMS, DEFAULT_NAME } from './moduleMetadata/token.component';
import { CustomPipePipe } from './moduleMetadata/custom.pipe';
storiesOf('Metadata|Combined', module)
.addDecorator(
moduleMetadata({
imports: [],
declarations: [TokenComponent],
providers: [
{
provide: ITEMS,
useValue: ['Joe', 'Jane'],
},
{
provide: DEFAULT_NAME,
useValue: 'Provider Name',
},
],
})
)
.add('Combined 1', () => ({
template: `<storybook-simple-token-component [name]="name"></storybook-simple-token-component>`,
props: {
name: 'Prop Name',
},
}))
.add('Combined 2', () => ({
template: `<storybook-simple-token-component [name]="name | customPipe"></storybook-simple-token-component>`,
props: {
name: 'Prop Name',
示例5: storiesOf
import { storiesOf, moduleMetadata } from '@storybook/angular';
import { withKnobs, text } from '@storybook/addon-knobs';
import { NameComponent } from './moduleMetadata/name.component';
import { CustomPipePipe } from './moduleMetadata/custom.pipe';
storiesOf('Custom|Pipes', module)
.addDecorator(
moduleMetadata({
imports: [],
schemas: [],
declarations: [CustomPipePipe],
providers: [],
})
)
.add('Simple', () => ({
component: NameComponent,
props: {
field: 'foobar',
},
}))
.add(
'With Knobs',
() => ({
component: NameComponent,
props: {
field: text('field', 'foobar'),
},
}),
{
decorators: [withKnobs],