-
Notifications
You must be signed in to change notification settings - Fork 29
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
Provide decorator support for Angular #24
Comments
Hi @CodeByAlex in fact each framework need its custom decorator development. |
That would be awesome! Thanks - please let me know if I could be of help @tonai |
Hi @CodeByAlex , I started to have a look to implement Angular but there is some difficulties and maybe you can help if you want. The decorator is here on the The problem is that the component must rerender when the If you want to help, notice you will have to use the storybook 6.x alpha version. |
Hey there - I’ll take a look 👆 thanks for getting this started so quickly |
@tonai Are there any special setup steps that I should know about? And do you have an example code snippet of how it would be used? Dont see a code snippet for vue so its a but hard to determine how things are supposed to be set up when actually used |
Hello @CodeByAlex here is a little repository that reproduce the problem : https://github.com/tonai/storybook-angular |
Hey @tonai that repo will definitely help - thanks. One thing I’m still missing is how you're thinking the decorator will look/what code you were using to test the decorator when you saw it fail. Based on what I’ve seen, the react decorator setup is very different from the HTML set up so I’m curious what you had in mind for angular. Also wouldn't it be easier to provide a generic decorator that works similarly to your HTML version and have the user pass in specific params like theme name and code? That way you wouldn't have to maintain framework-specific decorators and it would require less from the user. Example usage:
|
Hum I don't really understand your question @CodeByAlex . import { withThemes } from 'storybook-addon-themes/angular';
export default {
title: 'Button',
component: Button,
decorators: [withThemes],
parameters: {
themes: {
list: [
{ name: 'twitter', color: '#00aced', default: true, class: 'theme-twt' },
{ name: 'facebook', color: '#3b5998', class: 'theme-fb' },
]
}
},
}; You can see that code in the example repo: https://github.com/tonai/storybook-angular/blob/master/src/stories/1-Button.stories.ts If you want to see the erreur, clone the repo, install deps, run |
@tonai What I mean is we have these custom Decorators for React like this:
and HTML like this:
What do we expect the Angular one to look like? My other question is, instead of having the user create the decorators above, why not keep a generic one internal that looks similar to the HTML version above. Then pass certain data props to that decorator like in my earlier comment:
So the new setup from a user's perspective would be this:
|
I don't know how custom decorators will be handled for now. |
@tonai - it would be best to make your addon logic framework agnostic (the best and most widely used addons are and it makes it more maintainable). The problem here is that the decorator is expecting it to be passed a change detector reference but it could be that since you are simply trying to compile the ts., it is missing something that the angular build process normally might pick up |
@CodeByAlex You can't make the addon framwork agnostic for decorators. |
@tonai This for instance is a framework agnostic decorator: https://github.com/CodeByAlex/storybook-theme-knob. |
@CodeByAlex with that addon you are injetting code into the body but you are not touching the initial story. |
When the decorator manipulates the Dom, it manipulates what’s in the story itself which is why it works with docs. If you were to eject the story from the storybook app, it would use the default theme. |
When you capture a story with the storyshots addon, it will only capture the story itself (and not all the DOM from the body). So all DOM manipulations you do in your addon (or with this addon without using the decorator) won't get captured. That's why I created the decorator version to add an intermediate div englobing the story that is correclty captured by the snapshot. |
Hi @tonai , is there any change the Angular decorator you created will be merged? |
Sorry for the late reply. |
@tonai do you know what’s causing the addon to not support Angular?
The text was updated successfully, but these errors were encountered: