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 #12665 from lachieh/next
Addon-docs: Fix type aliases and enum types from Angular Compodoc JSON
- Loading branch information
Showing
7 changed files
with
259 additions
and
5 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
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
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
32 changes: 32 additions & 0 deletions
32
...ular-cli/src/stories/component-with-enums/__snapshots__/enums.component.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,32 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots Enum Types Basic 1`] = ` | ||
<storybook-dynamic-app-root | ||
cfr={[Function CodegenComponentFactoryResolver]} | ||
data={[Function Object]} | ||
target={[Function ViewContainerRef_]} | ||
> | ||
<app-enums> | ||
<div> | ||
<div> | ||
unionType: union a | ||
</div> | ||
<div> | ||
aliasedUnionType: Type Alias 1 | ||
</div> | ||
<div> | ||
enumNumeric: | ||
</div> | ||
<div> | ||
enumNumericInitial: 1 | ||
</div> | ||
<div> | ||
enumStrings: PRIMARY | ||
</div> | ||
<div> | ||
enumAlias: | ||
</div> | ||
</div> | ||
</app-enums> | ||
</storybook-dynamic-app-root> | ||
`; |
8 changes: 8 additions & 0 deletions
8
examples/angular-cli/src/stories/component-with-enums/enums.component.html
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,8 @@ | ||
<div> | ||
<div>unionType: {{ unionType }}</div> | ||
<div>aliasedUnionType: {{ aliasedUnionType }}</div> | ||
<div>enumNumeric: {{ enumNumeric }}</div> | ||
<div>enumNumericInitial: {{ enumNumericInitial }}</div> | ||
<div>enumStrings: {{ enumStrings }}</div> | ||
<div>enumAlias: {{ enumAlias }}</div> | ||
</div> |
25 changes: 25 additions & 0 deletions
25
examples/angular-cli/src/stories/component-with-enums/enums.component.stories.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,25 @@ | ||
import { Story, Meta } from '@storybook/angular'; | ||
import { | ||
EnumsComponent, | ||
EnumNumeric, | ||
EnumNumericInitial, | ||
EnumStringValues, | ||
} from './enums.component'; | ||
|
||
export default { | ||
title: 'Enum Types', | ||
component: EnumsComponent, | ||
} as Meta; | ||
|
||
export const Basic: Story = (args) => ({ | ||
component: EnumsComponent, | ||
props: args, | ||
}); | ||
Basic.args = { | ||
unionType: 'union a', | ||
aliasedUnionType: 'Type Alias 1', | ||
enumNumeric: EnumNumeric.FIRST, | ||
enumNumericInitial: EnumNumericInitial.UNO, | ||
enumStrings: EnumStringValues.PRIMARY, | ||
enumAlias: EnumNumeric.FIRST, | ||
}; |
53 changes: 53 additions & 0 deletions
53
examples/angular-cli/src/stories/component-with-enums/enums.component.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,53 @@ | ||
import { Component, Input } from '@angular/core'; | ||
|
||
/** | ||
* This component is used for testing the various forms of enum types | ||
*/ | ||
@Component({ | ||
selector: 'app-enums', | ||
templateUrl: './enums.component.html', | ||
}) | ||
export class EnumsComponent { | ||
/** Union Type of string literals */ | ||
@Input() unionType: 'Union A' | 'Union B' | 'Union C'; | ||
|
||
/** Union Type assigned as a Type Alias */ | ||
@Input() aliasedUnionType: TypeAlias; | ||
|
||
/** Base Enum Type with no assigned values */ | ||
@Input() enumNumeric: EnumNumeric; | ||
|
||
/** Enum with initial numeric value and auto-incrementing subsequent values */ | ||
@Input() enumNumericInitial: EnumNumericInitial; | ||
|
||
/** Enum with string values */ | ||
@Input() enumStrings: EnumStringValues; | ||
|
||
/** Type Aliased Enum Type */ | ||
@Input() enumAlias: EnumAlias; | ||
} | ||
|
||
/** | ||
* Button Priority | ||
*/ | ||
export enum EnumNumeric { | ||
FIRST, | ||
SECOND, | ||
THIRD, | ||
} | ||
|
||
export enum EnumNumericInitial { | ||
UNO = 1, | ||
DOS, | ||
TRES, | ||
} | ||
|
||
export enum EnumStringValues { | ||
PRIMARY = 'PRIMARY', | ||
SECONDARY = 'SECONDARY', | ||
TERTIARY = 'TERTIARY', | ||
} | ||
|
||
export type EnumAlias = EnumNumeric; | ||
|
||
type TypeAlias = 'Type Alias 1' | 'Type Alias 2' | 'Type Alias 3'; |