-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Documentation: angular decorator not working without template #12749
Comments
have you looked at this? #12656 |
@shilman yes this is the documentation I was refering to. I did't know this is so new. I want to know if there is a method of writing wrapping decorators without a template in the story. As a side note: |
For supporting child content, without a template, I think a starting point would be to make this issue work: #10272 @alexan I looked at that centered addon code you linked and that would partially work. It would allow you to render the component, but none of the props would be applied to the component in the template, unless you also implemented something to add them to the template it creates. One of my functions I posted here could partially add them, but it isn't at a point that you could just use it anywhere yet. Here is how you could use the code from that addon, but I don't it is worth doing as it, since none of the inputs/outputs will be applied. // your-component.stories.ts
import { Meta, Story } from '@storybook/angular';
function getComponentSelector(component: any) {
return component.__annotations__[0].selector;
}
function componentAsTemplate(component: any) {
const selector = getComponentSelector(component)
return `<${selector}></${selector}>`
}
export default {
component: YourComponent,
decorators: [
// This is needed, because the decorator we are adding makes the StoryFnReturnType have a `template`
// and Storybook assumes anything used in the `template` has already been declared.
moduleMetadata({ declarations: [ YourComponent] }),
(storyFunc) => {
const story = storyFunc();
return {
...story,
template: `<div style="margin: 3em">${componentAsTemplate(story.component)}</div>`,
};
},
],
} as Meta;
export const Example: Story = (args) => ({
component: YourComponent,
props: args,
}) |
thank you @Marklb here is my attempt:
this code could also be usefull for: #10617 |
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! |
w00t!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.0-alpha.13 containing PR #13507 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
the angular decorator documentation has several not working examples (https://storybook.js.org/docs/angular/writing-stories/decorators)
https://storybook.js.org/docs/angular/writing-stories/decorators#wrap-stories-with-extra-markup
is only working if the story is having an template property.
If only a component is present the template will be undefined and you will get
undefined
wrapped.How can I wrap stories which only have component without a template?
I need a way to consitently wrap all stories with and without template in use.
I found this old addon which also have special handling for stories with templates and without, But I don't know how to apply this to a decorator.
https://github.com/storybookjs/storybook/blob/v5.3.21/addons/centered/src/angular.ts
https://storybook.js.org/docs/angular/writing-stories/decorators#context-for-mocking
is an react example not working in an angular project
The text was updated successfully, but these errors were encountered: