I'm coming from storybook pre 5.2 using storiesOf whereby if i wanted to wrap my component I would use template.
EG
.add('Test', () => ({
component: TestComponent,
template: `
<div class="wrapper">
<test-component></test-component>...
In 5.2 the recommended way to write stories has changed and describes how to use decorators to achieve the same outcome https://storybook.js.org/docs/basics/writing-stories/#decorators. However I am using angular and struggling to find a solution as there are only react and vue examples. Both of which use specific functions / components
In Vue projects you have to use the special component
<story/>instead of the function parameterstoryFnthat is used in React projects
Using template as in the older spec I have tried the following
- As an initial test that
templateworks
export const Test = () => ({
component: TestComponent,
template: `Expecting just this text`
});
Outcome: See the text 'Expecting just this text'
- Using
<TestComponent>
export const Test = () => ({ component: TestComponent,
template: <div class="wrapper"><TestComponent></TestComponent></div>
});
Outcome: Blank screen with Template parse errors:
'CheckboxComponent' is not a known element: suggesting use of `schemas: [CUSTOM_ELEMENTS_SCHEMA]
- Using
<test-component>
export const Test = () => ({
component: TestComponent,
template: `<div class="wrapper"><test-component></test-component></div>`
});
Outcome: Blank screen with Template parse errors: 'CheckboxComponent' is not a known element: suggesting use of schemas: [CUSTOM_ELEMENTS_SCHEMA]
For both 2 & 3 I tried adding
export const Test = () => ({
component: TestComponent,
addDecorator: moduleMetadata({
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}),
template: `[tried both templates from 2 & 3]`
});
Outcome: Same errors appeared again
Could someone shed some light on how this would accomplished in typescript and where I am going wrong - thanks.