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
Set ngClass/ngStyle from props #12946
Comments
Automention: Hey @MaximSagan @kroeder, you've been tagged! Can you give a hand here? |
I have been thinking about this and my main hesitation is adding custom implementations for directives, because if the functionality isn't exactly the same or someone has another directive/component that thinks it can inject a reference to the directive, it may be confusing. If we could make directives work without a I haven't seen any dynamic Component libraries support directives, without limitations. It makes sense to not build a template string for rendering a component in an app, but for Storybook's use case, it may make sense to do that. |
Makes sense, I definitely feel as though the
We could reconceptualize this as a collection:
I don't love it, but it's certainly closer to how Angular works architecturally. EDIT: i do want to add that I've purposefully left out discussing structural directives within the above example, which may further complicate things 😓 |
@spaceribs As far as how they would be defined, something like that is what I was thinking. The blocker that I am thinking we would need, unless we dynamically create the story component from a template in the renderer, is explained in this issue: angular/angular#8785. We would basically just be composing the directives and there just doesn't seem to be an easy way to do it from js still, for some reason. |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
@ThibaudAV @Marklb per: #13215 (comment) can we close this or does it still need to be documented? |
No, I don't think so :/ . What has been done in #13215 (comment) does not correct this problem. Currently props properties can be of these types:
Current behaviour : (simple explanation)This component -> @Component({selector: 'my-component', template: '' })
class MyComponent {
@Input() input: string;
@Output() output = new EventEmitter<string>();
localProp = 'only for template'
} With this story -> export const Default = args => ({
component: MyComponent,
props: {
input: 'new input value',
output: action('output'),
localProp: 'new localProp'
},
}); Generates this template: The It should be possible to remove local properties of props in order to consider all default props as a template attribute. But this causes braking changes. There may be other possibilities. And even this one requires some feedback before doing a PR. i think 🤔 |
damn @ThibaudAV you totally got my hopes up with:
let me know of course if I can help plan out this functionality within the grander scheme of things @Marklb |
😄 haha sorry. I didn't have all the subtlety in mind yet. |
Is this still an issue in 7.0 beta @spaceribs @ThibaudAV ? |
@ndelangen Yes. There is no way to identify a property in I have a fairly large change I want to make to the Angular renderer, which I hope to propose in a PR soon, that would potentially make supporting this a little easier. The change I will be proposing reads more information about the compiled template and lets Angular handle more property updating from the template, instead of all properties being directly updated on the component instance. |
You should probably talk to @kroeder and @valentinpalkovic about this PR you have in mind! 👍 |
@Marklb Let me know if you need any support. |
Apologies, I'm still a bit of a noob writing stories with Storybook. When building out angular component stories, I'd like to be able to set a class to style the component in different ways. Currently I'm using templates to perform that:
I'd actually much prefer the following format, but it doesn't seem to work:
I'd be happy to help if this makes any sense to implement or there are no proposed alternatives.
The text was updated successfully, but these errors were encountered: