I'm tired of creating a new component structure every time for React.
Idea totally not stolen from @joshwcomeau/new-component ;)
Here's the folder/file breakdown:
-
Folder: <name-of-component>
-
index.js: Contains the logic for the component -
styled.js: Some sweet styling fromstyled-components
-
-
The help command
➜ mkcomp --help mkcomp creates boilerplate code for a new React component and leverages styled-components. Usage: mkcomp [component-name-1] [component-name-2] ... [component-name-n] Type mkcomp -h or mkcomp --help to repeat this message. -
Creating new components
➜ mkcomp Button Dropdown Sidebar Modal Project Directory: /home/codeabiswas/Developer/mkcomp Creating a components folder... Button has been successfully created! Dropdown has been successfully created! Sidebar has been successfully created! Modal has been successfully created!
Note: This has only been tried and tested on Ubuntu. It has good chances of working with MacOS. Strong doubt on Windows (unless some WSL magic is involved but it hasn't been tested).
- Clone or download this repo (unzip if downloaded).
- Unless you have one already, create a root folder in your root directory called
bin/.
cd ~
mkdir bin/
- Add the absolute path of the
bin/directory to your.bashrc(or.bash_profile,.zshrc, etc.) as shown below.
export PATH=$PATH:<absolute-path-of-bin/-directory>
- Copy the
mkcompfile to that folder
cp mkcomp ~/bin
- Give
mkcompexecutable rights after entering thebin/folder
cd ~/bin
chmod +x mkcomp
- Andrei Biswas @codeabiswas