brdevstreamers / brdevstreamers-ui

https://brstreamers.dev
Apache License 2.0
60 stars 20 forks source link

feat(plop): added plop file to automatic generate component files #36

Closed ehcorrea closed 2 years ago

ehcorrea commented 2 years ago

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

NandoSangenetto commented 2 years ago

What is your proposal for adding this tool?

ehcorrea commented 2 years ago

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:

  1. 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
    1. The styles file with the initial structure:
      .button{
      height: 20px;
      max-width: 50px;
      width: 100%;
      } 
  2. The test file with the initial structure:
    
    import { screen, render } from '@testing-library/react';
    import Button from './'

describe('); expect(screen.getByRole('button', { name: /lorem ipsum/i })).tobeInTheDocument(); }); });

NandoSangenetto commented 2 years ago

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.

flaviojmendes commented 2 years ago

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?

ehcorrea commented 2 years ago

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;