Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: updated templates to accomodate new naming convention & storybook 6 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plop-templates/js/component.class-component.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { Styled{{name}} } from './style'
import { Styled{{name}} } from './{{selectedComponentCase name}}.style'
import PropTypes from 'prop-types'

class {{name}} extends Component {
2 changes: 1 addition & 1 deletion plop-templates/js/component.function-component.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Styled{{name}} } from './style'
import { Styled{{name}} } from './{{selectedComponentCase name}}.style'
import PropTypes from 'prop-types'

const {{name}} = () =>
2 changes: 1 addition & 1 deletion plop-templates/js/component.pure-component.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react'
import { Styled{{name}} } from './style'
import { Styled{{name}} } from './{{selectedComponentCase name}}.style'
import PropTypes from 'prop-types'

class {{name}} extends PureComponent {
2 changes: 1 addition & 1 deletion plop-templates/js/index.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {{name}} from './{{name}}'
import {{name}} from './{{selectedComponentCase name}}'

export default {{name}}
32 changes: 13 additions & 19 deletions plop-templates/js/story.hbs
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import React from 'react'
import { withKnobs, select, boolean, number, text } from '@storybook/addon-knobs'
import { storiesOf } from '@storybook/react'
import {{name}} from './'
import React from 'react';
import {{name}} from './';

const baseProps = {
export default {
title: '{{name}}',
component: {{name}},
};

}
const Template = (args) => {
return <{{name}} {...args} />;
};

const stories = storiesOf('{{name}}', module)
export const Main = Template.bind({});

// stories.addDecorator(withKnobs)

stories.add('basic', () => <{{name}} {...baseProps} />)

/*stories.add('dynamic props', () => (
<{{name}}
{...baseProps}
editMode={boolean('editMode', false)}
borderSize={number('borderSize', 1)}
width={text('width', '')}
/>
))*/
Main.args = {
// add default prop values here
};
14 changes: 7 additions & 7 deletions plop-templates/js/test.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import 'jest-styled-components'
import renderer from 'react-test-renderer'
import {{ name }} from './index'
import React from 'react';
import 'jest-styled-components';
import { render } from 'react-testing-library';
import {{ name }} from './'

describe('<{{name}} />', () => {
const props
@@ -12,7 +12,7 @@ describe('<{{name}} />', () => {
})

it('should render correctly', () => {
const tree = renderer.create(<{{name}} {...props} />).toJSON()
expect(tree).toMatchSnapshot()
})
const instance = render(<{{name}} {...props} />);
expect(instance).toMatchSnapshot();
});
})
2 changes: 1 addition & 1 deletion plop-templates/ts/component.class-component.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { Styled{{name}} } from './style'
import { Styled{{name}} } from './{{selectedComponentCase name}}.style'
import PropTypes from 'prop-types'

export interface {{name}}Props {
6 changes: 3 additions & 3 deletions plop-templates/ts/component.function-component.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FunctionComponent } from 'react'
import { Styled{{name}} } from './style'
import React, { FC } from 'react'
import { Styled{{name}} } from './{{selectedComponentCase name}}.style'

export interface {{name}}Props {

@@ -9,7 +9,7 @@ export interface {{name}}State {

}

const {{name}}:FunctionComponent<{{name}}Props, {{name}}State> = () => {
const {{name}}:FC<{{name}}Props, {{name}}State> = () => {

return (
<Styled{{name}}>
2 changes: 1 addition & 1 deletion plop-templates/ts/component.pure-component.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react'
import { Styled{{name}} } from './style'
import { Styled{{name}} } from './{{selectedComponentCase name}}.style'
import PropTypes from 'prop-types'

export interface {{name}}Props {
2 changes: 1 addition & 1 deletion plop-templates/ts/index.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {{name}} from './{{name}}'
import {{name}} from './{{selectedComponentCase name}}';

export default {{name}}
35 changes: 15 additions & 20 deletions plop-templates/ts/story.hbs
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import React from 'react'
import { withKnobs, select, boolean, number, text } from '@storybook/addon-knobs'
import { storiesOf } from '@storybook/react'
import {{name}}Props from './{{name}}'
import {{name}} from './'
import React from 'react';
import { Story, Meta } from '@storybook/react/types-6-0';
import { {{name}}Props } from './{{selectedComponentCase name}}';
import {{name}} from './';

const baseProps:{{name}}Props = {
export default {
title: '{{name}}',
component: {{name}},
} as Meta;

}
const Template: Story<{{name}}Props> = (args: {{name}}Props) => {
return <{{name}} {...args} />;
};

const stories = storiesOf('{{name}}', module)
export const Main = Template.bind({});

// stories.addDecorator(withKnobs)

stories.add('basic', () => <{{name}} {...baseProps} />)

/*stories.add('dynamic props', () => (
<{{name}}
{...baseProps}
editMode={boolean('editMode', false)}
borderSize={number('borderSize', 1)}
width={text('width', '')}
/>
))*/
Main.args = {
// add default prop values here
};
1 change: 0 additions & 1 deletion plop-templates/ts/style.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import styled from 'styled-components'
// import { ifProp, ifNotProp, switchProp, prop } from 'styled-tools'

export const Styled{{name}} = styled.div`

18 changes: 8 additions & 10 deletions plop-templates/ts/test.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import 'jest-styled-components'
import renderer from 'react-test-renderer'
import { {{name}}Props } from './{{name}}'
import {{ name }} from './index'
import React from 'react';
import 'jest-styled-components';
import { render } from 'react-testing-library';
import { {{name}}Props } from './{{selectedComponentCase name}}';
import {{name}} from './';

describe('<{{name}} />', () => {
const props:{{name}}Props
@@ -13,9 +13,7 @@ describe('<{{name}} />', () => {
})

it('should render correctly', () => {
const tree = renderer.create(
<{{name}} {...props} />
).toJSON()
expect(tree).toMatchSnapshot()
})
const instance = render(<{{name}} {...props} />);
expect(instance).toMatchSnapshot();
});
})
2 changes: 1 addition & 1 deletion plopfile.js
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ module.exports = function(plop) {
if (data.story) {
actions.push({
type: 'add',
path: baseDir + `/{{selectedComponentCase name}}/{{ selectedComponentCase name }}.story.${fileExt}x`,
path: baseDir + `/{{selectedComponentCase name}}/{{ selectedComponentCase name }}.stories.${fileExt}x`,
templateFile: `${templateFile}/story.hbs`,
})
}