@storybook/angular 7.3.2 → 7.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/package.json +18 -17
  2. package/src/server/angular-cli-webpack.d.ts +0 -7
  3. package/src/server/angular-cli-webpack.js +0 -127
  4. package/src/server/plugins/storybook-normalize-angular-entry-plugin.js +0 -54
  5. package/src/typings.d.ts +0 -21
  6. package/template/components/button.component.ts +0 -54
  7. package/template/components/button.css +0 -30
  8. package/template/components/form.component.ts +0 -37
  9. package/template/components/html.component.ts +0 -22
  10. package/template/components/pre.component.ts +0 -29
  11. package/template/stories/angular-mdx.stories.mdx +0 -25
  12. package/template/stories/argTypes/doc-button/doc-button.component.html +0 -7
  13. package/template/stories/argTypes/doc-button/doc-button.component.scss +0 -3
  14. package/template/stories/argTypes/doc-button/doc-button.component.ts +0 -232
  15. package/template/stories/argTypes/doc-button/doc-button.stories.ts +0 -24
  16. package/template/stories/argTypes/doc-directive/doc-directive.directive.ts +0 -24
  17. package/template/stories/argTypes/doc-directive/doc-directive.stories.ts +0 -14
  18. package/template/stories/argTypes/doc-injectable/doc-injectable.service.ts +0 -27
  19. package/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts +0 -14
  20. package/template/stories/argTypes/doc-pipe/doc-pipe.pipe.ts +0 -18
  21. package/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts +0 -14
  22. package/template/stories/basics/README.stories.mdx +0 -7
  23. package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts +0 -27
  24. package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva.component.ts +0 -57
  25. package/template/stories/basics/component-with-complex-selectors/attribute-selector.component.ts +0 -19
  26. package/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts +0 -8
  27. package/template/stories/basics/component-with-complex-selectors/class-selector.component.stories.ts +0 -8
  28. package/template/stories/basics/component-with-complex-selectors/class-selector.component.ts +0 -19
  29. package/template/stories/basics/component-with-complex-selectors/multiple-class-selector.component.stories.ts +0 -8
  30. package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.stories.ts +0 -8
  31. package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.ts +0 -37
  32. package/template/stories/basics/component-with-enums/enums.component.html +0 -8
  33. package/template/stories/basics/component-with-enums/enums.component.stories.ts +0 -24
  34. package/template/stories/basics/component-with-enums/enums.component.ts +0 -53
  35. package/template/stories/basics/component-with-inheritance/base-button.component.ts +0 -10
  36. package/template/stories/basics/component-with-inheritance/base-button.stories.ts +0 -12
  37. package/template/stories/basics/component-with-inheritance/icon-button.component.ts +0 -11
  38. package/template/stories/basics/component-with-inheritance/icon-button.stories.ts +0 -13
  39. package/template/stories/basics/component-with-ng-content/ng-content-about-parent.stories.ts +0 -58
  40. package/template/stories/basics/component-with-ng-content/ng-content-simple.stories.ts +0 -29
  41. package/template/stories/basics/component-with-ng-on-destroy/component-with-on-destroy.stories.ts +0 -40
  42. package/template/stories/basics/component-with-on-push/on-push-box.component.ts +0 -21
  43. package/template/stories/basics/component-with-on-push/on-push.stories.ts +0 -21
  44. package/template/stories/basics/component-with-pipe/custom-pipes.stories.ts +0 -31
  45. package/template/stories/basics/component-with-pipe/custom.pipe.ts +0 -10
  46. package/template/stories/basics/component-with-pipe/with-pipe.component.ts +0 -10
  47. package/template/stories/basics/component-with-provider/di.component.html +0 -7
  48. package/template/stories/basics/component-with-provider/di.component.stories.ts +0 -26
  49. package/template/stories/basics/component-with-provider/di.component.ts +0 -28
  50. package/template/stories/basics/component-with-style/styled.component.css +0 -3
  51. package/template/stories/basics/component-with-style/styled.component.html +0 -5
  52. package/template/stories/basics/component-with-style/styled.component.scss +0 -5
  53. package/template/stories/basics/component-with-style/styled.component.stories.ts +0 -10
  54. package/template/stories/basics/component-with-style/styled.component.ts +0 -8
  55. package/template/stories/basics/component-without-selector/without-selector-ng-component-outlet.stories.ts +0 -73
  56. package/template/stories/basics/component-without-selector/without-selector-ng-factory-resolver.stories.ts +0 -71
  57. package/template/stories/basics/component-without-selector/without-selector.component.ts +0 -30
  58. package/template/stories/basics/component-without-selector/without-selector.stories.ts +0 -30
  59. package/template/stories/basics/ng-module/angular-src/chip-color.token.ts +0 -3
  60. package/template/stories/basics/ng-module/angular-src/chip-text.pipe.ts +0 -29
  61. package/template/stories/basics/ng-module/angular-src/chip.component.ts +0 -60
  62. package/template/stories/basics/ng-module/angular-src/chips-group.component.ts +0 -49
  63. package/template/stories/basics/ng-module/angular-src/chips.module.ts +0 -31
  64. package/template/stories/basics/ng-module/import-module-chip.stories.ts +0 -23
  65. package/template/stories/basics/ng-module/import-module-for-root.stories.ts +0 -50
  66. package/template/stories/basics/ng-module/import-module.stories.ts +0 -35
  67. package/template/stories/button.component.ts +0 -26
  68. package/template/stories/core/README.stories.mdx +0 -7
  69. package/template/stories/core/applicationConfig/with-browser-animations.stories.ts +0 -40
  70. package/template/stories/core/applicationConfig/with-noop-browser-animations.stories.ts +0 -35
  71. package/template/stories/core/decorators/componentWrapperDecorator/child.component.ts +0 -20
  72. package/template/stories/core/decorators/componentWrapperDecorator/decorators.stories.ts +0 -99
  73. package/template/stories/core/decorators/componentWrapperDecorator/parent.component.ts +0 -18
  74. package/template/stories/core/decorators/theme-decorator/decorators.stories.ts +0 -20
  75. package/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts +0 -10
  76. package/template/stories/core/moduleMetadata/angular-src/dummy.service.ts +0 -14
  77. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.css +0 -13
  78. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.html +0 -7
  79. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.ts +0 -39
  80. package/template/stories/core/moduleMetadata/angular-src/service.component.ts +0 -24
  81. package/template/stories/core/moduleMetadata/angular-src/token.component.ts +0 -31
  82. package/template/stories/core/moduleMetadata/in-export-default.stories.ts +0 -38
  83. package/template/stories/core/moduleMetadata/in-stories.stories.ts +0 -46
  84. package/template/stories/core/moduleMetadata/merge-default-and-story.stories.ts +0 -35
  85. package/template/stories/core/parameters/bootstrap-options.stories.ts +0 -18
  86. package/template/stories/core/styles/story-styles.stories.ts +0 -50
  87. package/template/stories/others/app-initializer-use-factory/app-initializer-use-factory.stories.ts +0 -34
  88. package/template/stories/others/issues/12009-unknown-component.stories.ts +0 -14
  89. package/template/stories/others/ngx-translate/README.stories.mdx +0 -65
@@ -1,49 +0,0 @@
1
- import { Component, Input, Output, EventEmitter } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'storybook-chips-group',
5
- template: `
6
- <storybook-chip
7
- *ngFor="let chip of chips"
8
- class="chip"
9
- [displayText]="chip.text"
10
- (removeClicked)="removeChipClick.emit(chip.id)"
11
- ></storybook-chip>
12
- <div *ngIf="chips.length > 1" class="remove-all" (click)="removeAllChipsClick.emit()">
13
- Remove All
14
- </div>
15
- `,
16
- styles: [
17
- `
18
- :host {
19
- display: flex;
20
- align-content: center;
21
- padding: 0.5rem;
22
- background-color: lightgrey;
23
- border-radius: 0.5rem;
24
- width: fit-content;
25
- }
26
- .chip:not(:first-of-type) {
27
- margin-left: 0.5rem;
28
- }
29
- .remove-all {
30
- margin-left: 0.5rem;
31
- padding: 0.2rem 0.5rem;
32
- border: solid 0.1rem #eeeeee;
33
- }
34
- .remove-all:hover {
35
- background-color: palevioletred;
36
- }
37
- `,
38
- ],
39
- })
40
- export class ChipsGroupComponent {
41
- @Input() chips?: {
42
- id: number;
43
- text: string;
44
- }[];
45
-
46
- @Output() removeChipClick = new EventEmitter<number>();
47
-
48
- @Output() removeAllChipsClick = new EventEmitter();
49
- }
@@ -1,31 +0,0 @@
1
- import { ModuleWithProviders, NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { ChipComponent } from './chip.component';
4
- import { ChipsGroupComponent } from './chips-group.component';
5
- import { ChipTextPipe } from './chip-text.pipe';
6
- import { CHIP_COLOR } from './chip-color.token';
7
-
8
- @NgModule({
9
- imports: [CommonModule],
10
- exports: [ChipsGroupComponent, ChipComponent],
11
- declarations: [ChipsGroupComponent, ChipComponent, ChipTextPipe],
12
- providers: [
13
- {
14
- provide: CHIP_COLOR,
15
- useValue: '#eeeeee',
16
- },
17
- ],
18
- })
19
- export class ChipsModule {
20
- public static forRoot(): ModuleWithProviders<ChipsModule> {
21
- return {
22
- ngModule: ChipsModule,
23
- providers: [
24
- {
25
- provide: CHIP_COLOR,
26
- useValue: '#ff5454',
27
- },
28
- ],
29
- };
30
- }
31
- }
@@ -1,23 +0,0 @@
1
- import { StoryFn, Meta, moduleMetadata } from '@storybook/angular';
2
- import { ChipsModule } from './angular-src/chips.module';
3
- import { ChipComponent } from './angular-src/chip.component';
4
-
5
- export default {
6
- component: ChipComponent,
7
- decorators: [
8
- moduleMetadata({
9
- imports: [ChipsModule],
10
- }),
11
- ],
12
- } as Meta;
13
-
14
- export const Chip: StoryFn = (args) => ({
15
- props: args,
16
- });
17
-
18
- Chip.args = {
19
- displayText: 'Chip',
20
- };
21
- Chip.argTypes = {
22
- removeClicked: { action: 'Remove icon clicked' },
23
- };
@@ -1,50 +0,0 @@
1
- import { StoryFn, Meta, moduleMetadata } from '@storybook/angular';
2
- import { ChipsModule } from './angular-src/chips.module';
3
- import { ChipsGroupComponent } from './angular-src/chips-group.component';
4
- import { CHIP_COLOR } from './angular-src/chip-color.token';
5
-
6
- export default {
7
- // title: 'Basics / NgModule / forRoot() pattern',
8
- component: ChipsGroupComponent,
9
- decorators: [
10
- moduleMetadata({
11
- imports: [ChipsModule.forRoot()],
12
- }),
13
- ],
14
- args: {
15
- chips: [
16
- {
17
- id: 1,
18
- text: 'Chip 1',
19
- },
20
- {
21
- id: 2,
22
- text: 'Chip 2',
23
- },
24
- ],
25
- },
26
- argTypes: {
27
- removeChipClick: { action: 'Remove chip' },
28
- removeAllChipsClick: { action: 'Remove all chips clicked' },
29
- },
30
- } as Meta;
31
-
32
- const Template = (): StoryFn => (args) => ({
33
- props: args,
34
- });
35
-
36
- export const Base = Template();
37
- Base.storyName = 'Chips group';
38
-
39
- export const WithCustomProvider = Template();
40
- WithCustomProvider.decorators = [
41
- moduleMetadata({
42
- providers: [
43
- {
44
- provide: CHIP_COLOR,
45
- useValue: 'yellow',
46
- },
47
- ],
48
- }),
49
- ];
50
- WithCustomProvider.storyName = 'Chips group with overridden provider';
@@ -1,35 +0,0 @@
1
- import { StoryFn, Meta, moduleMetadata } from '@storybook/angular';
2
- import { ChipsModule } from './angular-src/chips.module';
3
- import { ChipsGroupComponent } from './angular-src/chips-group.component';
4
-
5
- export default {
6
- // title: 'Basics / NgModule / Module with multiple component',
7
- component: ChipsGroupComponent,
8
- decorators: [
9
- moduleMetadata({
10
- imports: [ChipsModule],
11
- }),
12
- ],
13
- } as Meta;
14
-
15
- export const ChipsGroup: StoryFn = (args) => ({
16
- props: args,
17
- });
18
-
19
- ChipsGroup.args = {
20
- chips: [
21
- {
22
- id: 1,
23
- text: 'Chip 1',
24
- },
25
- {
26
- id: 2,
27
- text: 'Chip 2',
28
- },
29
- ],
30
- };
31
-
32
- ChipsGroup.argTypes = {
33
- removeChipClick: { action: 'Remove chip' },
34
- removeAllChipsClick: { action: 'Remove all chips clicked' },
35
- };
@@ -1,26 +0,0 @@
1
- import { Component, Input, Output, EventEmitter } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'storybook-button-component',
5
- template: ` <button (click)="onClick.emit($event)">{{ text }}</button> `,
6
- styles: [
7
- `
8
- button {
9
- border: 1px solid #eee;
10
- border-radius: 3px;
11
- background-color: #ffffff;
12
- cursor: pointer;
13
- font-size: 15px;
14
- padding: 3px 10px;
15
- margin: 10px;
16
- }
17
- `,
18
- ],
19
- })
20
- export default class ButtonComponent {
21
- @Input()
22
- text = '';
23
-
24
- @Output()
25
- onClick = new EventEmitter<any>();
26
- }
@@ -1,7 +0,0 @@
1
- import { Meta } from '@storybook/addon-docs';
2
-
3
- <Meta title="stories / frameworks / angular / core / README" />
4
-
5
- # Examples for Storybook native features
6
-
7
- These examples highlight Storybook's native functionality. It does not require any special addon
@@ -1,40 +0,0 @@
1
- import { Meta, StoryObj, applicationConfig } from '@storybook/angular';
2
- import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
3
- import { within, userEvent } from '@storybook/testing-library';
4
- import { expect } from '@storybook/jest';
5
- import { importProvidersFrom } from '@angular/core';
6
- import { OpenCloseComponent } from '../moduleMetadata/angular-src/open-close-component/open-close.component';
7
-
8
- const meta: Meta = {
9
- component: OpenCloseComponent,
10
- decorators: [
11
- applicationConfig({
12
- providers: [importProvidersFrom(BrowserAnimationsModule)],
13
- }),
14
- ],
15
- parameters: {
16
- chromatic: { delay: 100 },
17
- },
18
- };
19
-
20
- export default meta;
21
-
22
- type Story = StoryObj<typeof OpenCloseComponent>;
23
-
24
- export const WithBrowserAnimations: Story = {
25
- render: () => ({
26
- template: `<app-open-close></app-open-close>`,
27
- moduleMetadata: {
28
- declarations: [OpenCloseComponent],
29
- },
30
- }),
31
- play: async ({ canvasElement }) => {
32
- const canvas = within(canvasElement);
33
- const opened = canvas.getByText('The box is now Open!');
34
- expect(opened).toBeDefined();
35
- const submitButton = canvas.getByRole('button');
36
- await userEvent.click(submitButton);
37
- const closed = canvas.getByText('The box is now Closed!');
38
- expect(closed).toBeDefined();
39
- },
40
- };
@@ -1,35 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/angular';
2
- import { NoopAnimationsModule } from '@angular/platform-browser/animations';
3
- import { within, userEvent } from '@storybook/testing-library';
4
- import { expect } from '@storybook/jest';
5
- import { importProvidersFrom } from '@angular/core';
6
- import { OpenCloseComponent } from '../moduleMetadata/angular-src/open-close-component/open-close.component';
7
-
8
- const meta: Meta = {
9
- component: OpenCloseComponent,
10
- };
11
-
12
- export default meta;
13
-
14
- type Story = StoryObj<typeof OpenCloseComponent>;
15
-
16
- export const WithNoopBrowserAnimations: Story = {
17
- render: () => ({
18
- template: `<app-open-close></app-open-close>`,
19
- applicationConfig: {
20
- providers: [importProvidersFrom(NoopAnimationsModule)],
21
- },
22
- moduleMetadata: {
23
- declarations: [OpenCloseComponent],
24
- },
25
- }),
26
- play: async ({ canvasElement }) => {
27
- const canvas = within(canvasElement);
28
- const opened = canvas.getByText('The box is now Open!');
29
- expect(opened).toBeDefined();
30
- const submitButton = canvas.getByRole('button');
31
- await userEvent.click(submitButton);
32
- const closed = canvas.getByText('The box is now Closed!');
33
- expect(closed).toBeDefined();
34
- },
35
- };
@@ -1,20 +0,0 @@
1
- import { Component, Input, Output, EventEmitter } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'child-component',
5
- template: `
6
- Child<br />
7
- Input text: {{ childText }} <br />
8
- Output : <button (click)="onClickChild.emit($event)">Click here !</button> <br />
9
- Private text: {{ childPrivateText }} <br />
10
- `,
11
- })
12
- export default class ChildComponent {
13
- @Input()
14
- childText = '';
15
-
16
- childPrivateText = '';
17
-
18
- @Output()
19
- onClickChild = new EventEmitter<any>();
20
- }
@@ -1,99 +0,0 @@
1
- // your-component.stories.ts
2
-
3
- import { Args, Meta, Story, componentWrapperDecorator, moduleMetadata } from '@storybook/angular';
4
- import ChildComponent from './child.component';
5
- import ParentComponent from './parent.component';
6
-
7
- export default {
8
- // title: 'Core / Decorators / ComponentWrapperDecorator',
9
- component: ChildComponent,
10
- decorators: [
11
- componentWrapperDecorator(
12
- (story) => `Grandparent<br><div style="margin: 3em; border:solid;">${story}</div>`
13
- ),
14
- ],
15
- args: { childText: 'Child text', childPrivateText: 'Child private text' },
16
- argTypes: { onClickChild: { action: 'onClickChild' } },
17
- } as Meta;
18
-
19
- export const WithTemplate = (args: Args) => ({
20
- template: `Child Template`,
21
- props: {
22
- ...args,
23
- },
24
- });
25
-
26
- export const WithComponent = (args: Args) => ({
27
- props: {
28
- ...args,
29
- },
30
- });
31
-
32
- export const WithLegacyComponent = (args: Args) => ({
33
- component: ChildComponent,
34
- props: {
35
- ...args,
36
- },
37
- });
38
-
39
- export const WithComponentWrapperDecorator = (args: Args) => ({
40
- component: ChildComponent,
41
- props: {
42
- ...args,
43
- },
44
- });
45
- WithComponentWrapperDecorator.decorators = [
46
- moduleMetadata({ declarations: [ParentComponent] }),
47
- componentWrapperDecorator(ParentComponent),
48
- ];
49
-
50
- export const WithComponentWrapperDecoratorAndProps = (args: Args) => ({
51
- component: ChildComponent,
52
- props: {
53
- ...args,
54
- },
55
- });
56
- WithComponentWrapperDecoratorAndProps.decorators = [
57
- moduleMetadata({ declarations: [ParentComponent] }),
58
- componentWrapperDecorator(ParentComponent, {
59
- parentText: 'Parent text',
60
- onClickParent: () => {
61
- console.log('onClickParent');
62
- },
63
- }),
64
- ];
65
-
66
- export const WithComponentWrapperDecoratorAndArgs = (args: Args) => ({
67
- component: ChildComponent,
68
- props: {
69
- ...args,
70
- },
71
- });
72
- WithComponentWrapperDecoratorAndArgs.argTypes = {
73
- parentText: { control: { type: 'text' } },
74
- onClickParent: { action: 'onClickParent' },
75
- };
76
- WithComponentWrapperDecoratorAndArgs.decorators = [
77
- moduleMetadata({ declarations: [ParentComponent] }),
78
- componentWrapperDecorator(ParentComponent, ({ args }) => ({
79
- parentText: args.parentText,
80
- onClickParent: args.onClickParent,
81
- })),
82
- ];
83
-
84
- export const WithCustomDecorator = (args: Args) => ({
85
- template: `Child Template`,
86
- props: {
87
- ...args,
88
- },
89
- });
90
- WithCustomDecorator.decorators = [
91
- (storyFunc) => {
92
- const story = storyFunc();
93
-
94
- return {
95
- ...story,
96
- template: `Custom Decorator <div style="margin: 3em">${story.template}</div>`,
97
- };
98
- },
99
- ] as Story['decorators'];
@@ -1,18 +0,0 @@
1
- import { Component, Input, Output, EventEmitter } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'parent-component',
5
- template: `
6
- Parent<br />
7
- Input text: {{ parentText }} <br />
8
- Output : <button (click)="onClickParent.emit($event)">Click here !</button> <br />
9
- <div style="margin: 3em; border:solid;"><ng-content></ng-content></div>
10
- `,
11
- })
12
- export default class ParentComponent {
13
- @Input()
14
- parentText = '';
15
-
16
- @Output()
17
- onClickParent = new EventEmitter<any>();
18
- }
@@ -1,20 +0,0 @@
1
- import { Args, Meta, componentWrapperDecorator } from '@storybook/angular';
2
-
3
- export const Base = (args: Args) => ({
4
- template: 'Change theme with the brush in toolbar',
5
- props: {
6
- ...args,
7
- },
8
- });
9
-
10
- export default {
11
- // title: 'Core / Decorators / Theme Decorators',
12
- component: Base,
13
- decorators: [
14
- componentWrapperDecorator(
15
- (story) => `<div [class]="myTheme">${story}</div>`,
16
-
17
- ({ globals }) => ({ myTheme: `${globals['theme']}-theme` })
18
- ),
19
- ],
20
- } as Meta;
@@ -1,10 +0,0 @@
1
- import { PipeTransform, Pipe } from '@angular/core';
2
-
3
- @Pipe({
4
- name: 'customPipe',
5
- })
6
- export class CustomPipePipe implements PipeTransform {
7
- transform(value: any, args?: any): any {
8
- return `CustomPipe: ${value}`;
9
- }
10
- }
@@ -1,14 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
-
3
- @Injectable({ providedIn: 'root' })
4
- export class DummyService {
5
- constructor() {}
6
-
7
- getItems() {
8
- return new Promise((resolve) => {
9
- setTimeout(() => {
10
- resolve(['Joe', 'Jane']);
11
- }, 2000);
12
- });
13
- }
14
- }
@@ -1,13 +0,0 @@
1
- :host {
2
- display: block;
3
- margin-top: 1rem;
4
- }
5
-
6
- .open-close-container {
7
- border: 1px solid #dddddd;
8
- margin-top: 1em;
9
- padding: 20px 20px 0px 20px;
10
- color: #000000;
11
- font-weight: bold;
12
- font-size: 20px;
13
- }
@@ -1,7 +0,0 @@
1
- <nav>
2
- <button type="button" (click)="toggle()">Toggle Open/Close</button>
3
- </nav>
4
-
5
- <div [@openClose]="isOpen ? 'open' : 'closed'" class="open-close-container">
6
- <p>The box is now {{ isOpen ? 'Open' : 'Closed' }}!</p>
7
- </div>
@@ -1,39 +0,0 @@
1
- import { Component } from '@angular/core';
2
- // eslint-disable-next-line import/no-extraneous-dependencies
3
- import { trigger, state, style, transition, animate } from '@angular/animations';
4
-
5
- @Component({
6
- selector: 'app-open-close',
7
- animations: [
8
- trigger('openClose', [
9
- // ...
10
- state(
11
- 'open',
12
- style({
13
- height: '200px',
14
- opacity: 1,
15
- backgroundColor: 'yellow',
16
- })
17
- ),
18
- state(
19
- 'closed',
20
- style({
21
- height: '100px',
22
- opacity: 0.8,
23
- backgroundColor: 'blue',
24
- })
25
- ),
26
- transition('open => closed', [animate('0.1s')]),
27
- transition('closed => open', [animate('0.1s')]),
28
- ]),
29
- ],
30
- templateUrl: 'open-close.component.html',
31
- styleUrls: ['open-close.component.css'],
32
- })
33
- export class OpenCloseComponent {
34
- isOpen = true;
35
-
36
- toggle() {
37
- this.isOpen = !this.isOpen;
38
- }
39
- }
@@ -1,24 +0,0 @@
1
- import { OnInit, Component, Input } from '@angular/core';
2
- import { DummyService } from './dummy.service';
3
-
4
- @Component({
5
- selector: 'storybook-simple-service-component',
6
- template: `
7
- <p>{{ name }}:</p>
8
- <ul>
9
- <li *ngFor="let item of items">{{ item }}</li>
10
- </ul>
11
- `,
12
- })
13
- export class ServiceComponent implements OnInit {
14
- items?: {};
15
-
16
- @Input()
17
- name?: any;
18
-
19
- constructor(private dummy: DummyService) {}
20
-
21
- async ngOnInit() {
22
- this.items = (await this.dummy.getItems()) as any;
23
- }
24
- }
@@ -1,31 +0,0 @@
1
- import { Component, Input, InjectionToken, Inject, Optional } from '@angular/core';
2
-
3
- export const ITEMS = new InjectionToken<string[]>('TokenComponent.Items');
4
- export const DEFAULT_NAME = new InjectionToken<string>('TokenComponent.DefaultName');
5
-
6
- @Component({
7
- selector: 'storybook-simple-token-component',
8
- template: `
9
- <h3>{{ name }}</h3>
10
- <p>Items:</p>
11
- <ul>
12
- <li *ngFor="let item of items">{{ item }}</li>
13
- </ul>
14
- `,
15
- })
16
- export class TokenComponent {
17
- items;
18
-
19
- @Input()
20
- name;
21
-
22
- constructor(
23
- @Optional()
24
- @Inject(DEFAULT_NAME)
25
- defaultName: string,
26
- @Inject(ITEMS) items: string[]
27
- ) {
28
- this.name = defaultName;
29
- this.items = items;
30
- }
31
- }
@@ -1,38 +0,0 @@
1
- import { StoryFn, Meta, moduleMetadata } from '@storybook/angular';
2
- import { TokenComponent, ITEMS, DEFAULT_NAME } from './angular-src/token.component';
3
-
4
- export const Story1: StoryFn = () => ({
5
- template: `<storybook-simple-token-component [name]="name"></storybook-simple-token-component>`,
6
- props: {
7
- name: 'Prop Name',
8
- },
9
- });
10
-
11
- Story1.storyName = 'Story 1';
12
-
13
- export const Story2: StoryFn = () => ({
14
- template: `<storybook-simple-token-component></storybook-simple-token-component>`,
15
- });
16
-
17
- Story2.storyName = 'Story 2';
18
-
19
- export default {
20
- // title: 'Core / ModuleMetadata / In export default with decorator',
21
- component: Story1,
22
- decorators: [
23
- moduleMetadata({
24
- imports: [],
25
- declarations: [TokenComponent],
26
- providers: [
27
- {
28
- provide: ITEMS,
29
- useValue: ['Joe', 'Jane'],
30
- },
31
- {
32
- provide: DEFAULT_NAME,
33
- useValue: 'Provider Name',
34
- },
35
- ],
36
- }),
37
- ],
38
- } as Meta;