-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plopfile): add file generator with plopfile
add file templates from a standard component for automatic generation using plopfile.
- Loading branch information
1 parent
4eef0b1
commit 1cd9a4f
Showing
7 changed files
with
585 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = function (plop) { | ||
plop.setGenerator('component', { | ||
description: 'application component', | ||
|
||
prompts: [ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: 'component name?' | ||
} | ||
], | ||
|
||
actions: [ | ||
{ | ||
type: 'add', | ||
path: '../src/components/{{pascalCase name}}/index.tsx', | ||
templateFile: 'templates/index.tsx.hbs' | ||
}, | ||
{ | ||
type: 'add', | ||
path: '../src/components/{{pascalCase name}}/index.stories.tsx', | ||
templateFile: 'templates/index.stories.tsx.hbs' | ||
}, | ||
{ | ||
type: 'add', | ||
path: '../src/components/{{pascalCase name}}/styles.ts', | ||
templateFile: 'templates/styles.ts.hbs' | ||
}, | ||
{ | ||
type: 'add', | ||
path: '../src/components/{{pascalCase name}}/test.tsx', | ||
templateFile: 'templates/test.tsx.hbs' | ||
} | ||
] | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/react'; | ||
|
||
import { {{pascalCase name}} } from '.'; | ||
|
||
export default { | ||
title: '{{pascalCase name}}', | ||
component: {{pascalCase name}}, | ||
} as Meta; | ||
|
||
export const Default: Story = args => { | ||
return <{{pascalCase name}} {...args} />; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
|
||
import * as S from './styles'; | ||
|
||
export const {{pascalCase name}} = () => { | ||
return ( | ||
<S.Wrapper> | ||
<h1>{{pascalCase name}}</h1> | ||
</S.Wrapper> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Wrapper = styled.div``; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import { {{pascalCase name}} } from '.'; | ||
|
||
describe('<{{pascalCase name}} />', () => { | ||
it('should render the heading', () => { | ||
render(<{{pascalCase name}} />); | ||
|
||
expect( | ||
screen.getByRole('heading', { name: /{{pascalCase name}}/i }) | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.