#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: mkcom <ComponentName>"
exit 1
fi
COMPONENT_NAME=$1
COMPONENT_NAME_LOWERCASE=$(echo "$COMPONENT_NAME" | tr '[:upper:]' '[:lower:]')
COMPONENT_DIR="components/$COMPONENT_NAME"
mkdir -p "$COMPONENT_DIR"
cd "$COMPONENT_DIR" || exit
touch "$COMPONENT_NAME.tsx" "$COMPONENT_NAME.module.scss" "index.ts"
echo "export { $COMPONENT_NAME } from './$COMPONENT_NAME';" >index.ts
cat <<EOF >"$COMPONENT_NAME.tsx"
import styles from './$COMPONENT_NAME.module.scss';
export function ${COMPONENT_NAME}() {
return (
<div className={styles.$COMPONENT_NAME_LOWERCASE}>
<h2>$COMPONENT_NAME</h2>
</div>
);
};
EOF
cat <<EOF >"$COMPONENT_NAME.module.scss"
.$COMPONENT_NAME_LOWERCASE {
color: var(--color);
}
EOF
echo "✅ $COMPONENT_NAME created in components/$COMPONENT_NAME"
code "$COMPONENT_NAME.tsx" "$COMPONENT_NAME.module.scss"