-
-
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
[app/angular] Add ability to define component props binding in story. #2469
Comments
@ralzinov this is something we definitely want in Do you think you could take this proposal one step further and issue a PR? I'm more than willing to guide you if something doesn't make sense (although it looks like you're well versed in Angular :) ) |
@alterx Thank you! I think i can do that. But that api seems to me little dirty solution, bindings rarely changing, what if do that with another decorator like this:
|
Hmmm, what would this bring to the table that the other approach (a simple object) wouldn't? 🤔 I'd lean towards something in the lines of the first example, like this:
or even using 'tuples' (simple 2-item arrays that we can destructure) to avoid putting the name
this way we can also provide shorthands:
in the above example we could assume that a single string instead of an array means an @input prop or that a function instead of an array means an @output, for example. What do you think @ralzinov ? |
Mm its just less verbose and has better readability. I thought about decorators because you can decorate component once at top and use it in stories. You can also pass there other things ( f.e dependencies for ngModule) which don't change. It is more laconically than "propsBinding" property in every story and 1 and 2 methods. Problem with 3 method can be if somebody want to pass a callback or class as input, or maybe JS objects like Date which also are functions. What if functions would be recognized as outputs by default, but user can define bindings through decorator
I think nothing wrong if apps can have own decorators. What do you think? @alterx |
I agree with you concerns with method # 3 Readability is somewhat subjective, what's readable for me it's not necessarily readable for others. And it just feels like the percentage of verbosity reduced isn't worth. However, decorating a component a single time and then using it in several stories does feel like a solid reason to lean towards this approach. Ok, I think I've made my mind up. Let's give this approach a go and we can iterate over it once we have a working PR. Does that work for you, @ralzinov ? |
Ok, i will do that |
@ralzinov Could you join us on the storybook slack? |
WHOOPS didn't mean to close at all |
Hey @ralzinov , what about a simpler API? Take a look at #269 (comment). I think we could just allow users to provide a template. Given that we already have an |
This looks really promising @ralzinov , we could offload the tricky parts of dynamic component generation 🤔 |
The new |
Issue details
Angular components can have 3 types of binding for props. Binding should be defined by template, like:
But currently story components are rendered dynamically and there is no way to define binding for props of story. I think something like this would be solution for that:
The text was updated successfully, but these errors were encountered: