Skip to content

Instantly share code, notes, and snippets.

@dgaitsgo
Created July 13, 2022 03:08
Show Gist options
  • Select an option

  • Save dgaitsgo/611a5318f497b14301824ebfb30af34c to your computer and use it in GitHub Desktop.

Select an option

Save dgaitsgo/611a5318f497b14301824ebfb30af34c to your computer and use it in GitHub Desktop.
New React/CSS Module TS Component
#!/bin/bash
if [ "$1" == "" ]; then
echo "Missing $component name"
exit 0
fi
for comp in "$@"
do
if [ ! -d ./$comp ]; then
echo -e "Creating $comp/$comp.tsx"
echo -e "Creating $comp/$comp.module.css"
echo -e "Creating $comp/index.ts"
fi
mkdir $comp
touch $comp/$comp.module.css
touch $comp/$comp.tsx
touch $comp/index.ts
class=$"import styles from './$comp.module.css'
interface "$comp"Props {
}
function $comp({ }: "$comp"Props) {
return ()
}
export default $comp"
index=$"export { default } from './$comp'"
echo "$class" > $comp/$comp.tsx
echo "$index" > $comp/index.ts
done
@dgaitsgo
Copy link
Author

dgaitsgo commented Jul 13, 2022

Put this in /usr/local/bin/next-comp
$> next-comp ComponentName
Creating ComponentName/ComponentName.tsx
Creating ComponentName/ComponentName.module.css
Creating ComponentName/index.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment