-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding extra metadata to module/components #2526
Conversation
Codecov Report
@@ Coverage Diff @@
## release/3.3 #2526 +/- ##
===============================================
+ Coverage 19.45% 19.45% +<.01%
===============================================
Files 387 387
Lines 8734 8733 -1
Branches 944 941 -3
===============================================
Hits 1699 1699
- Misses 6310 6332 +22
+ Partials 725 702 -23
Continue to review full report at Codecov.
|
Signed-off-by: Carlos Vega <clmvega@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is there some documentation that needs to be edited about how to use new features?
- As one that is not familiar with most of the angular things (now better, but still =) ), I think it's very important to add descriptive and intuitive names of just everything. I would like to create some followup PR with a bit refactoring/renaming/separating things, will it be OK?
@@ -13,7 +13,8 @@ import { | |||
OnDestroy, | |||
EventEmitter | |||
} from "@angular/core"; | |||
import { STORY, Data } from "../app.token"; | |||
import { STORY } from "../app.token"; | |||
import { Data } from "../types"; | |||
|
|||
@Component({ | |||
selector: "my-app", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can set a better selector name for the app component? "main-angular-app", "app-root" ... idk ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want these to be the same since they all hook into the same tag in the template.
I'm going to go with app-root
@@ -1,5 +1,6 @@ | |||
import { Component, Inject } from "@angular/core"; | |||
import { STORY, Data } from "../app.token"; | |||
import { STORY } from "../app.token"; | |||
import { Data } from "../types"; | |||
|
|||
@Component({ | |||
selector: "my-app", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here. maybe "error-root"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want these to be the same since they all hook into the same tag in the template.
I'm going to go with app-root
moduleMetadata: NgModuleMetadata | ||
} | ||
|
||
export type Data = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can give this one an intuitive name as well ? And can't we actually use the NgStory type ?
@@ -20,28 +20,11 @@ import { Welcome, Button } from '@storybook/angular/demo'; | |||
import { SimpleKnobsComponent } from './knobs.component'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to separate these examples into different stories like it's done in the react example. Surely not in this PR =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Back when we started with these the react example was this way, we surely need to update these too
name: 'Static name' | ||
}, | ||
moduleMetadata: { | ||
imports: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you put here all the props in order to visually show all the options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is kinda documentation, but maybe add it to a real documentation too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, they're just there to show you can actually add all of them
import { DummyService } from './dummy.service'; | ||
|
||
@Component({ | ||
selector: 'simple-knobs-component', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simple-service-component ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup
@@ -2,7 +2,8 @@ import { | |||
enableProdMode, | |||
NgModule, | |||
Component, | |||
CUSTOM_ELEMENTS_SCHEMA | |||
NgModuleRef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need them, if they are not in use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right, I probably screwed the rebase
:P
@@ -34,7 +36,9 @@ const debounce = (func, wait = 100, immediate = false) => { | |||
}; | |||
}; | |||
|
|||
const getComponentMetadata = ({ component, props = {}, propsMeta = {}, pipes = [] }) => { | |||
const getComponentMetadata = ( | |||
{ component, props = {}, propsMeta = {}, moduleMetadata }: NgStory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moduleMetadata = {}
and you won't need to check it further?
- Changing main tag to a more meaningful name - Removing redundant type Data - Validating moduleMetadata param - Removing unused references Signed-off-by: Carlos Vega <clmvega@gmail.com>
…book into angular-module-metadata
@igor-dv after this one gets merged feel free to submit a PR to rename some stuff, these names were chosen on the go and now that we have a more feature complete product I think there's a lot of room for improvement in naming :) @ndelangen @igor-dv how do we want to procede with documentation? |
I will try to help you, above all in docs. |
@igor-dv I can improve this gif |
@norato it will be very helpful |
Nope. Just merge 👍 |
Issue:
What I did
Added the ability to provide custom metadata to the story. This works, for example, when you need to include a service, a custom pipe or directive.
How to test
yarn bootstrap
cd examples/angular-cli
yarn storybook