Last active
June 5, 2023 02:48
-
-
Save giangdhwhtbr/201c484d2753332f06807845a06496be to your computer and use it in GitHub Desktop.
Create React Component
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
#!/bin/bash | |
# Prompt user for the component name | |
echo "Enter the name of the React component in:" | |
read component_name | |
capitalized_name=$(perl -pe 's/^./\U$&/' <<< $component_name) | |
echo "Enter the dest path of the component $component_name" | |
read component_path | |
# Create the components directory if it doesn't already exist | |
if [ ! -d $component_path ]; then | |
mkdir -p $component_path | |
fi | |
# Create the component file | |
dest_file_path="${component_path}/$component_name" | |
touch $dest_file_path | |
echo "import { twMerge } from 'tailwind-merge' | |
export function $capitalized_name({ className = '' }) { | |
return ( | |
<div className={twMerge('', className)}> | |
</div> | |
) | |
}" > $dest_file_path | |
echo "Successfully created React component file at $dest_file_path!" |
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
#!/bin/bash | |
# Prompt user for the component name | |
echo "Enter the name of the React component in:" | |
read component_name | |
capitalized_name=$(perl -pe 's/^./\U$&/' <<< $component_name) | |
# Create the components directory if it doesn't already exist | |
if [ ! -d "components" ]; then | |
mkdir components | |
fi | |
# Create the component file | |
touch "components/$component_name.ts" | |
echo "import { twMerge } from 'tailwind-merge' | |
export function $capitalized_name({ className = '' }) { | |
return ( | |
<div className={twMerge('', className)}> | |
</div> | |
) | |
}" > "components/$component_name.ts" | |
echo "Successfully created React component file for $component_name!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment