Skip to content

Commit

Permalink
feat(storybook): csf3 stories generator
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini committed Feb 23, 2023
1 parent cbf33c4 commit d6db89b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import { moduleMetadata, Story, Meta } from '@storybook/angular';
import { Meta } from '@storybook/angular';
import { <%=componentName%> } from './<%=componentFileName%>';

export default {
title: '<%=componentName%>',
component: <%=componentName%>,
decorators: [
moduleMetadata({
imports: [],
})
],
component: <%=componentName%>
} as Meta<<%=componentName%>>;

const Template: Story<<%=componentName%>> = (args: <%=componentName%>) => ({
props: args,
});


export const Primary = Template.bind({});
Primary.args = {<% for (let prop of props) { %>
export const Primary = {
render: (args: <%=componentName%>) => ({
props: args,
}),
args: {<% for (let prop of props) { %>
<%= prop.name %>: <%- prop.defaultValue %>,<% } %>
}
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if ( !isPlainJs ) { %>import type { ComponentStory, ComponentMeta } from '@storybook/react';<% } %>
<% if ( !isPlainJs ) { %>import type { Meta } from '@storybook/react';<% } %>
import<% if ( !isPlainJs ) { %> { <% } %> <%= componentName %> <% if ( !isPlainJs ) { %> } <% } %> from './<%= componentImportFileName %>';

<% if ( isPlainJs ) { %>
Expand All @@ -14,7 +14,7 @@ export default {


<% if ( !isPlainJs ) { %>
const Story: ComponentMeta<typeof <%= componentName %>> = {
const Story: Meta<typeof <%= componentName %>> = {
component: <%= componentName %>,
title: '<%= componentName %>',<% if ( argTypes && argTypes.length > 0 ) { %>
argTypes: {<% for (let argType of argTypes) { %>
Expand All @@ -25,9 +25,8 @@ const Story: ComponentMeta<typeof <%= componentName %>> = {
export default Story;
<% } %>

const Template<% if ( !isPlainJs ) { %>: ComponentStory< typeof <%= componentName %> ><% } %> = (args) => <<%= componentName %> {...args} />;

export const Primary = Template.bind({})
Primary.args = {<% for (let prop of props) { %>
export const Primary = {
args: {<% for (let prop of props) { %>
<%= prop.name %>: <%- prop.defaultValue %>,<% } %>
}
},
};

0 comments on commit d6db89b

Please sign in to comment.