Closed ehcorrea closed 2 years ago
What is your proposal for adding this tool?
What is your proposal for adding this tool?
You can generate componet files with a single comand, based on templates. My idea was to have more templates, but I saw that they removed the test files. You can forcing an initial pattern and complementing with the prettier. For exemple, with command generate Button
, you could have three files created:
The component file(Button.tsx) with the initial structure(including imports):
import {ButtonProps} fom './types'
import "./Button.css";
const Button = ({childrens, ...props}: ButtonProps) => <button ...props>{childrens}</button>
export default Button
.button{
height: 20px;
max-width: 50px;
width: 100%;
}
import { screen, render } from '@testing-library/react';
import Button from './'
describe('', () => { it('should render the medium size by default', () => { render (); expect(screen.getByRole('button', { name: /lorem ipsum/i })).tobeInTheDocument(); }); });
Gotcha. Nice.
I have one more question, do you believe we'll need this tool to generate these files? I feel that our roadmap is not big enough to have generators. Your point regarding tests is a good one, though.
Agree, think we can hold this one for now. Then, if we feel the need on creating a larger amount of new components we put this in our radar again. @ehcorrea is that okay?
Agree, think we can hold this one for now. Then, if we feel the need on creating a larger amount of new components we put this in our radar again. @ehcorrea is that okay?
Nice. Thats all right, its a simple modification to do;
How to use: Run the command yarn generate ComponentName Write the folder inside component folder
Result: A file will be created in the folder inside component folder, with initial structures already defined: ComponentName.tsx
Road Map: In the future, new templates can be added, such as styles, tests and stories.
Used libs: plop