-
-
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 #3233 from storybooks/example-with-ngrx-store
Add example for @ngrx/store
- Loading branch information
Showing
5 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
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
31 changes: 31 additions & 0 deletions
31
examples/angular-cli/src/stories/__snapshots__/ngrx-store.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,31 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots ngrx|Store With component 1`] = ` | ||
<storybook-dynamic-app-root | ||
cfr={[Function CodegenComponentFactoryResolver]} | ||
data={[Function Object]} | ||
target={[Function ViewContainerRef_]} | ||
> | ||
<storybook-comp-with-store> | ||
<div> | ||
Store is injected | ||
</div> | ||
</storybook-comp-with-store> | ||
</storybook-dynamic-app-root> | ||
`; | ||
|
||
exports[`Storyshots ngrx|Store With template 1`] = ` | ||
<storybook-dynamic-app-root | ||
cfr={[Function CodegenComponentFactoryResolver]} | ||
data={[Function Object]} | ||
target={[Function ViewContainerRef_]} | ||
> | ||
<ng-component> | ||
<storybook-comp-with-store> | ||
<div> | ||
Store is injected | ||
</div> | ||
</storybook-comp-with-store> | ||
</ng-component> | ||
</storybook-dynamic-app-root> | ||
`; |
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,17 @@ | ||
import { StoreModule } from '@ngrx/store'; | ||
import { storiesOf, moduleMetadata } from '@storybook/angular'; | ||
import { WithStoreComponent } from './ngrx/WithStoreComponent'; | ||
|
||
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>`, | ||
})); |
18 changes: 18 additions & 0 deletions
18
examples/angular-cli/src/stories/ngrx/WithStoreComponent.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 { Component } from '@angular/core'; | ||
import { Store } from '@ngrx/store'; | ||
|
||
@Component({ | ||
selector: 'storybook-comp-with-store', | ||
template: '<div>{{this.getSotreState()}}</div>', | ||
}) | ||
export 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'; | ||
} | ||
} |
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